Changeset 1587 for trunk/GSASIIlattice.py
 Timestamp:
 Nov 27, 2014 9:34:45 AM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIlattice.py
r1585 r1587 418 418 def Pos2dsp(Inst,pos): 419 419 ''' convert powder pattern position (2theta or TOF, musec) to dspacing 420 ignores secondary effects (e.g. difB in TOF)421 420 ''' 422 421 if 'C' in Inst['Type'][0]: … … 424 423 return wave/(2.0*sind((posInst.get('Zero',[0,0])[1])/2.0)) 425 424 else: #'T'OF  ignore difB 426 # return TOF2dsp(Inst,pos) 427 T = posInst['Zero'][1] 428 T1 = Inst['difC'][1]**24.*Inst['difA'][1]*T 429 return 2.*T/(Inst['difC'][1]+np.sqrt(T1)) 425 return TOF2dsp(Inst,pos) 430 426 431 427 def TOF2dsp(Inst,Pos): 432 import scipy.optimize as so 433 434 def func(d,pos,Inst): 435 return posInst['difC'][1]*dInst['difA'][1]*d**2Inst['Zero'][1]Inst['difB'][1]/d 436 437 return [so.brentq(func,.01,100.,args=(pos,Inst)) for pos in Pos] 428 ''' convert powder pattern TOF, musec to dspacing by successive approximation 429 Pos can be numpy array 430 ''' 431 def func(d,pos,Inst): 432 return (posInst['difA'][1]*d**2Inst['Zero'][1]Inst['difB'][1]/d)/Inst['difC'][1] 433 dsp0 = np.ones_like(Pos) 434 while True: #successive approximations 435 dsp = func(dsp0,Pos,Inst) 436 if np.allclose(dsp,dsp0,atol=0.000001): 437 return dsp 438 dsp0 = dsp 438 439 439 440 def Dsp2pos(Inst,dsp): … … 456 457 return pos 457 458 458 459 459 def calc_rDsq(H,A): 460 460 'needs doc string'
Note: See TracChangeset
for help on using the changeset viewer.