Ignore:
Timestamp:
Dec 9, 2019 2:30:49 PM (23 months ago)
Author:
toby
Message:

doc improvements; new scripting options (rev. sequential & set background file)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r4187 r4198  
    486486\                     type                  The background model, e.g. 'chebyschev'
    487487\                     refine                The value of the refine flag, boolean
    488 \                     no. coeffs            Number of coefficients to use, integer
     488\                     'no. coeffs'          Number of coefficients to use, integer
    489489\                     coeffs                List of floats, literal values for background
    490490\                     FixedPoints           List of (2-theta, intensity) values for fixed points
    491 \                     fit fixed points      If True, triggers a fit to the fixed points to
     491\                     'fit fixed points'    If True, triggers a fit to the fixed points to
    492492                                            be calculated. It is calculated when this key is
    493493                                            detected, regardless of calls to refine.
    494                       peaks                 Specifies a set of flags for refining
     494\                     peaks                 Specifies a set of flags for refining
    495495                                            background peaks as a nested list. There may
    496496                                            be an item for each defined background peak
     
    18141814
    18151815class G2Project(G2ObjectWrapper):   
    1816     """Represents an entire GSAS-II project.
     1816    """Represents an entire GSAS-II project. The object contains these
     1817    class variables:
     1818
     1819     * G2Project.filename: contains the .gpx filename
     1820     * G2Project.names: contains the contents of the project "tree" as a list
     1821       of lists. Each top-level entry in the tree is an item in the list. The
     1822       name of the top-level item is the first item in the inner list. Children
     1823       of that item, if any, are subsequent entries in that list.
     1824     * G2Project.data: contains the entire project as a dict. The keys
     1825       for the dict are the top-level names in the project tree (initial items
     1826       in the G2Project.names inner lists) and each top-level item is stored
     1827       as a dict.
     1828
     1829         * The contents of Top-level entries will be found in the item
     1830           named 'data', as an example, ``G2Project.data['Notebook']['data']``
     1831
     1832         * The contents of child entries will be found in the item
     1833           using the names of the parent and child, for example
     1834           ``G2Project.data['Phases']['NaCl']``
    18171835
    18181836    :param str gpxfile: Existing .gpx file to be loaded. If nonexistent,
     
    30213039            * cycles: the maximum number of cycles (returns int)
    30223040            * sequential: the histograms used for a sequential refinement as a list
    3023               of histogram names or an empty list when in non-sequential mode.
     3041              of histogram names or an empty list when in non-sequential mode.
     3042            * Reverse Seq: returns True or False. True indicates that fitting of the
     3043              sequence of histograms proceeds in reversed order.
    30243044            * seqCopy: returns True or False. True indicates that results from
    30253045              each sequential fit are used as the starting point for the next
     
    30353055        elif control == 'sequential':
    30363056            return self.data['Controls']['data']['Seq Data']
     3057        elif control == 'Reverse Seq':
     3058            return self.data['Controls']['data']['Reverse Seq']
    30373059        elif control in self.data['Controls']['data']:
    30383060            return self.data['Controls']['data'][control]
     
    30593081              the starting point for the next. After each fit is is set to False.
    30603082              Ignored for non-sequential fits.
     3083            * Reverse Seq: when True, sequential refinement is performed on the
     3084              reversed list of histograms.
    30613085
    30623086        .. seealso::
     
    30673091        elif control == 'seqCopy':
    30683092            self.data['Controls']['data']['Copy2Next'] = bool(value)
     3093        elif control == 'Reverse Seq':
     3094            self.data['Controls']['data']['Reverse Seq'] = bool(value)
    30693095        elif control == 'sequential':
    30703096            histlist = []
     
    32913317
    32923318class G2PwdrData(G2ObjectWrapper):
    3293     """Wraps a Powder Data Histogram."""
     3319    """Wraps a Powder Data Histogram.
     3320    The object contains these class variables:
     3321
     3322        * G2PwdrData.proj: contains a reference to the :class:`G2Project`
     3323          object that contains this histogram
     3324        * G2PwdrData.name: contains the name of the histogram
     3325        * G2PwdrData.data: contains the histogram's associated data in a dict,
     3326          as documented for the :ref:`Powder Diffraction Tree<Powder_table>`.
     3327          The actual histogram values are contained in the 'data' dict item,
     3328          as documented for Data.
     3329
     3330    """
    32943331    def __init__(self, data, proj, name):
    32953332        self.data = data
     
    35873624        return self['data'][0].get('wR')
    35883625
     3626    def _decodeHist(self,hist):
     3627        '''Convert a histogram reference to a histogram name string
     3628        '''
     3629        if isinstance(hist, G2PwdrData):
     3630            return hist.name
     3631        elif hist in [h.name for h in self.proj.histograms()]:
     3632            return hist
     3633        elif type(hist) is int:
     3634            return self.proj.histograms()[hist].name
     3635        else:
     3636            raise G2ScriptException("Invalid histogram reference: "+str(hist))
     3637       
     3638    def set_background(self, key, value):
     3639        '''Set background parameters (this serves a similar function as in
     3640        :meth:`set_refinements`, but with a simplified interface).
     3641
     3642        :param str key: a string that defines the background parameter that will
     3643           be changed. Must appear in the table below.
     3644
     3645           =================   ==============   ===========================================
     3646           key name            type of value     meaning of value
     3647           =================   ==============   ===========================================
     3648           fixedHist           int, str,         reference to a histogram in the current
     3649                               None or           project or None to remove the reference.
     3650                               G2PwdrData       
     3651           fixedFileMult       float             multiplier applied to intensities in
     3652                                                 the background histogram where a value
     3653                                                 of -1.0 means full subtraction of
     3654                                                 the background histogram.
     3655           =================   ==============   ===========================================
     3656
     3657        :param value: a value to set the selected background parameter. The meaning
     3658           and type for this parameter is listed in the table above.
     3659
     3660        '''
     3661        bkgPrms, bkgDict = self.data['Background']
     3662        if key == 'fixedHist':
     3663            if value is None:
     3664                bkgDict['background PWDR'][0] = ''
     3665                return
     3666            bkgDict['background PWDR'][0] = self._decodeHist(value)
     3667        elif key == 'fixedFileMult':
     3668            bkgDict['background PWDR'][1] = float(value)
     3669        else:
     3670            raise ValueError("Invalid key in set_background:", key)
     3671       
    35893672    def set_refinements(self, refs):
    35903673        """Sets the histogram refinement parameter 'key' to the specification 'value'.
     
    39184001class G2Phase(G2ObjectWrapper):
    39194002    """A wrapper object around a given phase.
     4003    The object contains these class variables:
     4004
     4005        * G2Phase.proj: contains a reference to the :class:`G2Project`
     4006          object that contains this phase
     4007        * G2Phase.name: contains the name of the phase
     4008        * G2Phase.data: contains the phases's associated data in a dict,
     4009          as documented for the :ref:`Phase Tree items<Phase_table>`.
    39204010
    39214011    Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com)
     
    50245114    calls to :meth:`G2Project.add_image` or :meth:`G2Project.images`.
    50255115    Scripts will not use ``G2Image()`` to call :meth:`G2Image.__init__` directly.
     5116    The object contains these class variables:
     5117
     5118        * G2Image.proj: contains a reference to the :class:`G2Project`
     5119          object that contains this image
     5120        * G2Image.name: contains the name of the image
     5121        * G2Image.data: contains the image's associated data in a dict,
     5122          as documented for the :ref:`Image Data Structure<Image_table>`.
    50265123
    50275124    Example use of G2Image:
Note: See TracChangeset for help on using the changeset viewer.