Changeset 3437
- Timestamp:
- Jun 18, 2018 11:25:20 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r3435 r3437 321 321 SGErr,SGData = G2spc.SpcGroup(self.newSpGrp) 322 322 self.Phase['General']['SGData'] = SGData 323 SGTxt.Set Value(self.newSpGrp)323 SGTxt.SetLabel(self.newSpGrp) 324 324 OnTest(event) 325 325 … … 327 327 event.Skip() 328 328 SpcGp = GetSpGrpfromUser(self.panel,self.newSpGrp) 329 if SpcGp == self.newSpGrp : #didn't change it!329 if SpcGp == self.newSpGrp or SpcGp is None: #didn't change it! 330 330 return 331 331 # try a lookup on the user-supplied name … … 337 337 if SGErr: 338 338 text = [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous'] 339 SGTxt.Set Value(self.newSpGrp)339 SGTxt.SetLabel(self.newSpGrp) 340 340 msg = 'Space Group Error' 341 341 Text = '\n'.join(text) … … 345 345 self.Phase['General']['SGData'] = SGData 346 346 self.newSpGrp = SpcGp 347 SGTxt.Set Value(self.Phase['General']['SGData']['SpGrp'])347 SGTxt.SetLabel(self.Phase['General']['SGData']['SpGrp']) 348 348 msg = 'Space Group Information' 349 349 G2G.SGMessageBox(self.panel,msg,text,table).Show() -
trunk/GSASIIscriptable.py
r3365 r3437 2318 2318 raise ValueError("Unknown key:", key) 2319 2319 2320 def add_peak(self,area,dspace=None,Q=None,ttheta=None): 2321 '''Adds a single peak to the peak list 2322 :param float area: peak area 2323 :param float dspace: peak position as d-space (A) 2324 :param float Q: peak position as Q (A-1) 2325 :param float ttheta: peak position as 2Theta (deg) 2326 2327 Note: only one of the parameters dspace, Q or ttheta may be specified 2328 ''' 2329 import GSASIIlattice as G2lat 2330 import GSASIImath as G2mth 2331 if (not dspace) + (not Q) + (not ttheta) != 2: 2332 print('add_peak error: too many or no peak position(s) specified') 2333 return 2334 pos = ttheta 2335 Parms,Parms2 = self.data['Instrument Parameters'] 2336 if Q: 2337 pos = G2lat.Dsp2pos(Parms,2.*np.pi/Q) 2338 elif dspace: 2339 pos = G2lat.Dsp2pos(Parms,dspace) 2340 peaks = self.data['Peak List'] 2341 peaks['sigDict'] = {} #no longer valid 2342 peaks['peaks'].append(G2mth.setPeakparms(Parms,Parms2,pos,area)) 2343 2344 def set_peakFlags(self,peaklist=None,area=None,pos=None,sig=None,gam=None): 2345 '''Set refinement flags for peaks 2346 :param list peaklist: a list of peaks to change flags. If None (default), changes 2347 are made to all peaks. 2348 :param bool area: Sets or clears the refinement flag for the peak area value. 2349 If None (the default), no change is made. 2350 :param bool pos: Sets or clears the refinement flag for the peak position value. 2351 If None (the default), no change is made. 2352 :param bool sig: Sets or clears the refinement flag for the peak sig (Gaussian width) value. 2353 If None (the default), no change is made. 2354 :param bool gam: Sets or clears the refinement flag for the peak sig (Lorentzian width) value. 2355 If None (the default), no change is made. 2356 2357 Note that when peaks are first created the area flag is on and the other flags are 2358 initially off. 2359 2360 Example:: 2361 2362 set_peakFlags(sig=False,gam=True) 2363 2364 causes the sig refinement flag to be cleared and the gam flag to be set, in both cases for 2365 all peaks. The position and area flags are not changed from their previous values. 2366 ''' 2367 peaks = self.data['Peak List'] 2368 if peaklist is None: 2369 peaklist = range(len(peaks['peaks'])) 2370 for i in peaklist: 2371 for var,j in [(area,3),(pos,1),(sig,5),(gam,7)]: 2372 if var is not None: 2373 peaks['peaks'][i][j] = var 2374 2375 def refine_peaks(self): 2376 '''Causes a refinement of peak position, background and instrument parameters 2377 ''' 2378 import GSASIIpwd as G2pwd 2379 controls = self.proj.data.get('Controls',{}) 2380 controls = controls.get('data', 2381 {'deriv type':'analytic','min dM/M':0.001,} #fill in defaults if needed 2382 ) 2383 peaks = self.data['Peak List'] 2384 Parms,Parms2 = self.data['Instrument Parameters'] 2385 background = self.data['Background'] 2386 limits = self.data['Limits'][1] 2387 bxye = np.zeros(len(self.data['data'][1][1])) 2388 peaks['sigDict'] = G2pwd.DoPeakFit('LSQ',peaks['peaks'],background,limits, 2389 Parms,Parms2,self.data['data'][1],bxye,[], 2390 False,controls,None)[0] 2320 2391 2321 2392 class G2Phase(G2ObjectWrapper):
Note: See TracChangeset
for help on using the changeset viewer.