Changeset 686
- Timestamp:
- Jul 11, 2012 4:01:20 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r683 r686 2039 2039 Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree() 2040 2040 print Histograms.keys() 2041 Natoms,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases, Print=False)2041 Natoms,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable = G2str.GetPhaseData(Phases,RestDict=None,Print=False) 2042 2042 hapVary,hapDict,controlDict = G2str.GetHistogramPhaseData(Phases,Histograms,Print=False) 2043 2043 histVary,histDict,controlDict = G2str.GetHistogramData(Histograms,Print=False) -
trunk/GSASIIstruct.py
r679 r686 128 128 if not Histograms: 129 129 return 'Error: no diffraction data','' 130 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases, Print=False)130 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,RestDict=None,Print=False) 131 131 hapVary,hapDict,controlDict = GetHistogramPhaseData(Phases,Histograms,Print=False) 132 132 histVary,histDict,controlDict = GetHistogramData(Histograms,Print=False) … … 134 134 constrDict,fixedList = GetConstraints(GPXfile) 135 135 return G2mv.CheckConstraints(varyList,constrDict,fixedList) 136 137 def GetRestraints(GPXfile): 138 '''Read the restraints from the GPX file 139 ''' 140 fl = open(GPXfile,'rb') 141 while True: 142 try: 143 data = cPickle.load(fl) 144 except EOFError: 145 break 146 datum = data[0] 147 if datum[0] == 'Restraints': 148 restDict = datum[1] 149 fl.close() 150 return restDict 136 151 137 152 def GetPhaseNames(GPXfile): … … 560 575 ################################################################################ 561 576 562 def GetPhaseData(PhaseData, Print=True):577 def GetPhaseData(PhaseData,RestDict=None,Print=True): 563 578 564 579 def PrintFFtable(FFtable): … … 633 648 ptstr += '%12.4f'%(SHcoeff[item]) 634 649 print ptlbls 635 print ptstr 650 print ptstr 651 652 def PrintRestraints(phaseRest): 653 if phaseRest: 654 print '\n Restraints:' 655 names = ['Bonds','Angles','Planes','Volumes'] 656 for i,name in enumerate(['Bond','Angle','Plane','Chiral']): 657 itemRest = phaseRest[name] 658 if itemRest[names[i]]: 659 print '\n %30s %10.3f'%(name+' restraint weight factor',itemRest['wtFactor']) 660 print ' atoms(symOp), calc, obs, sig: ' 661 for item in phaseRest[name][names[i]]: 662 text = ' ' 663 for a,at in enumerate(item[0]): 664 text += at+'+('+item[1][a]+') ' 665 if (a+1)%5 == 0: 666 text += '\n ' 667 print text,' %.3f %.3f %.3f'%(item[3],item[4],item[5]) 636 668 637 669 if Print: print ' Phases:' … … 741 773 '%.3f'%(cell[6]),' volume =','%.3f'%(cell[7]),' Refine?',cell[0] 742 774 PrintTexture(textureData) 775 if name in RestDict: 776 PrintRestraints(RestDict[name]) 743 777 744 778 elif PawleyRef: … … 2915 2949 parmdict.update(zip(varylist,values)) 2916 2950 G2mv.Dict2Map(parmdict,varylist) 2917 Histograms,Phases = HistoPhases2951 Histograms,Phases,restDict = HistoPhases 2918 2952 nvar = len(varylist) 2919 2953 dMdv = np.empty(0) … … 2980 3014 parmdict.update(zip(varylist,values)) 2981 3015 G2mv.Dict2Map(parmdict,varylist) 2982 Histograms,Phases = HistoPhases3016 Histograms,Phases,restDict = HistoPhases 2983 3017 nvar = len(varylist) 2984 3018 Hess = np.empty(0) … … 3066 3100 Values2Dict(parmdict, varylist, values) 3067 3101 G2mv.Dict2Map(parmdict,varylist) 3068 Histograms,Phases = HistoPhases3102 Histograms,Phases,restDict = HistoPhases 3069 3103 M = np.empty(0) 3070 3104 SumwYo = 0 … … 3184 3218 calcControls.update(Controls) 3185 3219 constrDict,fixedList = GetConstraints(GPXfile) 3220 restDict = GetRestraints(GPXfile) 3186 3221 Histograms,Phases = GetUsedHistogramsAndPhases(GPXfile) 3187 3222 if not Phases: … … 3193 3228 print ' *** Refine aborted ***' 3194 3229 raise Exception 3195 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases )3230 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restDict) 3196 3231 calcControls['Natoms'] = Natoms 3197 3232 calcControls['FFtables'] = FFtables … … 3237 3272 result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True, 3238 3273 ftol=Ftol,col_deriv=True,factor=Factor, 3239 args=([Histograms,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3274 args=([Histograms,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3240 3275 ncyc = int(result[2]['nfev']/2) 3241 3276 elif 'Hessian' in Controls['deriv type']: 3242 3277 result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc, 3243 args=([Histograms,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3278 args=([Histograms,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3244 3279 ncyc = result[2]['num cyc']+1 3245 3280 Rvals['lamMax'] = result[2]['lamMax'] 3246 3281 else: #'numeric' 3247 3282 result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor, 3248 args=([Histograms,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3283 args=([Histograms,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3249 3284 ncyc = int(result[2]['nfev']/len(varyList)) 3250 3285 # table = dict(zip(varyList,zip(values,result[0],(result[0]-values)))) … … 3336 3371 ShowControls(Controls) 3337 3372 constrDict,fixedList = GetConstraints(GPXfile) 3373 restDict = GetRestraints(GPXfile) 3338 3374 Histograms,Phases = GetUsedHistogramsAndPhases(GPXfile) 3339 3375 if not Phases: … … 3345 3381 print ' *** Refine aborted ***' 3346 3382 raise Exception 3347 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases, False)3383 Natoms,phaseVary,phaseDict,pawleyLookup,FFtables,BLtables = GetPhaseData(Phases,restDict,False) 3348 3384 if 'Seq Data' in Controls: 3349 3385 histNames = Controls['Seq Data'] … … 3423 3459 result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True, 3424 3460 ftol=Ftol,col_deriv=True,factor=Factor, 3425 args=([Histo,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3461 args=([Histo,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3426 3462 ncyc = int(result[2]['nfev']/2) 3427 3463 elif 'Hessian' in Controls['deriv type']: 3428 3464 result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc, 3429 args=([Histo,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3465 args=([Histo,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3430 3466 ncyc = result[2]['num cyc']+1 3431 3467 else: #'numeric' 3432 3468 result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor, 3433 args=([Histo,Phases ],parmDict,varyList,calcControls,pawleyLookup,dlg))3469 args=([Histo,Phases,restDict],parmDict,varyList,calcControls,pawleyLookup,dlg)) 3434 3470 ncyc = int(result[2]['nfev']/len(varyList)) 3435 3471
Note: See TracChangeset
for help on using the changeset viewer.