- Timestamp:
- Feb 26, 2021 4:49:53 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Absorb.py
r4672 r4830 463 463 464 464 if self.Volume: 465 Text += "%s %s%10. 2f%s" % ("Total",' '+Gkmu+'=',self.Pack*muT/self.Volume,'cm'+Pwrm1+', ')466 Text += "%s%10. 2f%s" % ('Total '+Gkmu+'R=',self.Radius*self.Pack*muT/(10.0*self.Volume),', ')465 Text += "%s %s%10.4g %s" % ("Total",' '+Gkmu+'=',self.Pack*muT/self.Volume,'cm'+Pwrm1+', ') 466 Text += "%s%10.4g%s" % ('Total '+Gkmu+'R=',self.Radius*self.Pack*muT/(10.0*self.Volume),', ') 467 467 Text += "%s%10.4f%s\n" % ('Transmission exp(-2'+Gkmu+'R)=', \ 468 468 100.0*math.exp(-2*self.Radius*self.Pack*muT/(10.0*self.Volume)),'%') -
trunk/GSASIIimage.py
r4820 r4830 1262 1262 return useMask 1263 1263 1264 def MakeGainMap(image,Ix,Iy ,data,blkSize=128):1264 def MakeGainMap(image,Ix,Iy0,data,blkSize=128): 1265 1265 import scipy.ndimage.filters as sdif 1266 Iy = sdif.gaussian_filter1d(Iy0,3.) 1266 1267 Iy *= npcosd(Ix[:-1])**3 #undo parallax 1267 1268 Iy *= (1000./data['distance'])**2 #undo r^2 effect … … 1270 1271 Iy *= G2pwd.Oblique(data['Oblique'][0],Ix[:-1]) #undo penetration 1271 1272 IyInt = scint.interp1d(Ix[:-1],Iy[0],bounds_error=False) 1273 muT = data.get('SampleAbs',[0.0,''])[0] 1272 1274 GainMap = np.zeros_like(image,dtype=float) 1273 1275 #do interpolation on all points - fills in the empty bins; leaves others the same … … 1282 1284 jFin = min(jBeg+blkSize,Nx) 1283 1285 TA = Make2ThetaAzimuthMap(data,(iBeg,iFin),(jBeg,jFin)) #2-theta & azimuth arrays & create position mask 1286 tabs = np.ones_like(TA[3]) 1287 if data.get('SampleAbs',[0.0,False])[1]: 1288 if 'Cylind' in data['SampleShape']: 1289 if 'horiz' in data['orientation']: 1290 muR = muT*(1.+0.5*npsind(TA[0])*npsind(TA[1])**2) #adjust for additional thickness off sample normal 1291 else: #vertical 1292 muR = muT*(1.+0.5*npsind(TA[0])*npcosd(TA[1])**2) 1293 tabs = G2pwd.Absorb(data['SampleShape'],muR,TA[1]) 1294 elif 'Fixed' in data['SampleShape']: #assumes flat plate sample normal to beam 1295 tabs = G2pwd.Absorb('Fixed',muT,TA[1]) 1284 1296 Ipix = IyInt(TA[0]) 1285 GainMap[iBeg:iFin,jBeg:jFin] = image[iBeg:iFin,jBeg:jFin]/( Ipix*TA[3])1297 GainMap[iBeg:iFin,jBeg:jFin] = image[iBeg:iFin,jBeg:jFin]/(tabs*Ipix*TA[3]) 1286 1298 GainMap = np.nan_to_num(GainMap,1.0) 1287 1299 GainMap = sdif.gaussian_filter(GainMap,3.,order=0) … … 1350 1362 tax = np.where(tax > LRazm[1],tax-360.,tax) #put azm inside limits if possible 1351 1363 tax = np.where(tax < LRazm[0],tax+360.,tax) 1352 if data.get('SampleAbs',[0.0, ''])[1]:1364 if data.get('SampleAbs',[0.0,False])[1]: 1353 1365 if 'Cylind' in data['SampleShape']: 1354 muR = muT*(1.+npsind(tax)**2/2.)/(npcosd(tay)) #adjust for additional thickness off sample normal 1366 if 'horiz' in data['orientation']: 1367 muR = muT*(1.+0.5*npsind(tax)*npsind(tay)**2) #adjust for additional thickness off sample normal 1368 else: #vertical 1369 muR = muT*(1.+0.5*npsind(tax)*npcosd(tay)**2) 1355 1370 tabs = G2pwd.Absorb(data['SampleShape'],muR,tay) 1356 1371 elif 'Fixed' in data['SampleShape']: #assumes flat plate sample normal to beam -
trunk/GSASIIimgGUI.py
r4820 r4830 157 157 158 158 def OnMakeGainMap(event): 159 import scipy.ndimage.filters as sdif 159 160 sumImg = GetImageZ(G2frame,data) 160 161 masks = copy.deepcopy(G2frame.GPXtree.GetItemPyData( … … 166 167 Data['LRazimuth'] = [0.,360.] 167 168 Data['outChannels'] = 5000 168 Data['SampleAbs'] = [0.0,False]169 169 Data['binType'] = '2-theta' 170 170 Data['color'] = 'gray' … … 182 182 Data['formatName'] = 'GSAS-II image' 183 183 Data['range'] = [(500,2000),[800,1200]] 184 GainMap = np.where(GainMap > 1200,1200,GainMap) 185 GainMap = np.where(GainMap < 800,800,GainMap) 184 GainMap = np.where(GainMap > 2000,2000,GainMap) 185 GainMap = np.where(GainMap < 500,500,GainMap) 186 masks['Thresholds'] = [(500.,2000.),[800.,1200.]] 186 187 G2IO.PutG2Image(newimagefile,[],data,Npix,GainMap) 187 188 GMname = 'IMG '+os.path.split(newimagefile)[1] … … 284 285 if 'det2theta' not in data: 285 286 data['det2theta'] = 0.0 287 if 'orientation' not in data: 288 data['orientation'] = 'horizontal' 286 289 #end patch 287 290 … … 646 649 'tilt','rotation','azmthOff','fullIntegrate','LRazimuth','setdist', 647 650 'IOtth','outChannels','outAzimuths','invert_x','invert_y','DetDepth', 648 'calibskip','pixLimit','cutoff','calibdmin','Flat Bkg','varyList', 651 'calibskip','pixLimit','cutoff','calibdmin','Flat Bkg','varyList','orientation', 649 652 'binType','SampleShape','PolaVal','SampleAbs','dark image','background image'] 650 653 keyList.sort(key=lambda s: s.lower()) … … 1186 1189 def OnSamAbs(event): 1187 1190 data['SampleAbs'][1] = not data['SampleAbs'][1] 1191 wx.CallLater(100,UpdateImageControls,G2frame,data,masks) 1188 1192 1189 1193 def OnShowLines(event): … … 1219 1223 def OnIfPink(event): 1220 1224 data['IfPink'] = not data['IfPink'] 1225 1226 def OnOchoice(event): 1227 data['orientation'] = ochoice.GetValue() 1221 1228 1222 1229 dataSizer = wx.FlexGridSizer(0,2,5,3) … … 1270 1277 outAzim = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'outAzimuths',nDig=(10,4),xmin=1,typeHint=int,OnLeave=OnNumOutAzms) 1271 1278 littleSizer.Add(outAzim,0,WACV) 1272 dataSizer.Add(littleSizer,0,) 1273 samplechoice = ['Cylinder','Fixed flat plate',] 1274 dataSizer.Add(wx.StaticText(G2frame.dataWindow,label='Select sample shape'),0,WACV) 1275 samShape = wx.ComboBox(G2frame.dataWindow,value=data['SampleShape'],choices=samplechoice, 1276 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1277 samShape.Bind(wx.EVT_COMBOBOX,OnSampleShape) 1278 dataSizer.Add(samShape,0,WACV) 1279 dataSizer.Add(littleSizer) 1280 showLines = wx.CheckBox(parent=G2frame.dataWindow,label='Show integration limits?') 1281 dataSizer.Add(showLines,0,WACV) 1282 showLines.Bind(wx.EVT_CHECKBOX, OnShowLines) 1283 showLines.SetValue(data['showLines']) 1284 fullIntegrate = wx.CheckBox(parent=G2frame.dataWindow,label='Do full integration?') 1285 dataSizer.Add(fullIntegrate,0,WACV) 1286 fullIntegrate.Bind(wx.EVT_CHECKBOX, OnFullIntegrate) 1287 fullIntegrate.SetValue(data['fullIntegrate']) 1288 setDefault = wx.CheckBox(parent=G2frame.dataWindow,label='Use for all new images?') 1289 dataSizer.Add(setDefault,0,WACV) 1290 setDefault.Bind(wx.EVT_CHECKBOX, OnSetDefault) 1291 setDefault.SetValue(data['setDefault']) 1292 centerAzm = wx.CheckBox(parent=G2frame.dataWindow,label='Azimuth at bin center?') 1293 dataSizer.Add(centerAzm,0,WACV) 1294 centerAzm.Bind(wx.EVT_CHECKBOX, OnCenterAzm) 1295 centerAzm.SetValue(data['centerAzm']) 1279 1296 #SampleShape - cylinder or flat plate choice? 1280 1297 littleSizer = wx.BoxSizer(wx.HORIZONTAL) … … 1284 1301 samabs.SetValue(data['SampleAbs'][1]) 1285 1302 minmax = [0.,2.] 1286 if 'Cylind' in data['SampleShape']: #cylinder mu*R; flat plate transmission 1287 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='mu*R (0.00-2.0) '),0,WACV) 1288 elif 'Fixed' in data['SampleShape']: 1289 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='transmission '),0,WACV) #for flat plate 1290 minmax = [.05,1.0] 1291 samabsVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data['SampleAbs'],0,nDig=(10,3), 1292 typeHint=float,xmin=minmax[0],xmax=minmax[1]) 1293 littleSizer.Add(samabsVal,0,WACV) 1294 dataSizer.Add(littleSizer,0,) 1303 if data['SampleAbs'][1]: 1304 samplechoice = ['Cylinder','Fixed flat plate',] 1305 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='Select shape '),0,WACV) 1306 samShape = wx.ComboBox(G2frame.dataWindow,value=data['SampleShape'],choices=samplechoice, 1307 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1308 samShape.Bind(wx.EVT_COMBOBOX,OnSampleShape) 1309 littleSizer.Add(samShape,0,WACV) 1310 dataSizer.Add(littleSizer) 1311 if data['SampleAbs'][1]: 1312 littleSizer = wx.BoxSizer(wx.HORIZONTAL) 1313 if 'Cylind' in data['SampleShape']: #cylinder mu*R; flat plate transmission 1314 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='mu*R (0.00-2.0) '),0,WACV) 1315 elif 'Fixed' in data['SampleShape']: 1316 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='transmission '),0,WACV) #for flat plate 1317 minmax = [.05,1.0] 1318 samabsVal = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data['SampleAbs'],0,nDig=(10,3), 1319 typeHint=float,xmin=minmax[0],xmax=minmax[1]) 1320 littleSizer.Add(samabsVal,0,WACV) 1321 dataSizer.Add(littleSizer,0,WACV) 1322 if 'Cylind' in data['SampleShape'] and data['SampleAbs'][1]: 1323 littleSizer = wx.BoxSizer(wx.HORIZONTAL) 1324 littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='Select orientation '),0,WACV) 1325 choice = ['horizontal','vertical'] 1326 ochoice = wx.ComboBox(G2frame.dataWindow,value=data['orientation'],choices=choice, 1327 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1328 ochoice.Bind(wx.EVT_COMBOBOX,OnOchoice) 1329 littleSizer.Add(ochoice,0,WACV) 1330 dataSizer.Add(littleSizer) 1331 if 'flat' in data['SampleShape'] and data['SampleAbs'][1]: 1332 dataSizer.Add((5,5),0) 1295 1333 if 'PWDR' in data['type']: 1296 1334 littleSizer = wx.BoxSizer(wx.HORIZONTAL) … … 1314 1352 dataSizer.Add(littleSizer,0,) 1315 1353 1316 showLines = wx.CheckBox(parent=G2frame.dataWindow,label='Show integration limits?')1317 dataSizer.Add(showLines,0,WACV)1318 showLines.Bind(wx.EVT_CHECKBOX, OnShowLines)1319 showLines.SetValue(data['showLines'])1320 fullIntegrate = wx.CheckBox(parent=G2frame.dataWindow,label='Do full integration?')1321 dataSizer.Add(fullIntegrate,0,WACV)1322 fullIntegrate.Bind(wx.EVT_CHECKBOX, OnFullIntegrate)1323 fullIntegrate.SetValue(data['fullIntegrate'])1324 setDefault = wx.CheckBox(parent=G2frame.dataWindow,label='Use for all new images?')1325 dataSizer.Add(setDefault,0,WACV)1326 setDefault.Bind(wx.EVT_CHECKBOX, OnSetDefault)1327 setDefault.SetValue(data['setDefault'])1328 centerAzm = wx.CheckBox(parent=G2frame.dataWindow,label='Azimuth at bin center?')1329 dataSizer.Add(centerAzm,0,WACV)1330 centerAzm.Bind(wx.EVT_CHECKBOX, OnCenterAzm)1331 centerAzm.SetValue(data['centerAzm'])1332 1354 return dataSizer 1333 1355 … … 1630 1652 mainSizer.Add((5,5),0) 1631 1653 mainSizer.Add(BackSizer(),0) 1632 mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Calibration controls:'),0 ,WACV)1654 mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Calibration controls:'),0) 1633 1655 mainSizer.Add((5,5),0) 1634 mainSizer.Add(CalibSizer(),0 ,WACV)1656 mainSizer.Add(CalibSizer(),0) 1635 1657 mainSizer.Add((5,5),0) 1636 mainSizer.Add(GonioSizer(),0 ,WACV)1658 mainSizer.Add(GonioSizer(),0) 1637 1659 G2frame.dataWindow.SetDataSize() 1638 1660 … … 2104 2126 delbtn.Bind(wx.EVT_BUTTON,OnDelBtn) 2105 2127 spotSizer.Add(delbtn,0,WACV) 2106 mainSizer.Add(spotSizer,0 ,WACV)2128 mainSizer.Add(spotSizer,0) 2107 2129 if len(Spots): 2108 2130 lbl = wx.StaticText(parent=G2frame.dataWindow,label=' Spot masks(on plot LB drag to move, shift-LB drag to resize, RB to delete)') -
trunk/GSASIImath.py
r4819 r4830 338 338 # complete current cycle 339 339 deltaChi2 = (chisq0-chisq1)/chisq0 340 if n-len(indices): 341 G2fil.G2Print( 342 'Cycle %d: %.2fs Chi2: %.5g; Obs: %d; Lam: %.3g Del: %.3g; drop=%d, SVD=%d'% 343 (icycle,time.time()-time0,chisq1,Nobs,lamMax,deltaChi2,n-len(indices),Nzeros)) 344 else: 345 G2fil.G2Print( 346 'Cycle %d: %.2fs, Chi**2: %.5g for %d obs., Lambda: %.3g, Delta: %.3g, SVD=%d'% 347 (icycle,time.time()-time0,chisq1,Nobs,lamMax,deltaChi2,Nzeros)) 340 if Print: 341 if n-len(indices): 342 G2fil.G2Print( 343 'Cycle %d: %.2fs Chi2: %.5g; Obs: %d; Lam: %.3g Del: %.3g; drop=%d, SVD=%d'% 344 (icycle,time.time()-time0,chisq1,Nobs,lamMax,deltaChi2,n-len(indices),Nzeros)) 345 else: 346 G2fil.G2Print( 347 'Cycle %d: %.2fs, Chi**2: %.5g for %d obs., Lambda: %.3g, Delta: %.3g, SVD=%d'% 348 (icycle,time.time()-time0,chisq1,Nobs,lamMax,deltaChi2,Nzeros)) 348 349 Histograms = args[0][0] 349 350 if refPlotUpdate is not None: refPlotUpdate(Histograms,icycle) # update plot 350 351 if deltaChi2 < ftol: 351 352 ifConverged = True 352 G2fil.G2Print("converged") 353 if Print: 354 G2fil.G2Print("converged") 353 355 break 354 356 icycle += 1 -
trunk/GSASIIpwd.py
r4821 r4830 68 68 npT2stl = lambda tth, wave: 2.0*npsind(tth/2.0)/wave #=d* 69 69 npT2q = lambda tth,wave: 2.0*np.pi*npT2stl(tth,wave) #=2pi*d* 70 npq2T = lambda Q,wave: 2.0*npasind(0.25*Q*wave/np.pi) 70 71 ateln2 = 8.0*math.log(2.0) 71 72 sateln2 = np.sqrt(ateln2) … … 248 249 C = 2.9978e8 249 250 D = 1.5e-3 250 hmc = 0.024262734687 251 hmc = 0.024262734687 #Compton wavelength in A 251 252 sinth2 = (Q*wave/(4.0*np.pi))**2 252 253 dlam = (wave**2)*Compton*Q/C 253 254 dlam_c = 2.0*hmc*sinth2-D*wave**2 254 255 return 1.0/((1.0+dlam/RulCoff)*(1.0+(np.pi*dlam_c/(dlam+RulCoff))**2)) 256 257 def KleinNishina(wave,Q): 258 hmc = 0.024262734687 #Compton wavelength in A 259 TTh = npq2T(Q,wave) 260 P = 1./(1.+(1.-npcosd(TTh)*(hmc/wave))) 261 KN = (P**3-(P*npsind(TTh))**2+P)/(1.+npcosd(TTh)**2) 262 return KN 255 263 256 264 def LorchWeight(Q): … … 383 391 # auxPlot.append([Q,np.copy(CF),'CF-unCorr']) 384 392 if 'XC' in inst['Type'][0]: 393 # CF *= KleinNishina(wave,Q) 385 394 ruland = Ruland(data['Ruland'],wave,Q,CF) 386 395 # auxPlot.append([Q,ruland,'Ruland']) -
trunk/imports/G2phase_CIF.py
r4659 r4830 598 598 isodistort_warnings += '\nRepeated atom labels prevents ISODISTORT decode' 599 599 for lbl in phasenamefields: # get a name for the phase 600 name = blk.get(lbl) 600 name = blk.get(lbl)[0] 601 601 if name is None: 602 602 continue
Note: See TracChangeset
for help on using the changeset viewer.