Ignore:
Timestamp:
Aug 16, 2017 10:00:23 AM (4 years ago)
Author:
odonnell
Message:

more documentation changes, removed (phase|histogram)_names, add occupancy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r3007 r3009  
    1616Supports a command line interface as well.
    1717
    18 
    1918Look at :class:`G2Project` to start.
     19
     20=====================
     21Refinement parameters
     22=====================
     23
     24There are three classes of refinement parameters:
     25
     26    * Histogram. Turned on and off through :func:`~G2PwdrData.set_refinements`
     27      and :func:`~G2PwdrData.clear_refinements`
     28    * Phase. Turned on and off through :func:`~G2Phase.set_refinements`
     29      and :func:`~G2Phase.clear_refinements`
     30    * Histogram-and-phase (HAP). Turned on and off through
     31      :func:`~G2Phase.set_HAP_refinements` and :func:`~G2Phase.clear_HAP_refinements`
    2032"""
    2133from __future__ import division, print_function # needed?
     
    134146
    135147    :param dict Project: representation of gpx file following the GSAS-II
    136       tree structure as described for LoadDictFromProjFile
     148        tree structure as described for LoadDictFromProjFile
    137149    :param list nameList: names of main tree entries & subentries used to reconstruct project file
    138150    :param str ProjFile: full file name for output project.gpx file (including extension)
     
    159171
    160172    :returns list rdlist: list of reader objects containing powder data, one for each
    161       "Bank" of data encountered in file. Items in reader object of interest are:
    162 
    163         * rd.comments: list of str: comments found on powder file
    164         * rd.dnames: list of str: data nammes suitable for use in GSASII data tree NB: duplicated in all rd entries in rdlist
    165         * rd.powderdata: list of numpy arrays: pos,int,wt,zeros,zeros,zeros as needed for a PWDR entry in  GSASII data tree.
     173        "Bank" of data encountered in file. Items in reader object of interest are:
     174
     175          * rd.comments: list of str: comments found on powder file
     176          * rd.dnames: list of str: data nammes suitable for use in GSASII data tree NB: duplicated in all rd entries in rdlist
     177          * rd.powderdata: list of numpy arrays: pos,int,wt,zeros,zeros,zeros as needed for a PWDR entry in  GSASII data tree.
    166178    '''
    167179    rdfile,rdpath,descr = imp.find_module(reader)
     
    194206    '''Create an initial Histogram dictionary
    195207
    196     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     208    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    197209    '''
    198210    if dType in ['SXC','SNC']:
     
    222234
    223235    from GSASIIphsGUI.py, near end of UpdatePhaseData
    224     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     236
     237    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    225238    '''
    226239    if 'RBModels' not in data:
     
    241254
    242255    From GSASIIphsGui.py, function of the same name. Minor changes for imports etc.
    243     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     256
     257    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    244258    """
    245259    mapDefault = {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True,
     
    371385
    372386    Returns: project dictionary, name list
    373     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     387
     388    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    374389    """
    375390    if not filename:
     
    512527    """Loads powder data from a reader object, and assembles it into a GSASII data tree.
    513528
    514     Returns: (name, tree) - 2-tuple of the histogram name (str), and data
    515     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     529    :returns: (name, tree) - 2-tuple of the histogram name (str), and data
     530
     531    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    516532    """
    517533    HistName = 'PWDR ' + G2obj.StripUnicode(reader.idstring, '_')
     
    580596def _deep_copy_into(from_, into):
    581597    """Helper function for reloading .gpx file. See G2Project.reload()
    582     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     598
     599    :author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    583600    """
    584601    if isinstance(from_, dict) and isinstance(into, dict):
     
    619636    of overrides are implemented so that the wrapper behaves like a dictionary.
    620637
    621     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     638    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    622639    """
    623640    def __init__(self, datadict):
     
    652669
    653670        :param str gpxfile: Existing .gpx file to be loaded. If nonexistent,
    654         creates an empty project.
     671            creates an empty project.
    655672        :param str author: Author's name. Optional.
    656673        :param str filename: The filename the project should be saved to in
    657         the future. If both filename and gpxfile are present, the project is
    658         loaded from the gpxfile, then set to  save to filename in the future"""
     674            the future. If both filename and gpxfile are present, the project is
     675            loaded from the gpxfile, then set to  save to filename in the future"""
    659676        if gpxfile is None:
    660677            filename = os.path.abspath(os.path.expanduser(filename))
     
    712729
    713730        :returns: A :class:`G2PwdrData` object representing
    714         the histogram
     731            the histogram
    715732        """
    716733        LoadG2fil()
     
    737754        :param str phasename: The name of the new phase, or None for the default
    738755        :param list histograms: The names of the histograms to associate with
    739         this phase
     756            this phase
    740757
    741758        :returns: A :class:`G2Phase` object representing the
    742         new phase.
     759            new phase.
    743760        """
    744761        LoadG2fil()
     
    829846        self.reload()
    830847
    831     def histogram_names(self):
    832         """Gives a list of the names of each histogram in the project.
    833 
    834         :returns: list of strings
    835 
    836         .. seealso::
    837             :func:`~GSASIIscriptable.G2Project.histogram`
    838             :func:`~GSASIIscriptable.G2Project.histograms`
    839             :func:`~GSASIIscriptable.G2Project.phase`
    840             :func:`~GSASIIscriptable.G2Project.phases`
    841             :func:`~GSASIIscriptable.G2Project.phase_names`
    842             """
    843         output = []
    844         for obj in self.names:
    845             if len(obj) > 1 and obj[0] != u'Phases':
    846                 output.append(obj[0])
    847         return output
    848 
    849848    def histogram(self, histname):
    850849        """Returns the histogram named histname, or None if it does not exist.
     
    852851        :param histname: The name of the histogram (str), or ranId or index.
    853852        :returns: A :class:`G2PwdrData` object, or None if
    854         the histogram does not exist
     853            the histogram does not exist
    855854
    856855        .. seealso::
     
    861860        if histname in self.data:
    862861            return G2PwdrData(self.data[histname], self)
    863         histRanId = None
    864862        for key, val in G2obj.HistIdLookup.items():
    865863            name, ranId = val
     
    883881        return output
    884882
    885     def phase_names(self):
    886         """Gives an list of the names of each phase in the project.
    887 
    888         :returns: A list of strings
    889 
    890         .. seealso::
    891             :func:`~GSASIIscriptable.G2Project.histogram`
    892             :func:`~GSASIIscriptable.G2Project.histograms`
    893             :func:`~GSASIIscriptable.G2Project.phase`
    894             :func:`~GSASIIscriptable.G2Project.phases`
    895             """
    896         for obj in self.names:
    897             if obj[0] == 'Phases':
    898                 return obj[1:]
    899         return []
    900 
    901883    def phase(self, phasename):
    902884        """
    903885        Gives an object representing the specified phase in this project.
    904886
    905         :param str phasename: The name of the desired phase
     887        :param str phasename: The name of the desired phase. Either the name
     888            (str), the phase's ranId, or the phase's index
    906889        :returns: A :class:`G2Phase` object
    907890        :raises: KeyError
     
    915898        if phasename in phases:
    916899            return G2Phase(phases[phasename], phasename, self)
    917         phaseRanId = None
    918900        for key, val in G2obj.PhaseIdLookup.items():
    919901            name, ranId = val
     
    926908        Returns a list of all the phases in the project.
    927909
    928         :returns: A :class:`G2Phase`
     910        :returns: A list of :class:`G2Phase` objects
    929911
    930912        .. seealso::
     
    944926        :param list refinements: A list of dictionaries defining refinements
    945927        :param str histogram: Name of histogram for refinements to be applied
    946         to, or 'all'
     928            to, or 'all'
    947929        :param str phase: Name of phase for refinements to be applied to, or
    948         'all'
     930            'all'
    949931        """
    950932        if outputnames:
     
    985967        :param dict refinement: The refinements to be conducted
    986968        :param histogram: Either a name of a histogram (str), a list of
    987         histogram names, or 'all' (default)
     969            histogram names, or 'all' (default)
    988970        :param phase: Either a name of a phase (str), a list of phase names, or
    989         'all' (default)
     971            'all' (default)
    990972
    991973        .. seealso::
     
    10821064        type is passed directly to add_constraint_raw as consType
    10831065
    1084         :param list vars: A list of variables to hold. Either G2obj.G2VarObj objects,
    1085         string variable specifiers, or arguments for :meth:`make_var_obj`
     1066        :param list vars: A list of variables to hold. Either :class:`GSASIIobj.G2VarObj` objects,
     1067            string variable specifiers, or arguments for :meth:`make_var_obj`
    10861068        :param str type: A string constraint type specifier. See
    10871069        :class:`~GSASIIscriptable.G2Project.add_constraint_raw`"""
     
    11401122class G2AtomRecord(G2ObjectWrapper):
    11411123    """Wrapper for an atom record. Has convenient accessors via @property.
     1124
     1125
     1126    Available accessors: label, type, refinement_flags, coordinates,
     1127        occupancy, ranId, id, adp_flag, uiso
    11421128
    11431129    Example:
     
    11541140    >>> atom.ranId
    11551141    4615973324315876477
     1142    >>> atom.occupancy
     1143    1.0
    11561144    """
    11571145    def __init__(self, data, indices, proj):
     
    11831171    def coordinates(self):
    11841172        return tuple(self.data[self.cx:self.cx+3])
     1173
     1174    @property
     1175    def occupancy(self):
     1176        return self.data[self.cx+3]
     1177
     1178    @occupancy.setter
     1179    def occupancy(self, val):
     1180        self.data[self.cx+3] = float(val)
    11851181
    11861182    @property
     
    14241420class G2Phase(G2ObjectWrapper):
    14251421    """A wrapper object around a given phase.
    1426     Author: Jackson O'Donnell jacksonhodonnell@gmail.com
     1422
     1423    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
    14271424    """
    14281425    def __init__(self, data, name, proj):
     
    14481445        :param str atomlabel: The name of the atom (e.g. "O2")
    14491446        :returns: A :class:`G2AtomRecord` object
    1450         representing the atom.
     1447            representing the atom.
    14511448        """
    14521449        # Consult GSASIIobj.py for the meaning of this
     
    14611458        """Returns a list of atoms present in the phase.
    14621459
    1463         :returns: A list of :class:`G2AtomRecord` objects. See
    1464         also :func:`~GSASIIscriptable.G2Phase.atom`
     1460        :returns: A list of :class:`G2AtomRecord` objects.
     1461
     1462        .. seealso::
     1463            :func:`~GSASIIscriptable.G2Phase.atom`
     1464            :class:`G2AtomRecord`
    14651465        """
    14661466        ptrs = self.data['General']['AtomPtrs']
     
    15521552        :param dict refs: A dictionary of the parameters to be set.
    15531553        :param histograms: Either 'all' (default) or a list of the histograms
    1554         whose HAP parameters will be set with this phase. Histogram and phase
    1555         must already be associated
     1554            whose HAP parameters will be set with this phase. Histogram and phase
     1555            must already be associated
    15561556
    15571557        :returns: None
     
    16281628        :param dict refs: A dictionary of the parameters to be cleared.
    16291629        :param histograms: Either 'all' (default) or a list of the histograms
    1630         whose HAP parameters will be cleared with this phase. Histogram and
    1631         phase must already be associated
     1630            whose HAP parameters will be cleared with this phase. Histogram and
     1631            phase must already be associated
    16321632
    16331633        :returns: None
Note: See TracChangeset for help on using the changeset viewer.