Changeset 2808
- Timestamp:
- Apr 25, 2017 2:01:51 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIpwd.py ¶
r2802 r2808 1986 1986 line = ' ' 1987 1987 line2 = ' Scattering density: Real %.5g'%(Substances[name]['Scatt density']*parmDict[cid+'DenMul']) 1988 line2 += ' Imag %.5g'%(Substances[name].get('XImag density',0.)* *parmDict[cid+'DenMul'])1988 line2 += ' Imag %.5g'%(Substances[name].get('XImag density',0.)*parmDict[cid+'DenMul']) 1989 1989 for parm in ['Thick','Rough','DenMul','Mag SLD','iDenMul']: 1990 1990 if parm in layer: … … 2170 2170 sigma[ilay] = max(0.001,layer['Rough'][0]) 2171 2171 if name != 'vacuum': 2172 rho[ilay] = Substances[name]['Scatt density']*layer['DenMul'][0] 2172 if name == 'unit scatter': 2173 rho[ilay] = np.sqrt(layer['DenMul'][0]**2+layer['iDenMul'][0]**2) 2174 else: 2175 rrho = Substances[name]['Scatt density'] 2176 irho = Substances[name]['XImag density'] 2177 rho[ilay] = np.sqrt(rrho**2+irho**2)*layer['DenMul'][0] 2173 2178 if 'Mag SLD' in layer: 2174 2179 rho[ilay] += layer['Mag SLD'][0] -
TabularUnified trunk/GSASIIpwdGUI.py ¶
r2802 r2808 227 227 return {'Layers':[{'Name':'vacuum','DenMul':[1.0,False],}, #top layer 228 228 {'Name':'vacuum','Rough':[0.,False],'Penetration':[0.,False],'DenMul':[1.0,False],}], #bottom layer 229 'Scale':[1.0,False],'FltBack':[0.0,False],'Zero':'Top','dQ type':'None', 229 'Scale':[1.0,False],'FltBack':[0.0,False],'Zero':'Top','dQ type':'None','Layer Seq':[], #globals 230 230 'Minimizer':'LMLS','Resolution':[0.,'Const dq/q'],'Recomb':0.5,'Toler':0.5, #minimizer controls 231 231 'DualFitFiles':['',],'DualFltBacks':[[0.0,False],],'DualScales':[[1.0,False],]} #optional stuff for multidat fits? … … 4972 4972 def OndQSel(event): 4973 4973 data['dQ type'] = dQSel.GetStringSelection() 4974 Recalculate() 4975 4976 def NewRes(invalid,value,tc): 4977 Recalculate() 4978 4979 def Recalculate(): 4980 G2pwd.REFDModelFxn(Profile,Inst,Limits,Substances,data) 4981 x,xr,y = G2pwd.makeSLDprofile(data,Substances) 4982 ModelPlot(data,x,xr,y) 4983 G2plt.PlotPatterns(G2frame,plotType='REFD') 4974 4984 4975 4985 controlSizer = wx.BoxSizer(wx.VERTICAL) … … 4984 4994 resol.Add(dQSel,0,WACV) 4985 4995 resol.Add(wx.StaticText(G2frame.dataDisplay,label=' (FWHM %): '),0,WACV) 4986 resol.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Resolution'],0,nDig=(10,3),min=0.,max=5. ),0,WACV)4996 resol.Add(G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['Resolution'],0,nDig=(10,3),min=0.,max=5.,OnLeave=NewRes),0,WACV) 4987 4997 controlSizer.Add(resol,0,WACV) 4988 4998 minimiz = wx.BoxSizer(wx.HORIZONTAL) … … 5102 5112 ModelPlot(data,x,xr,y) 5103 5113 G2plt.PlotPatterns(G2frame,plotType='REFD') 5104 wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data)5114 # wx.CallLater(100,UpdateREFDModelsGrid,G2frame,data) 5105 5115 5106 5116 Indx = {} -
TabularUnified trunk/GSASIIstrMath.py ¶
r2797 r2808 3733 3733 if np.any(pVals): 3734 3734 dpdv = penaltyDeriv(pNames,pVals,HistoPhases,calcControls,parmDict,varylist) 3735 Vec += np.sum(dpdv*pWt*pVals,axis=1)3735 Vec -= np.sum(dpdv*pWt*pVals,axis=1) 3736 3736 Hess += np.inner(dpdv*pWt,dpdv) 3737 3737 return Vec,Hess -
TabularUnified trunk/imports/G2rfd_xye.py ¶
r2784 r2808 22 22 GSASIIpath.SetVersionNumber("$Revision: 2738 $") 23 23 npasind = lambda x: 180.*np.arcsin(x)/np.pi 24 npsind = lambda x: np.sin(np.pi*x/180.) 25 fourpi = 4.0*np.pi 24 26 25 27 class txt_XRayReaderClass(G2IO.ImportReflectometryData): … … 92 94 y.append(float(data[1])) 93 95 w.append(1.0/(0.02*float(data[1]))**2) 96 sq.append(0.) 94 97 except ValueError: 95 98 msg = 'Error in line '+str(i+1) … … 191 194 y.append(float(data[1])) 192 195 w.append(1.0/(0.02*float(data[1]))**2) 196 sq.append(0.) 193 197 except ValueError: 194 198 msg = 'Error in line '+str(i+1) … … 221 225 return True 222 226 227 class txt_XRayThetaReaderClass(G2IO.ImportReflectometryData): 228 'Routines to import X-ray theta REFD data from a .xtrfd or .xtdat file' 229 def __init__(self): 230 super(self.__class__,self).__init__( # fancy way to self-reference 231 extensionlist=('.xtrfd','.xtdat'), 232 strictExtension=False, 233 formatName = 'theta step X-ray QRE data', 234 longFormatName = 'theta stepped X-ray text data file in Q,R,E order; E optional' 235 ) 236 237 # Validate the contents -- make sure we only have valid lines 238 def ContentsValidator(self, filepointer): 239 'Look through the file for expected types of lines in a valid q-step file' 240 Ndata = 0 241 self.wavelength = 0. 242 for i,S in enumerate(filepointer): 243 if '#' in S[0]: 244 if 'wavelength' in S[:-1].lower(): 245 self.wavelength = float(S[:-1].split('=')[1]) 246 elif 'energy' in S[:-1].lower(): 247 self.wavelength = 12.39842*1000./float(S[:-1].split('=')[1]) 248 continue 249 vals = S.split() 250 if len(vals) >= 2: 251 try: 252 data = [float(val) for val in vals] 253 Ndata += 1 254 except ValueError: 255 pass 256 if not Ndata: 257 self.errors = 'No 2 or more column numeric data found' 258 return False 259 elif not self.wavelength: 260 self.errors = 'Missing wavelength or energy in header' 261 return False 262 return True # no errors encountered 263 264 def Reader(self,filename,filepointer, ParentFrame=None, **unused): 265 print 'Read a q-step text file' 266 x = [] 267 y = [] 268 w = [] 269 sq = [] 270 wave = self.wavelength 271 Temperature = 300 272 for i,S in enumerate(filepointer): 273 if len(S) == 1: #skip blank line 274 continue 275 if '=' in S: 276 self.comments.append(S[:-1]) 277 if 'wave' in S.split('=')[0].lower(): 278 try: 279 wave = float(S.split('=')[1]) 280 except: 281 pass 282 continue 283 if '#' in S[0]: 284 continue 285 vals = S.split() 286 if len(vals) >= 2: 287 try: 288 data = [float(val) for val in vals] 289 x.append(fourpi*npsind(float(data[0]))/wave) 290 f = float(data[1]) 291 if f <= 0.0: 292 del x[-1] 293 continue 294 elif len(vals) > 2: 295 y.append(float(data[1])) 296 w.append(1.0/float(data[2])**2) 297 if len(vals) == 4: 298 sq.append(float(data[3])) 299 else: 300 sq.append(0.) 301 else: 302 y.append(float(data[1])) 303 w.append(1.0/(0.02*float(data[1]))**2) 304 sq.append(0.) 305 except ValueError: 306 msg = 'Error in line '+str(i+1) 307 print msg 308 continue 309 N = len(x) 310 for S in self.comments: 311 if 'Temp' in S.split('=')[0]: 312 try: 313 Temperature = float(S.split('=')[1]) 314 except: 315 pass 316 self.instdict['wave'] = wave 317 self.instdict['type'] = 'RXC' 318 x = np.array(x) 319 self.reflectometrydata = [ 320 x, # x-axis values q 321 np.array(y), # small angle pattern intensities 322 np.array(w), # 1/sig(intensity)^2 values (weights) 323 np.zeros(N), # calc. intensities (zero) 324 np.zeros(N), # obs-calc profiles 325 np.array(sq), # fix bkg 326 ] 327 self.reflectometryentry[0] = filename 328 self.reflectometryentry[2] = 1 # xye file only has one bank 329 self.idstring = ospath.basename(filename) 330 # scan comments for temperature 331 self.Sample['Temperature'] = Temperature 332 333 return True 334
Note: See TracChangeset
for help on using the changeset viewer.