Changeset 1141
- Timestamp:
- Nov 7, 2013 2:46:36 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1138 r1141 72 72 import GSASIIstrIO as G2stIO 73 73 import GSASIImapvars as G2mv 74 import GSASIIobj as G2obj 74 75 75 76 #wx inspector - use as needed … … 2537 2538 print('For phase "'+str(phase)+ 2538 2539 '" unresolved reference to histogram "'+str(hist)+'"') 2540 G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases) 2539 2541 return Histograms,Phases 2540 2542 -
trunk/GSASIIconstrGUI.py
r1138 r1141 204 204 #reload(G2gd) 205 205 ################################################### 206 Histograms,Phases = G2 obj.IndexAllIds(G2frame)206 Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree() 207 207 ################################################################################## 208 208 # patch: convert old-style (str) variables in constraints to G2VarObj objects … … 216 216 j += 1 217 217 if j: 218 print str(key) + ': '+str(j)+' variable(s) strings converted to objects'218 print str(key) + ': '+str(j)+' variable(s) as strings converted to objects' 219 219 ################################################################################## 220 220 rigidbodyDict = G2frame.PatternTree.GetItemPyData( … … 252 252 253 253 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,Print=False) 254 hapList = hapDict.keys()254 hapList = [i for i in hapDict.keys() if i.split(':')[2] not in ('Type',)] 255 255 hapList.sort() 256 256 histVary,histDict,controlDict = G2stIO.GetHistogramData(Histograms,Print=False) -
trunk/GSASIIobj.py
r1138 r1141 438 438 diffraction data for that information are directly associated with 439 439 that tree item and there are a series of children to that item. The 440 routine :func:`~GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` will 440 routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` 441 and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will 441 442 load this information into a dictionary where the child tree name is 442 443 used as a key, and the information in the main entry is assigned … … 592 593 diffraction data for that information are directly associated with 593 594 that tree item and there are a series of children to that item. The 594 routine :func:`~GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` will 595 routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` 596 and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will 595 597 load this information into a dictionary where the child tree name is 596 598 used as a key, and the information in the main entry is assigned … … 723 725 ''' 724 726 725 def IndexAllIds( G2frame=None,Histograms=None,Phases=None):727 def IndexAllIds(Histograms,Phases): 726 728 '''Scan through the used phases & histograms and create an index 727 729 to the random numbers of phases, histograms and atoms. While doing this, … … 732 734 element each atom record. 733 735 736 This is called in two places (only) :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` 737 (which loads the histograms and phases from a GPX file) and 738 :meth:`GSASII.GSASII.GetUsedHistogramsAndPhases` 739 (which loads the histograms and phases from the data tree.) 740 734 741 TODO: do we need a lookup for rigid body variables? 735 742 ''' 736 if G2frame:737 Histograms,phaseDict = G2frame.GetUsedHistogramsAndPhasesfromTree()738 else:739 Histograms,phaseDict = Histograms,Phases740 743 # process phases and atoms 741 744 PhaseIdLookup.clear() … … 744 747 AtomRanIdLookup.clear() 745 748 ShortPhaseNames.clear() 746 for Phase in phaseDict:747 cx,ct,cs,cia = phaseDict[Phase]['General']['AtomPtrs']748 ranId = phaseDict[Phase]['ranId']749 for ph in Phases: 750 cx,ct,cs,cia = Phases[ph]['General']['AtomPtrs'] 751 ranId = Phases[ph]['ranId'] 749 752 while ranId in PhaseRanIdLookup: 750 753 # Found duplicate random Id! note and reassign 751 print ("\n\n*** Phase "+str( Phase)+" has repeated ranId. Fixing.\n")752 phaseDict[Phase]['ranId'] = ranId = ran.randint(0,sys.maxint)753 pId = str( phaseDict[Phase]['pId'])754 PhaseIdLookup[pId] = ( Phase,ranId)754 print ("\n\n*** Phase "+str(ph)+" has repeated ranId. Fixing.\n") 755 Phases[ph]['ranId'] = ranId = ran.randint(0,sys.maxint) 756 pId = str(Phases[ph]['pId']) 757 PhaseIdLookup[pId] = (ph,ranId) 755 758 PhaseRanIdLookup[ranId] = pId 756 shortname = Phase[:10]759 shortname = ph[:10] 757 760 while shortname in ShortPhaseNames.values(): 758 shortname = Phase[:8] + ' ('+ pId + ')'761 shortname = ph[:8] + ' ('+ pId + ')' 759 762 ShortPhaseNames[pId] = shortname 760 763 AtomIdLookup[pId] = {} 761 764 AtomRanIdLookup[pId] = {} 762 for iatm,at in enumerate( phaseDict[Phase]['Atoms']):765 for iatm,at in enumerate(Phases[ph]['Atoms']): 763 766 ranId = at[-1] 764 767 while ranId in AtomRanIdLookup[pId]: # check for dups 765 print ("\n\n*** Phase "+str( Phase)+" atom "+str(iatm)+" has repeated ranId. Fixing.\n")768 print ("\n\n*** Phase "+str(ph)+" atom "+str(iatm)+" has repeated ranId. Fixing.\n") 766 769 at[-1] = ranId = ran.randint(0,sys.maxint) 767 770 AtomRanIdLookup[pId][ranId] = str(iatm) 768 if phaseDict[Phase]['General']['Type'] == 'macromolecular':771 if Phases[ph]['General']['Type'] == 'macromolecular': 769 772 label = '%s_%s_%s_%s'%(at[ct-1],at[ct-3],at[ct-4],at[ct-2]) 770 773 else: … … 788 791 shortname = hist[:11] + ' ('+ hId + ')' 789 792 ShortHistNames[hId] = shortname 790 791 return Histograms,phaseDict792 793 793 794 def LookupAtomId(pId,ranId): -
trunk/GSASIIstrIO.py
r1138 r1141 64 64 def GetConstraints(GPXfile): 65 65 '''Read the constraints from the GPX file and interpret them 66 67 called in :func:`CheckConstraints`, :func:`GSASIIstrMain.Refine` 68 and :func:`GSASIIstrMain.SeqRefine`. 66 69 ''' 67 70 constList = [] … … 177 180 if not Histograms: 178 181 return 'Error: no diffraction data','' 179 G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)180 182 rigidbodyDict = GetRigidBodies(GPXfile) 181 183 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) … … 395 397 print('For phase "'+str(phase)+ 396 398 '" unresolved reference to histogram "'+str(hist)+'"') 399 G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases) 397 400 return Histograms,Phases 398 401 -
trunk/GSASIIstrMain.py
r1139 r1141 59 59 calcControls = {} 60 60 calcControls.update(Controls) 61 constrDict,fixedList = G2stIO.GetConstraints(GPXfile) # better to pass in Histograms,Phases61 constrDict,fixedList = G2stIO.GetConstraints(GPXfile) 62 62 restraintDict = G2stIO.GetRestraints(GPXfile) 63 63 Histograms,Phases = G2stIO.GetUsedHistogramsAndPhases(GPXfile) 64 G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)65 64 if not Phases: 66 65 print ' *** ERROR - you have no phases! ***'
Note: See TracChangeset
for help on using the changeset viewer.