source: trunk/sphinxdocs/build/html/_modules/GSASIIobj.html @ 947

Last change on this file since 947 was 947, checked in by toby, 10 years ago

update self-docs, start work on constraints object

  • Property svn:mime-type set to text/html
File size: 36.8 KB
Line 
1
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6
7<html xmlns="http://www.w3.org/1999/xhtml">
8  <head>
9    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10   
11    <title>GSASIIobj &mdash; GSAS-II 0.2.0 documentation</title>
12   
13    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
14    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
15   
16    <script type="text/javascript">
17      var DOCUMENTATION_OPTIONS = {
18        URL_ROOT:    '../',
19        VERSION:     '0.2.0',
20        COLLAPSE_INDEX: false,
21        FILE_SUFFIX: '.html',
22        HAS_SOURCE:  true
23      };
24    </script>
25    <script type="text/javascript" src="../_static/jquery.js"></script>
26    <script type="text/javascript" src="../_static/underscore.js"></script>
27    <script type="text/javascript" src="../_static/doctools.js"></script>
28    <link rel="top" title="GSAS-II 0.2.0 documentation" href="../index.html" />
29    <link rel="up" title="Module code" href="index.html" /> 
30  </head>
31  <body>
32    <div class="related">
33      <h3>Navigation</h3>
34      <ul>
35        <li class="right" style="margin-right: 10px">
36          <a href="../genindex.html" title="General Index"
37             accesskey="I">index</a></li>
38        <li class="right" >
39          <a href="../py-modindex.html" title="Python Module Index"
40             >modules</a> |</li>
41        <li><a href="../index.html">GSAS-II 0.2.0 documentation</a> &raquo;</li>
42          <li><a href="index.html" accesskey="U">Module code</a> &raquo;</li> 
43      </ul>
44    </div> 
45
46    <div class="document">
47      <div class="documentwrapper">
48        <div class="bodywrapper">
49          <div class="body">
50           
51  <h1>Source code for GSASIIobj</h1><div class="highlight"><pre>
52<span class="c"># TODO: change this to assemble the look-up tables of atoms, phases and hists from the tree</span>
53<span class="c"># and then save/unsave those values in __init__ &amp; __str__, etc. </span>
54
55<span class="sd">&#39;&#39;&#39;</span>
56<span class="sd">*GSASIIobj: Data objects*</span>
57<span class="sd">=========================</span>
58
59<span class="sd">This module defines and/or documents the data structures used in GSAS-II.</span>
60
61
62<span class="sd">Constraints Tree Item</span>
63<span class="sd">----------------------</span>
64
65<span class="sd">.. _Constraints_table:</span>
66
67<span class="sd">.. index::</span>
68<span class="sd">   single: Constraints object description</span>
69<span class="sd">   single: Data object descriptions; Constraints</span>
70
71<span class="sd">Constraints are stored in a dict, separated into groups.</span>
72<span class="sd">Note that parameter are named in the following pattern,</span>
73<span class="sd">p:h:&lt;var&gt;:n, where p is the phase number, h is the histogram number</span>
74<span class="sd">&lt;var&gt; is a variable name and n is the parameter number.</span>
75<span class="sd">If a parameter does not depend on a histogram or phase or is unnumbered, that</span>
76<span class="sd">number is omitted.</span>
77<span class="sd">Note that the contents of each dict item is a List where each element in the</span>
78<span class="sd">list is a :ref:`constraint definition objects &lt;Constraint_definitions_table&gt;`.</span>
79
80<span class="sd">The keys in the Constraints dict are:</span>
81
82<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
83
84<span class="sd">==========  ====================================================</span>
85<span class="sd">  key         explanation</span>
86<span class="sd">==========  ====================================================</span>
87<span class="sd">Hist        This specifies a list of constraints on </span>
88<span class="sd">            histogram-related parameters,</span>
89<span class="sd">            which will be of form :h:&lt;var&gt;:n.</span>
90<span class="sd">HAP         This specifies a list of constraints on parameters</span>
91<span class="sd">            that are defined for every histogram in each phase</span>
92<span class="sd">            and are of form p:h:&lt;var&gt;:n.            </span>
93<span class="sd">Phase       This specifies a list of constraints on phase</span>
94<span class="sd">            parameters,</span>
95<span class="sd">            which will be of form p::&lt;var&gt;:n.</span>
96<span class="sd">Global      This specifies a list of constraints on parameters</span>
97<span class="sd">            that are not tied to a histogram or phase and</span>
98<span class="sd">            are of form ::&lt;var&gt;:n</span>
99<span class="sd">==========  ====================================================</span>
100
101<span class="sd">.. _Constraint_definitions_table:</span>
102
103<span class="sd">.. index::</span>
104<span class="sd">   single: Constraint definition object description</span>
105<span class="sd">   single: Data object descriptions; Constraint Definition</span>
106
107<span class="sd">Each constraint is defined as a list using a series of terms of form</span>
108
109<span class="sd">::</span>
110
111<span class="sd">[[&lt;mult1&gt;, &lt;var1&gt;], [&lt;mult2&gt;, &lt;var2&gt;],..., &lt;fixed val&gt;, &lt;vary flag&gt;, &lt;cons type&gt;]</span>
112
113<span class="sd">Where the variable pair list item containing two values [&lt;mult&gt;, &lt;var&gt;], </span>
114
115<span class="sd">  * &lt;mult&gt; is a multiplier for the constraint (float)</span>
116<span class="sd">  * &lt;var&gt; is the name of the variable (str) (or to be implemented a :class:`VarName` object.)</span>
117
118<span class="sd">Note that the last three items in the list play a special role:</span>
119
120<span class="sd"> * &lt;fixed val&gt; is the fixed value for a constraint equation or is None</span>
121<span class="sd"> * &lt;vary flag&gt; is True, False or None and is intended to use to indicate if new variables</span>
122<span class="sd">   should be refined.</span>
123<span class="sd"> * &lt;cons type&gt; is one of four letters, &#39;e&#39;, &#39;c&#39;, &#39;h&#39;, &#39;f&#39; that determines the type of constraint.</span>
124
125<span class="sd">    * &#39;e&#39; defines a set of equivalent variables. Only the first variable is refined (if the</span>
126<span class="sd">      appropriate refine flag is set) and and all other equivalent variables in the list</span>
127<span class="sd">      are generated from that variable. The vary flag for those variables is ignored.</span>
128<span class="sd">    * &#39;c&#39; defines a constraint equation of form, :math:`m_1 \\times var_1 + m_2 \\times var_2 + ... = c`</span>
129<span class="sd">    * &#39;h&#39; defines a variable to hold (not vary). Any variable on this list is not varied, even if its refinement</span>
130<span class="sd">      flag is set. This is of particular value when needing to hold one or more variables in a set such as</span>
131<span class="sd">      the reciprocal metric tensor or anisotropic displacement parameter. </span>
132<span class="sd">    * &#39;f&#39; defines a relationship to define a new variable according to relationship </span>
133<span class="sd">      :math:`newvar = m_1 \\times var_1 + m_2 \\times var_2 + ...`</span>
134
135<span class="sd">Covariance Tree Item</span>
136<span class="sd">--------------------</span>
137
138<span class="sd">.. _Covariance_table:</span>
139
140<span class="sd">.. index::</span>
141<span class="sd">   single: Covariance description</span>
142<span class="sd">   single: Data object descriptions; Covariance</span>
143
144<span class="sd">The Covariance tree item has results from the last least-squares run. They</span>
145<span class="sd">are stored in a dict with these keys:</span>
146
147<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
148
149<span class="sd">=============  ===============  ====================================================</span>
150<span class="sd">  key            sub-key        explanation</span>
151<span class="sd">=============  ===============  ====================================================</span>
152<span class="sd">newCellDict    \                dict with lattice parameters computed by</span>
153<span class="sd">                                :func:`GSASIIstrMath.GetNewCellParms` (dict)</span>
154<span class="sd">title          \                Name of gpx file(?) (str)</span>
155<span class="sd">variables      \                Values for all N refined variables</span>
156<span class="sd">                                (list of float values, length N,</span>
157<span class="sd">                                ordered to match varyList)</span>
158<span class="sd">sig            \                Uncertainty values for all N refined variables</span>
159<span class="sd">                                (list of float values, length N,</span>
160<span class="sd">                                ordered to match varyList)</span>
161<span class="sd">varyList       \                List of directly refined variables </span>
162<span class="sd">                                (list of str values, length N)</span>
163<span class="sd">newAtomDict    \                dict with atom position values computed in </span>
164<span class="sd">                                :func:`GSASIIstrMath.ApplyXYZshifts` (dict)</span>
165<span class="sd">Rvals          \                R-factors, GOF, Marquardt value for last</span>
166<span class="sd">                                refinement cycle (dict)</span>
167<span class="sd">\              Nobs             Number of observed data points (int)</span>
168<span class="sd">\              Rwp              overall weighted profile R-factor (%, float)</span>
169<span class="sd">\              chisq            sum[w*(Iobs-Icalc)**2] for all data</span>
170<span class="sd">                                note this is not the reduced chi squared (float)</span>
171<span class="sd">\              lamMax           Marquardt value applied to Hessian diagonal</span>
172<span class="sd">                                (float)</span>
173<span class="sd">\              GOF              The goodness-of-fit, aka square root of</span>
174<span class="sd">                                the reduced chi squared. (float)</span>
175<span class="sd">covMatrix      \                The (NxN) covVariance matrix (np.array)</span>
176<span class="sd">=============  ===============  ====================================================</span>
177
178<span class="sd">Space Group Objects</span>
179<span class="sd">-------------------</span>
180
181<span class="sd">.. _SGData_table:</span>
182
183<span class="sd">.. index::</span>
184<span class="sd">   single: SGData description</span>
185<span class="sd">   single: Data object descriptions; SGData</span>
186
187<span class="sd">Space groups are interpreted by :func:`GSASIIspc:SpcGroup` </span>
188<span class="sd">and the information is placed in a SGdata object,</span>
189<span class="sd">which is a dict with these keys:</span>
190
191<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
192
193<span class="sd">==========  ====================================================</span>
194<span class="sd">  key         explanation</span>
195<span class="sd">==========  ====================================================</span>
196<span class="sd">SpGrp       space group symbol (str)</span>
197<span class="sd">Laue        one of the following 14 Laue classes:</span>
198<span class="sd">            -1, 2/m, mmm, 4/m, 4/mmm, 3R,</span>
199<span class="sd">            3mR, 3, 3m1, 31m, 6/m, 6/mmm, m3, m3m (str)</span>
200<span class="sd">SGInv       True if centrosymmetric, False if not (bool)</span>
201<span class="sd">SGLatt      Lattice centering type. Will be one of</span>
202<span class="sd">            P, A, B, C, I, F, R (str)</span>
203<span class="sd">SGUniq      unique axis if monoclinic. Will be</span>
204<span class="sd">            a, b, or c for monoclinic space groups.</span>
205<span class="sd">            Will be blank for non-monoclinic. (str)</span>
206<span class="sd">SGCen       Symmetry cell centering vectors. A (n,3) np.array</span>
207<span class="sd">            of centers. Will always have at least one row:</span>
208<span class="sd">            ``np.array([[0, 0, 0]])``</span>
209<span class="sd">SGOps       symmetry operations as a list in form</span>
210<span class="sd">            [[M1,T1],[M2,T2,...] where Mn is a 3x3 np.array</span>
211<span class="sd">            and T is a length 3 np.array.</span>
212<span class="sd">            Atom coordinates are transformed where the</span>
213<span class="sd">            Asymmetric unit coordinates [X=(x,y,z)] are</span>
214<span class="sd">            transformed using ``M*X+T ==&gt; X&#39;``</span>
215<span class="sd">SGSys       symmetry unit cell: type one of</span>
216<span class="sd">            &#39;triclinic&#39;, &#39;monoclinic&#39;, &#39;orthorhombic&#39;,</span>
217<span class="sd">            &#39;tetragonal&#39;, &#39;rhombohedral&#39;, &#39;trigonal&#39;,</span>
218<span class="sd">            &#39;hexagonal&#39;, &#39;cubic&#39; (str)</span>
219<span class="sd">SGPolax     Axes for space group polarity. Will be one of</span>
220<span class="sd">            &#39;&#39;, &#39;x&#39;, &#39;y&#39;, &#39;x y&#39;, &#39;z&#39;, &#39;x z&#39;, &#39;y z&#39;,</span>
221<span class="sd">            &#39;xyz&#39;. In the case where axes are arbitrary </span>
222<span class="sd">            &#39;111&#39; is used (P 1, and ?).</span>
223<span class="sd">==========  ====================================================</span>
224
225<span class="sd">&#39;&#39;&#39;</span>
226
227<div class="viewcode-block" id="LoadHistogramIDs"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LoadHistogramIDs">[docs]</a><span class="k">def</span> <span class="nf">LoadHistogramIDs</span><span class="p">(</span><span class="n">histList</span><span class="p">,</span><span class="n">idList</span><span class="p">):</span>
228    <span class="sd">&#39;&#39;&#39;Save the Id values for a series of histograms&#39;&#39;&#39;</span>
229    <span class="n">VarName</span><span class="o">.</span><span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;hists&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
230    <span class="k">for</span> <span class="n">h</span><span class="p">,</span><span class="n">i</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">histList</span><span class="p">,</span><span class="n">idList</span><span class="p">):</span>
231        <span class="n">VarName</span><span class="o">.</span><span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;hists&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">h</span>
232</div>
233<span class="k">def</span> <span class="nf">LoadPhaseIDs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
234    <span class="k">pass</span>
235
236<div class="viewcode-block" id="VarName"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.VarName">[docs]</a><span class="k">class</span> <span class="nc">VarName</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
237    <span class="sd">&#39;&#39;&#39;Defines a GSAS-II variable either using the phase/atom/histogram</span>
238<span class="sd">    unique Id numbers or using a character string that specifies</span>
239<span class="sd">    variables by phase/atom/histogram number (which can change).</span>
240<span class="sd">    Note that :func:`LoadID` should be used to (re)load the current Ids</span>
241<span class="sd">    before creating or later using the VarName object.</span>
242
243<span class="sd">    A :class:`VarName` object can be created with a single parameter:</span>
244<span class="sd">    </span>
245<span class="sd">    :param str varname: a single value can be used to create a :class:`VarName`</span>
246<span class="sd">      object. The string must be of form &quot;p:h:var&quot; or &quot;p:h:var:a&quot;, where</span>
247
248<span class="sd">     * p is the phase number (which may be left blank); </span>
249<span class="sd">     * h is the histogram number (which may be left blank); </span>
250<span class="sd">     * a is the atom number (which may be left blank in which case the third colon is omitted).</span>
251
252<span class="sd">    Alternately, a :class:`VarName` object can be created with exactly four positional parameters:</span>
253
254<span class="sd">    :param int phasenum: The number for the phase</span>
255<span class="sd">    :param int histnum: The number for the histogram</span>
256<span class="sd">    :param str varname: a single value can be used to create a :class:`VarName`</span>
257<span class="sd">    :param int atomnum: The number for the atom</span>
258<span class="sd">    </span>
259<span class="sd">    &#39;&#39;&#39;</span>
260    <span class="n">IDdict</span> <span class="o">=</span> <span class="p">{}</span>
261    <span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;phases&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
262    <span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;hists&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
263    <span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;atoms&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
264    <span class="c"># This dictionary lists descriptions for GSAS-II variables.</span>
265    <span class="c"># Note that keys may contain regular expressions, where &#39;[xyz]&#39;</span>
266    <span class="c"># matches &#39;x&#39; &#39;y&#39; or &#39;z&#39; (equivalently &#39;[x-z]&#39; describes this as range of values).</span>
267    <span class="c"># &#39;.*&#39; matches any string</span>
268    <span class="n">VarDesc</span> <span class="o">=</span> <span class="p">{</span>
269        <span class="c"># Phase vars (p::&lt;var&gt;)</span>
270        <span class="s">&#39;A[0-5]&#39;</span> <span class="p">:</span> <span class="s">&#39;Reciprocal metric tensor component&#39;</span><span class="p">,</span>
271        <span class="s">&#39;Vol&#39;</span> <span class="p">:</span> <span class="s">&#39;Unit cell volume????&#39;</span><span class="p">,</span>
272        <span class="c"># Atom vars (p::&lt;var&gt;:a)</span>
273        <span class="s">&#39;dA[xyz]&#39;</span> <span class="p">:</span> <span class="s">&#39;change to atomic position&#39;</span><span class="p">,</span>
274        <span class="s">&#39;AUiso&#39;</span><span class="p">:</span><span class="s">&#39;Atomic isotropic displacement parameter&#39;</span><span class="p">,</span>
275        <span class="s">&#39;AU[123][123]&#39;</span><span class="p">:</span><span class="s">&#39;Atomic anisotropic displacement parameter&#39;</span><span class="p">,</span>
276        <span class="s">&#39;AFrac&#39;</span><span class="p">:</span> <span class="s">&#39;Atomic occupancy parameter&#39;</span><span class="p">,</span>
277        <span class="c"># Hist &amp; Phase (HAP) vars (p:h:&lt;var&gt;)</span>
278        <span class="s">&#39;Bab[AU]&#39;</span><span class="p">:</span> <span class="s">&#39;Babinet solvent scattering coef.&#39;</span><span class="p">,</span>
279        <span class="s">&#39;D[123][123]&#39;</span> <span class="p">:</span> <span class="s">&#39;Anisotropic strain coef.&#39;</span><span class="p">,</span>
280        <span class="s">&#39;Extinction&#39;</span> <span class="p">:</span> <span class="s">&#39;Extinction coef.&#39;</span><span class="p">,</span>
281        <span class="s">&#39;MD&#39;</span> <span class="p">:</span> <span class="s">&#39;March-Dollase coef.&#39;</span><span class="p">,</span>
282        <span class="s">&#39;Mustrain;.*&#39;</span> <span class="p">:</span> <span class="s">&#39;Microstrain coef.&#39;</span><span class="p">,</span>
283        <span class="s">&#39;Scale&#39;</span> <span class="p">:</span> <span class="s">&#39;Phase scale factor&#39;</span><span class="p">,</span>
284        <span class="s">&#39;Size;.*&#39;</span> <span class="p">:</span> <span class="s">&#39;Crystallite size value&#39;</span><span class="p">,</span>
285        <span class="s">&#39;eA&#39;</span> <span class="p">:</span> <span class="s">&#39;?&#39;</span><span class="p">,</span>
286        <span class="c">#Histogram vars (:h:&lt;var&gt;)</span>
287        <span class="s">&#39;Absorption&#39;</span> <span class="p">:</span> <span class="s">&#39;Absorption coef.&#39;</span><span class="p">,</span>
288        <span class="s">&#39;Displace[XY]&#39;</span> <span class="p">:</span> <span class="s">&#39;Debye-Scherrer sample displacement&#39;</span><span class="p">,</span>
289        <span class="s">&#39;Lam&#39;</span> <span class="p">:</span> <span class="s">&#39;Wavelength&#39;</span><span class="p">,</span>
290        <span class="s">&#39;Polariz&#39;</span> <span class="p">:</span> <span class="s">&#39;Polarization correction&#39;</span><span class="p">,</span>
291        <span class="s">&#39;SH/L&#39;</span> <span class="p">:</span> <span class="s">&#39;FCJ peak asymmetry correction&#39;</span><span class="p">,</span>
292        <span class="s">&#39;Scale&#39;</span> <span class="p">:</span> <span class="s">&#39;Histogram scale factor&#39;</span><span class="p">,</span>
293        <span class="s">&#39;[UVW]&#39;</span> <span class="p">:</span> <span class="s">&#39;Gaussian instrument broadening&#39;</span><span class="p">,</span>
294        <span class="s">&#39;[XY]&#39;</span> <span class="p">:</span> <span class="s">&#39;Cauchy instrument broadening&#39;</span><span class="p">,</span>
295        <span class="s">&#39;Zero&#39;</span> <span class="p">:</span> <span class="s">&#39;Debye-Scherrer zero correction&#39;</span><span class="p">,</span>
296        <span class="s">&#39;nDebye&#39;</span> <span class="p">:</span> <span class="s">&#39;Debye model background corr. terms&#39;</span><span class="p">,</span>
297        <span class="s">&#39;nPeaks&#39;</span> <span class="p">:</span> <span class="s">&#39;Fixed peak  background corr. terms&#39;</span><span class="p">,</span>
298        <span class="c"># Global vars (::&lt;var&gt;)</span>
299        <span class="p">}</span>
300    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
301        <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="bp">None</span>
302        <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="bp">None</span>
303        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
304        <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="bp">None</span>
305        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
306            <span class="n">lst</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;:&#39;</span><span class="p">)</span>
307            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span> <span class="s">&quot;Need to look up IDs&quot;</span>
308            <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="n">lst</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
309            <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="n">lst</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
310            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">lst</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
311            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">lst</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
312                <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="n">lst</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
313        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span>
314            <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
315            <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
316            <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
317            <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
318        <span class="k">else</span><span class="p">:</span>
319            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&quot;Incorrectly called GSAS-II parameter name&quot;</span>
320
321    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
322        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">()</span>
323
324<div class="viewcode-block" id="VarName.name"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.VarName.name">[docs]</a>    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
325        <span class="sd">&#39;&#39;&#39;Formats the GSAS-II variable name as a &quot;traditional&quot; string (p:h:&lt;var&gt;:a)</span>
326
327<span class="sd">        :returns: the variable name as a str</span>
328<span class="sd">        &#39;&#39;&#39;</span>
329        <span class="k">def</span> <span class="nf">_fmt</span><span class="p">(</span><span class="n">val</span><span class="p">):</span>
330            <span class="k">if</span> <span class="n">val</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
331                <span class="k">return</span> <span class="s">&quot;&quot;</span>
332            <span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
333        <span class="k">return</span> <span class="n">_fmt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">phase</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">_fmt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">histogram</span><span class="p">)</span> <span class="o">+</span> <span class="n">_fmt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="o">+</span> <span class="n">_fmt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">atom</span><span class="p">)</span>
334</div>
335    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
336        <span class="sd">&#39;&#39;&#39;Return the detailed contents of the object</span>
337<span class="sd">        &#39;&#39;&#39;</span>
338        <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
339        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">phase</span><span class="p">:</span>
340            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Phase: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">phase</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;; &quot;</span>
341
342        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span><span class="p">:</span>
343            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Histogram: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">histogram</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;; &quot;</span>
344           
345        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
346            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Variable name: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;; &quot;</span>
347
348        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">atom</span><span class="p">:</span>
349            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Atom number: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">atom</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;; &quot;</span>
350
351        <span class="k">return</span> <span class="n">s</span><span class="o">+</span><span class="s">&quot;(&quot;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">()</span><span class="o">+</span><span class="s">&quot;)&quot;</span>
352
353    <span class="k">def</span> <span class="nf">getDescr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
354        <span class="sd">&#39;&#39;&#39;Return a short description for a GSAS-II variable </span>
355
356<span class="sd">        :returns: a short description or &#39;no definition&#39; if not found</span>
357<span class="sd">        &#39;&#39;&#39;</span>
358        <span class="c"># iterating over uncompiled regular expressions is not terribly fast,</span>
359        <span class="c"># but this routine should not need to be all that speedy</span>
360        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">:</span>
361            <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">):</span>
362                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
363        <span class="k">return</span> <span class="s">&#39;no definition&#39;</span>
364
365<div class="viewcode-block" id="VarName.getDescr"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.VarName.getDescr">[docs]</a>    <span class="k">def</span> <span class="nf">getDescr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
366        <span class="sd">&#39;&#39;&#39;Return a short description for a GSAS-II variable </span>
367
368<span class="sd">        :returns: a short description or &#39;no definition&#39; if not found</span>
369<span class="sd">        &#39;&#39;&#39;</span>
370        <span class="c"># iterating over uncompiled regular expressions is not terribly fast,</span>
371        <span class="c"># but this routine should not need to be all that speedy</span>
372        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">:</span>
373            <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">):</span>
374                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
375        <span class="k">return</span> <span class="s">&#39;no definition&#39;</span>
376</div>
377<div class="viewcode-block" id="VarName.fullDescr"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.VarName.fullDescr">[docs]</a>    <span class="k">def</span> <span class="nf">fullDescr</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
378        <span class="sd">&#39;&#39;&#39;Return a longer description for a GSAS-II variable </span>
379
380<span class="sd">        :returns: a short description or &#39;no definition&#39; if not found</span>
381<span class="sd">        &#39;&#39;&#39;</span>
382        <span class="c"># iterating over uncompiled regular expressions is not terribly fast,</span>
383        <span class="c"># but this routine should not need to be all that speedy</span>
384        <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">()</span>
385       
386        <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">:</span>
387            <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">):</span>
388                <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">VarDesc</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
389        <span class="k">return</span> <span class="s">&#39;no definition&#39;</span>
390
391</div>
392    <span class="k">def</span> <span class="nf">_show</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
393        <span class="s">&#39;For testing, shows the current lookup table&#39;</span>
394        <span class="k">print</span> <span class="s">&#39;phases&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;phases&#39;</span><span class="p">]</span>
395        <span class="k">print</span> <span class="s">&#39;hists&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;hists&#39;</span><span class="p">]</span>
396        <span class="k">print</span> <span class="s">&#39;atomDict&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDdict</span><span class="p">[</span><span class="s">&#39;atoms&#39;</span><span class="p">]</span>
397</pre></div></div>
398
399          </div>
400        </div>
401      </div>
402      <div class="sphinxsidebar">
403        <div class="sphinxsidebarwrapper">
404<div id="searchbox" style="display: none">
405  <h3>Quick search</h3>
406    <form class="search" action="../search.html" method="get">
407      <input type="text" name="q" />
408      <input type="submit" value="Go" />
409      <input type="hidden" name="check_keywords" value="yes" />
410      <input type="hidden" name="area" value="default" />
411    </form>
412    <p class="searchtip" style="font-size: 90%">
413    Enter search terms or a module, class or function name.
414    </p>
415</div>
416<script type="text/javascript">$('#searchbox').show(0);</script>
417        </div>
418      </div>
419      <div class="clearer"></div>
420    </div>
421    <div class="related">
422      <h3>Navigation</h3>
423      <ul>
424        <li class="right" style="margin-right: 10px">
425          <a href="../genindex.html" title="General Index"
426             >index</a></li>
427        <li class="right" >
428          <a href="../py-modindex.html" title="Python Module Index"
429             >modules</a> |</li>
430        <li><a href="../index.html">GSAS-II 0.2.0 documentation</a> &raquo;</li>
431          <li><a href="index.html" >Module code</a> &raquo;</li> 
432      </ul>
433    </div>
434    <div class="footer">
435        &copy; Copyright 2013, Von Dreele and Toby for Argonne National Laboratory.
436      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
437    </div>
438  </body>
439</html>
Note: See TracBrowser for help on using the repository browser.