Changeset 1141


Ignore:
Timestamp:
Nov 7, 2013 2:46:36 PM (8 years ago)
Author:
toby
Message:

minor tweaks: move indexing of Ids to histogram load, remove Type from HAP var list

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1138 r1141  
    7272import GSASIIstrIO as G2stIO
    7373import GSASIImapvars as G2mv
     74import GSASIIobj as G2obj
    7475
    7576#wx inspector - use as needed
     
    25372538                            print('For phase "'+str(phase)+
    25382539                                  '" unresolved reference to histogram "'+str(hist)+'"')
     2540        G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
    25392541        return Histograms,Phases
    25402542       
  • trunk/GSASIIconstrGUI.py

    r1138 r1141  
    204204    #reload(G2gd)
    205205    ###################################################
    206     Histograms,Phases = G2obj.IndexAllIds(G2frame)
     206    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
    207207    ##################################################################################
    208208    # patch: convert old-style (str) variables in constraints to G2VarObj objects
     
    216216                    j += 1
    217217        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'
    219219    ##################################################################################
    220220    rigidbodyDict = G2frame.PatternTree.GetItemPyData(
     
    252252           
    253253    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',)]
    255255    hapList.sort()
    256256    histVary,histDict,controlDict = G2stIO.GetHistogramData(Histograms,Print=False)
  • trunk/GSASIIobj.py

    r1138 r1141  
    438438diffraction data for that information are directly associated with
    439439that tree item and there are a series of children to that item. The
    440 routine :func:`~GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` will
     440routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`
     441and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will
    441442load this information into a dictionary where the child tree name is
    442443used as a key, and the information in the main entry is assigned
     
    592593diffraction data for that information are directly associated with
    593594that tree item and there are a series of children to that item. The
    594 routine :func:`~GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree` will
     595routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`
     596and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will
    595597load this information into a dictionary where the child tree name is
    596598used as a key, and the information in the main entry is assigned
     
    723725'''
    724726
    725 def IndexAllIds(G2frame=None,Histograms=None,Phases=None):
     727def IndexAllIds(Histograms,Phases):
    726728    '''Scan through the used phases & histograms and create an index
    727729    to the random numbers of phases, histograms and atoms. While doing this,
     
    732734    element each atom record.
    733735
     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
    734741    TODO: do we need a lookup for rigid body variables?
    735742    '''
    736     if G2frame:
    737         Histograms,phaseDict = G2frame.GetUsedHistogramsAndPhasesfromTree()
    738     else:
    739         Histograms,phaseDict = Histograms,Phases
    740743    # process phases and atoms
    741744    PhaseIdLookup.clear()
     
    744747    AtomRanIdLookup.clear()
    745748    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']
    749752        while ranId in PhaseRanIdLookup:
    750753            # 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)
    755758        PhaseRanIdLookup[ranId] = pId
    756         shortname = Phase[:10]
     759        shortname = ph[:10]
    757760        while shortname in ShortPhaseNames.values():
    758             shortname = Phase[:8] + ' ('+ pId + ')'
     761            shortname = ph[:8] + ' ('+ pId + ')'
    759762        ShortPhaseNames[pId] = shortname
    760763        AtomIdLookup[pId] = {}
    761764        AtomRanIdLookup[pId] = {}
    762         for iatm,at in enumerate(phaseDict[Phase]['Atoms']):
     765        for iatm,at in enumerate(Phases[ph]['Atoms']):
    763766            ranId = at[-1]
    764767            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")
    766769                at[-1] = ranId = ran.randint(0,sys.maxint)
    767770            AtomRanIdLookup[pId][ranId] = str(iatm)
    768             if phaseDict[Phase]['General']['Type'] == 'macromolecular':
     771            if Phases[ph]['General']['Type'] == 'macromolecular':
    769772                label = '%s_%s_%s_%s'%(at[ct-1],at[ct-3],at[ct-4],at[ct-2])
    770773            else:
     
    788791            shortname = hist[:11] + ' ('+ hId + ')'
    789792        ShortHistNames[hId] = shortname
    790 
    791     return Histograms,phaseDict
    792793
    793794def LookupAtomId(pId,ranId):
  • trunk/GSASIIstrIO.py

    r1138 r1141  
    6464def GetConstraints(GPXfile):
    6565    '''Read the constraints from the GPX file and interpret them
     66
     67    called in :func:`CheckConstraints`, :func:`GSASIIstrMain.Refine`
     68    and :func:`GSASIIstrMain.SeqRefine`.
    6669    '''
    6770    constList = []
     
    177180    if not Histograms:
    178181        return 'Error: no diffraction data',''
    179     G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
    180182    rigidbodyDict = GetRigidBodies(GPXfile)
    181183    rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
     
    395397                        print('For phase "'+str(phase)+
    396398                              '" unresolved reference to histogram "'+str(hist)+'"')
     399    G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
    397400    return Histograms,Phases
    398401   
  • trunk/GSASIIstrMain.py

    r1139 r1141  
    5959    calcControls = {}
    6060    calcControls.update(Controls)           
    61     constrDict,fixedList = G2stIO.GetConstraints(GPXfile) # better to pass in Histograms,Phases
     61    constrDict,fixedList = G2stIO.GetConstraints(GPXfile)
    6262    restraintDict = G2stIO.GetRestraints(GPXfile)
    6363    Histograms,Phases = G2stIO.GetUsedHistogramsAndPhases(GPXfile)
    64     G2obj.IndexAllIds(Histograms=Histograms,Phases=Phases)
    6564    if not Phases:
    6665        print ' *** ERROR - you have no phases! ***'
Note: See TracChangeset for help on using the changeset viewer.