Changeset 4892
- Timestamp:
- Apr 24, 2021 12:49:41 PM (21 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r4802 r4892 314 314 Imax = np.amax(Image) 315 315 if G2frame.imageDefault: 316 Data = copy.copy(G2frame.imageDefault)316 Data.update(copy.deepcopy(G2frame.imageDefault)) 317 317 Data['showLines'] = True 318 318 Data['ring'] = [] … … 762 762 Data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Image Controls')) 763 763 if Data['setDefault']: 764 G2frame.imageDefault = Data 764 G2frame.imageDefault = Data 765 G2frame.imageDefault['setDefault'] = False 766 if 'formatName' in G2frame.imageDefault: del G2frame.imageDefault['formatName'] 765 767 if LastSavedUsing: 766 768 print('GPX load successful. Last saved with GSAS-II revision '+LastSavedUsing) -
trunk/GSASIIfpaGUI.py
r4594 r4892 20 20 import os.path 21 21 import numpy as np 22 import copy 22 23 23 24 import wx … … 38 39 ''' 39 40 40 parmDict = { 'numWave':2}41 parmDict = {} 41 42 '''Parameter dict used for reading Topas-style values. These are 42 43 converted to SI units and placed into :data:`NISTparms` … … 60 61 ('sample_thickness', 1., 'Depth of sample (mm)'), 61 62 ('convolution_steps', 8, 'Number of Fourier-space bins per two-theta step'), 62 (' tube-tails_width', 0.04,'Tube filament width, in projection at takeoff angle (mm)'),63 ('source_width', 0.04,'Tube filament width, in projection at takeoff angle (mm)'), 63 64 ('tube-tails_L-tail', -1.,'Left-side tube tails width, in projection (mm)'), 64 65 ('tube-tails_R-tail', 1.,'Right-side tube tails width, in projection (mm)'), … … 112 113 parmDict['int'] = {i:v for i,v in enumerate((0.653817, 0.346183))} 113 114 parmDict['lwidth'] = {i:v for i,v in enumerate((0.501844,0.626579))} 114 SetCu2Wave() # use these as default 115 115 116 def SetCu5Wave(): 117 '''Set the parameters to the five-line (4 for incident beam mono) 118 Cu K alpha spectrum 119 ''' 120 parmDict['wave'] = {i:v for i,v in enumerate((1.534753,1.540596,1.541058,1.54441,1.544721))} 121 parmDict['int'] = {i:v for i,v in enumerate((0.0159, 0.5791, 0.0762, 0.2417, 0.0871))} 122 parmDict['lwidth'] = {i:v for i,v in enumerate((3.6854, 0.437, 0.6, 0.52, 0.62))} 123 124 def SetMonoWave(): 125 '''Eliminates the short-wavelength line from the five-line Cu K 126 alpha spectrum when incident beam mono; resets it to 5 if no mono 127 ''' 128 if IBmono and len(parmDict['wave']) == 5: 129 for key in 'wave','int','lwidth': 130 if 0 in parmDict[key]: del parmDict[key][0] 131 if (not IBmono) and len(parmDict['wave']) == 4: 132 SetCu5Wave() 133 134 #SetCu2Wave() # use these as default 135 SetCu5Wave() # use these as default 136 SetMonoWave() 116 137 117 138 def FillParmSizer(): … … 122 143 prmSizer = prmPnl.GetSizer() 123 144 prmSizer.Clear(True) 145 if IBmono: 146 itemList = [i for i in BraggBrentanoParms if not i[0].startswith('tube-tails')] 147 else: 148 itemList = copy.deepcopy(BraggBrentanoParms) 124 149 if DetMode == 'BBpoint': 125 itemList = BraggBrentanoParms+BBPointDetector150 itemList += BBPointDetector 126 151 elif DetMode == 'BBPSD': 127 itemList = BraggBrentanoParms+BBPSDDetector152 itemList += BBPSDDetector 128 153 else: 129 154 raise Exception('Unknown DetMode in FillParmSizer: '+DetMode) 130 155 if IBmono: 131 156 itemList += IBmonoParms 132 157 text = wx.StaticText(prmPnl,wx.ID_ANY,'label',style=wx.ALIGN_CENTER, 133 158 size=(170,-1)) # make just a bit bigger than largest item in column … … 172 197 FPdlg.Destroy() 173 198 def _onAddWave(event): 174 parmDict['numWave'] += 1 199 newkey = max(parmDict['wave'].keys())+1 200 for key,defVal in zip( 201 ('wave','int','lwidth'), 202 (0.0, 1.0, 0.1), 203 ): 204 parmDict[key][newkey] = defVal 175 205 wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus) 176 206 def _onRemWave(event): 177 parmDict['numWave'] -= 1 207 lastkey = max(parmDict['wave'].keys()) 208 for key in ('wave','int','lwidth'): 209 if lastkey in parmDict[key]: 210 del parmDict[key][lastkey] 178 211 wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus) 179 212 def _onSetCu5Wave(event): 180 parmDict['wave'] = {i:v for i,v in enumerate((1.534753,1.540596,1.541058,1.54441,1.544721))} 181 parmDict['int'] = {i:v for i,v in enumerate((0.0159, 0.5791, 0.0762, 0.2417, 0.0871))} 182 parmDict['lwidth'] = {i:v for i,v in enumerate((3.6854, 0.437, 0.6, 0.52, 0.62))} 183 parmDict['numWave'] = 5 213 SetCu5Wave() 214 SetMonoWave() 184 215 wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus) 185 216 def _onSetCu2Wave(event): 186 217 SetCu2Wave() 187 parmDict['numWave'] = 2188 218 wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus) 189 219 def _onSetDetBtn(event): … … 198 228 global IBmono 199 229 IBmono = not monoBtn1.GetValue() 200 wx.CallAfter(FillParmSizer) 230 SetMonoWave() 231 #wx.CallAfter(FillParmSizer) 232 wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus) 201 233 def PlotTopasFPA(event): 202 234 XferFPAsettings(parmDict) … … 236 268 237 269 if FPdlg.GetSizer(): FPdlg.GetSizer().Clear(True) 238 numWave = parmDict['numWave']239 270 MainSizer = wx.BoxSizer(wx.VERTICAL) 240 271 MainSizer.Add((-1,5)) 241 waveSizer = wx.FlexGridSizer(cols= numWave+1,hgap=3,vgap=5)272 waveSizer = wx.FlexGridSizer(cols=len(parmDict['wave'])+1,hgap=3,vgap=5) 242 273 for lbl,prm,defVal in zip( 243 274 (u'Wavelength (\u212b)','Rel. Intensity',u'Lorentz Width\n(\u212b/1000)'), … … 249 280 waveSizer.Add(text,0,wx.EXPAND) 250 281 if prm not in parmDict: parmDict[prm] = {} 251 for i in range(numWave):282 for i in parmDict['wave'].keys(): 252 283 if i not in parmDict[prm]: parmDict[prm][i] = defVal 253 284 ctrl = G2G.ValidatedTxtCtrl(FPdlg,parmDict[prm],i,size=(90,-1)) … … 334 365 px,py = prmSizer.GetSize() 335 366 dx,dy = FPdlg.GetSize() 336 FPdlg.SetMinSize((dx,dy+200)) # leave a min of 200 points for scroll panel 367 FPdlg.SetMinSize((dx,dy+200)) # leave a min of 200 points for scroll panel 368 FPdlg.SetMaxSize((max(dx,700),850)) 337 369 FPdlg.SetSize((max(dx,px+20),min(750,dy+py+30))) # 20 for scroll bar, 30 for a bit of room at bottom 338 370 … … 345 377 :returns: a nested dict with global parameters and those for each convolution 346 378 ''' 347 wavenums = range(InpParms['numWave']) 348 source_wavelengths_m = 1.e-10 * np.array([InpParms['wave'][i] for i in wavenums]) 349 la = [InpParms['int'][i] for i in wavenums] 379 # cleanup old stuff 380 for key in "tube_tails","absorption","si_psd","displacement","receiver_slit": 381 if key in NISTparms: 382 del NISTparms[key] 383 384 keys = list(InpParms['wave'].keys()) 385 source_wavelengths_m = 1.e-10 * np.array([InpParms['wave'][i] for i in keys]) 386 la = [InpParms['int'][i] for i in keys] 350 387 source_intensities = np.array(la)/max(la) 351 source_lor_widths_m = 1.e-10 * 1.e-3 * np.array([InpParms['lwidth'][i] for i in wavenums])352 source_gauss_widths_m = 1.e-10 * 1.e-3 * np.array([0.001 for i in wavenums])388 source_lor_widths_m = 1.e-10 * 1.e-3 * np.array([InpParms['lwidth'][i] for i in keys]) 389 source_gauss_widths_m = 1.e-10 * 1.e-3 * np.array([0.001 for i in keys]) 353 390 354 391 NISTparms["emission"] = {'emiss_wavelengths' : source_wavelengths_m, … … 364 401 for i in ('passband_mistune','passband_shoulder','two_theta_mono'): 365 402 NISTparms["emission"][i] = InpParms[i] 403 elif InpParms.get('source_width', 0) > 0 and InpParms.get( 404 'tube-tails_rel-I',0) > 0: 405 NISTparms["tube_tails"] = { 406 'main_width' : 1e-3 * InpParms.get('source_width', 0.), 407 'tail_left' : -1e-3 * InpParms.get('tube-tails_L-tail',0.), 408 'tail_right' : 1e-3 * InpParms.get('tube-tails_R-tail',0.), 409 'tail_intens' : InpParms.get('tube-tails_rel-I',0.),} 366 410 367 411 if InpParms['filament_length'] == InpParms['receiving_slit_length']: # workaround: … … 380 424 'sample_thickness': 1e-3 * InpParms['sample_thickness'], 381 425 } 382 elif "absorption" in NISTparms:383 del NISTparms["absorption"]384 426 385 427 if InpParms.get('lpsd_equitorial_divergence',0) > 0 and InpParms.get( 386 'lpsd_th2_angular_range',0) > 0 :428 'lpsd_th2_angular_range',0) > 0 and DetMode == 'BBPSD': 387 429 PSDdetector_length_mm=np.arcsin(np.pi*InpParms['lpsd_th2_angular_range']/180. 388 430 )*InpParms['Rs'] # mm … … 391 433 'si_psd_window_bounds': (0.,PSDdetector_length_mm/1000.) 392 434 } 393 elif "si_psd" in NISTparms: 394 del NISTparms["si_psd"] 395 435 396 436 if InpParms.get('Specimen_Displacement'): 397 437 NISTparms["displacement"] = {'specimen_displacement': 1e-3 * InpParms['Specimen_Displacement']} 398 elif "displacement" in NISTparms:399 del NISTparms["displacement"]400 438 401 439 if InpParms.get('receiving_slit_width'): 402 440 NISTparms["receiver_slit"] = {'slit_width':1e-3*InpParms['receiving_slit_width']} 403 elif "receiver_slit" in NISTparms:404 del NISTparms["receiver_slit"]405 406 if InpParms.get('tube-tails_width', 0) > 0 and InpParms.get(407 'tube-tails_rel-I',0) > 0:408 NISTparms["tube_tails"] = {409 'main_width' : 1e-3 * InpParms.get('tube-tails_width', 0.),410 'tail_left' : -1e-3 * InpParms.get('tube-tails_L-tail',0.),411 'tail_right' : 1e-3 * InpParms.get('tube-tails_R-tail',0.),412 'tail_intens' : InpParms.get('tube-tails_rel-I',0.),}413 elif "tube_tails" in NISTparms:414 del NISTparms["tube_tails"]415 441 416 442 # set Global parameters … … 422 448 'oversampling' : InpParms['convolution_steps'], 423 449 } 450 424 451 def setupFPAcalc(): 425 452 '''Create a peak profile object using the NIST XRD Fundamental … … 707 734 ('maxTT',123.,'Location of last peak in 2theta (deg)'), 708 735 ('step',0.01,'Pattern step size (deg 2theta)'), 709 ('npeaks',13 .,'Number of peaks'),736 ('npeaks',13,'Number of peaks'), 710 737 ('calcwid',2.,'Range to compute each peak (deg 2theta)'), 711 738 ):
Note: See TracChangeset
for help on using the changeset viewer.