Changeset 3069


Ignore:
Timestamp:
Sep 12, 2017 1:09:18 PM (4 years ago)
Author:
odonnell
Message:

phase and histogram access works without G2obj

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r3067 r3069  
    903903        if histname in self.data:
    904904            return G2PwdrData(self.data[histname], self)
    905         for key, val in G2obj.HistIdLookup.items():
    906             name, ranId = val
    907             # histname can be either ranId (key) or index (val)
    908             if ranId == histname or key == str(histname):
    909                 return self.histogram(name)
     905        try:
     906            # see if histname is an id or ranId
     907            histname = int(histname)
     908        except ValueError:
     909            return
     910
     911        for histogram in self.histograms():
     912            if histogram.id == histname or histogram.ranId == histname:
     913                return histogram
    910914
    911915    def histograms(self):
     
    941945        if phasename in phases:
    942946            return G2Phase(phases[phasename], phasename, self)
    943         for key, val in G2obj.PhaseIdLookup.items():
    944             name, ranId = val
    945             # phasename can be either ranId (key) or index (val)
    946             if ranId == phasename or key == str(phasename):
    947                 return self.phase(name)
     947
     948        try:
     949            # phasename should be phase index or ranId
     950            phasename = int(phasename)
     951        except ValueError:
     952            return
     953
     954        for phase in self.phases():
     955            if phase.id == phasename or phase.ranId == phasename:
     956                return phase
    948957
    949958    def phases(self):
     
    10711080        else:
    10721081            phases = [self.phase(name) for name in phase]
    1073 
    10741082
    10751083        # TODO: HAP parameters:
Note: See TracChangeset for help on using the changeset viewer.