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

Last change on this file since 1183 was 1183, checked in by toby, 8 years ago

fixup number formatting; update produced doc files

  • Property svn:mime-type set to text/html
File size: 148.5 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    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
29    <link rel="top" title="GSAS-II 0.2.0 documentation" href="../index.html" />
30    <link rel="up" title="Module code" href="index.html" /> 
31  </head>
32  <body>
33    <div class="related">
34      <h3>Navigation</h3>
35      <ul>
36        <li class="right" style="margin-right: 10px">
37          <a href="../genindex.html" title="General Index"
38             accesskey="I">index</a></li>
39        <li class="right" >
40          <a href="../py-modindex.html" title="Python Module Index"
41             >modules</a> |</li>
42        <li><a href="../index.html">GSAS-II 0.2.0 documentation</a> &raquo;</li>
43          <li><a href="index.html" accesskey="U">Module code</a> &raquo;</li> 
44      </ul>
45    </div> 
46
47    <div class="document">
48      <div class="documentwrapper">
49        <div class="bodywrapper">
50          <div class="body">
51           
52  <h1>Source code for GSASIIobj</h1><div class="highlight"><pre>
53<span class="c"># -*- coding: utf-8 -*-</span>
54<span class="c">#GSASIIobj - data objects for GSAS-II</span>
55<span class="c">########### SVN repository information ###################</span>
56<span class="c"># $Date: 2014-01-02 14:18:25 -0600 (Thu, 02 Jan 2014) $</span>
57<span class="c"># $Author: toby $</span>
58<span class="c"># $Revision: 1181 $</span>
59<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIIobj.py $</span>
60<span class="c"># $Id: GSASIIobj.py 1181 2014-01-02 20:18:25Z toby $</span>
61<span class="c">########### SVN repository information ###################</span>
62
63<span class="sd">&#39;&#39;&#39;</span>
64<span class="sd">*GSASIIobj: Data objects*</span>
65<span class="sd">=========================</span>
66
67<span class="sd">This module defines and/or documents the data structures used in GSAS-II, as well</span>
68<span class="sd">as provides misc. support routines. </span>
69
70<span class="sd">Constraints Tree Item</span>
71<span class="sd">----------------------</span>
72
73<span class="sd">.. _Constraints_table:</span>
74
75<span class="sd">.. index::</span>
76<span class="sd">   single: Constraints object description</span>
77<span class="sd">   single: Data object descriptions; Constraints</span>
78
79<span class="sd">Constraints are stored in a dict, separated into groups.</span>
80<span class="sd">Note that parameter are named in the following pattern,</span>
81<span class="sd">p:h:&lt;var&gt;:n, where p is the phase number, h is the histogram number</span>
82<span class="sd">&lt;var&gt; is a variable name and n is the parameter number.</span>
83<span class="sd">If a parameter does not depend on a histogram or phase or is unnumbered, that</span>
84<span class="sd">number is omitted.</span>
85<span class="sd">Note that the contents of each dict item is a List where each element in the</span>
86<span class="sd">list is a :ref:`constraint definition objects &lt;Constraint_definitions_table&gt;`.</span>
87<span class="sd">The constraints in this form are converted in</span>
88<span class="sd">:func:`GSASIIstrIO.ProcessConstraints` to the form used in :mod:`GSASIImapvars`</span>
89
90<span class="sd">The keys in the Constraints dict are:</span>
91
92<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
93
94<span class="sd">==========  ====================================================</span>
95<span class="sd">  key         explanation</span>
96<span class="sd">==========  ====================================================</span>
97<span class="sd">Hist        This specifies a list of constraints on </span>
98<span class="sd">            histogram-related parameters,</span>
99<span class="sd">            which will be of form :h:&lt;var&gt;:n.</span>
100<span class="sd">HAP         This specifies a list of constraints on parameters</span>
101<span class="sd">            that are defined for every histogram in each phase</span>
102<span class="sd">            and are of form p:h:&lt;var&gt;:n.            </span>
103<span class="sd">Phase       This specifies a list of constraints on phase</span>
104<span class="sd">            parameters,</span>
105<span class="sd">            which will be of form p::&lt;var&gt;:n.</span>
106<span class="sd">Global      This specifies a list of constraints on parameters</span>
107<span class="sd">            that are not tied to a histogram or phase and</span>
108<span class="sd">            are of form ::&lt;var&gt;:n</span>
109<span class="sd">==========  ====================================================</span>
110
111<span class="sd">.. _Constraint_definitions_table:</span>
112
113<span class="sd">.. index::</span>
114<span class="sd">   single: Constraint definition object description</span>
115<span class="sd">   single: Data object descriptions; Constraint Definition</span>
116
117<span class="sd">Each constraint is defined as an item in a list. Each constraint is of form::</span>
118
119<span class="sd">[[&lt;mult1&gt;, &lt;var1&gt;], [&lt;mult2&gt;, &lt;var2&gt;],..., &lt;fixedval&gt;, &lt;varyflag&gt;, &lt;constype&gt;]</span>
120
121<span class="sd">Where the variable pair list item containing two values [&lt;mult&gt;, &lt;var&gt;], where: </span>
122
123<span class="sd">  * &lt;mult&gt; is a multiplier for the constraint (float)</span>
124<span class="sd">  * &lt;var&gt; a :class:`G2VarObj` object (previously a str variable name of form</span>
125<span class="sd">      &#39;p:h:name[:at]&#39;)</span>
126
127<span class="sd">Note that the last three items in the list play a special role:</span>
128
129<span class="sd"> * &lt;fixedval&gt; is the fixed value for a `constant equation` (``constype=c``)</span>
130<span class="sd">   constraint or is None. For a `New variable` (``constype=f``) constraint,</span>
131<span class="sd">   a variable name can be specified as a str (used for externally</span>
132<span class="sd">   generated constraints)</span>
133<span class="sd"> * &lt;varyflag&gt; is True or False for `New variable` (``constype=f``) constraints</span>
134<span class="sd">   or is None. This will be implemented in the future to indicate if these variables</span>
135<span class="sd">   should be refined.</span>
136<span class="sd"> * &lt;constype&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>
137
138<span class="sd">    * &#39;e&#39; defines a set of equivalent variables. Only the first variable is refined (if the</span>
139<span class="sd">      appropriate refine flag is set) and and all other equivalent variables in the list</span>
140<span class="sd">      are generated from that variable, using the appropriate multipliers. </span>
141<span class="sd">    * &#39;c&#39; defines a constraint equation of form,</span>
142<span class="sd">      :math:`m_1 \\times var_1 + m_2 \\times var_2 + ... = c`</span>
143<span class="sd">    * &#39;h&#39; defines a variable to hold (not vary). Any variable on this list is not varied,</span>
144<span class="sd">      even if its refinement flag is set. Only one [mult,var] pair is allowed in a hold</span>
145<span class="sd">      constraint and the mult value is ignored.</span>
146<span class="sd">      This is of particular value when needing to hold one or more variables where a</span>
147<span class="sd">      single flag controls a set of variables such as, coordinates, </span>
148<span class="sd">      the reciprocal metric tensor or anisotropic displacement parameter. </span>
149<span class="sd">    * &#39;f&#39; defines a new variable (function) according to relationship </span>
150<span class="sd">      :math:`newvar = m_1 \\times var_1 + m_2 \\times var_2 + ...`</span>
151
152<span class="sd">Covariance Tree Item</span>
153<span class="sd">--------------------</span>
154
155<span class="sd">.. _Covariance_table:</span>
156
157<span class="sd">.. index::</span>
158<span class="sd">   single: Covariance description</span>
159<span class="sd">   single: Data object descriptions; Covariance</span>
160
161<span class="sd">The Covariance tree item has results from the last least-squares run. They</span>
162<span class="sd">are stored in a dict with these keys:</span>
163
164<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
165
166<span class="sd">=============  ===============  ====================================================</span>
167<span class="sd">  key            sub-key        explanation</span>
168<span class="sd">=============  ===============  ====================================================</span>
169<span class="sd">newCellDict    \                dict with lattice parameters computed by</span>
170<span class="sd">                                :func:`GSASIIstrMath.GetNewCellParms` (dict)</span>
171<span class="sd">title          \                Name of gpx file(?) (str)</span>
172<span class="sd">variables      \                Values for all N refined variables</span>
173<span class="sd">                                (list of float values, length N,</span>
174<span class="sd">                                ordered to match varyList)</span>
175<span class="sd">sig            \                Uncertainty values for all N refined variables</span>
176<span class="sd">                                (list of float values, length N,</span>
177<span class="sd">                                ordered to match varyList)</span>
178<span class="sd">varyList       \                List of directly refined variables </span>
179<span class="sd">                                (list of str values, length N)</span>
180<span class="sd">newAtomDict    \                dict with atom position values computed in </span>
181<span class="sd">                                :func:`GSASIIstrMath.ApplyXYZshifts` (dict)</span>
182<span class="sd">Rvals          \                R-factors, GOF, Marquardt value for last</span>
183<span class="sd">                                refinement cycle (dict)</span>
184<span class="sd">\              Nobs             Number of observed data points (int)</span>
185<span class="sd">\              Rwp              overall weighted profile R-factor (%, float)</span>
186<span class="sd">\              chisq            sum[w*(Iobs-Icalc)**2] for all data</span>
187<span class="sd">                                note this is not the reduced chi squared (float)</span>
188<span class="sd">\              lamMax           Marquardt value applied to Hessian diagonal</span>
189<span class="sd">                                (float)</span>
190<span class="sd">\              GOF              The goodness-of-fit, aka square root of</span>
191<span class="sd">                                the reduced chi squared. (float)</span>
192<span class="sd">covMatrix      \                The (NxN) covVariance matrix (np.array)</span>
193<span class="sd">=============  ===============  ====================================================</span>
194
195<span class="sd">Phase Tree Items</span>
196<span class="sd">----------------</span>
197
198<span class="sd">.. _Phase_table:</span>
199
200<span class="sd">.. index::</span>
201<span class="sd">   single: Phase object description</span>
202<span class="sd">   single: Data object descriptions; Phase</span>
203
204<span class="sd">Phase information is stored in the GSAS-II data tree as children of the</span>
205<span class="sd">Phases item in a dict with keys:</span>
206
207<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
208
209<span class="sd">==========  ===============  ====================================================</span>
210<span class="sd">  key         sub-key        explanation</span>
211<span class="sd">==========  ===============  ====================================================</span>
212<span class="sd">General         \            Overall information for the phase (dict)</span>
213<span class="sd">  \         AtomPtrs         list of four locations to use to pull info</span>
214<span class="sd">                             from the atom records (list)</span>
215<span class="sd">  \         F000X            x-ray F(000) intensity (float)</span>
216<span class="sd">  \         F000N            neutron F(000) intensity (float)</span>
217<span class="sd">  \         Mydir            directory of current .gpx file (str)</span>
218<span class="sd">  \         MCSA controls    Monte Carlo-Simulated Annealing controls (dict)</span>
219<span class="sd">  \         Cell             List with 8 items: cell refinement flag (bool)</span>
220<span class="sd">                             a, b, c, (Angstrom, float)</span>
221<span class="sd">                             alpha, beta &amp; gamma (degrees, float)</span>
222<span class="sd">                             volume (A^3, float)</span>
223<span class="sd">  \         Type             &#39;nuclear&#39; or &#39;macromolecular&#39; for now (str)</span>
224<span class="sd">  \         Map              dict of map parameters</span>
225<span class="sd">  \         SH Texture       dict of spherical harmonic preferred orientation </span>
226<span class="sd">                             parameters</span>
227<span class="sd">  \         Isotope          dict of isotopes for each atom type</span>
228<span class="sd">  \         Isotopes         dict of scattering lengths for each isotope</span>
229<span class="sd">                             combination for each element in phase  </span>
230<span class="sd">  \         Name             phase name (str)</span>
231<span class="sd">  \         SGData           Space group details as a :ref:`space group (SGData) object &lt;SGData_table&gt;`</span>
232<span class="sd">                             as defined in :func:`GSASIIspc.SpcGroup`.</span>
233<span class="sd">  \         Pawley neg wt    Restraint value for negative Pawley intensities</span>
234<span class="sd">                             (float)</span>
235<span class="sd">  \         Flip             dict of Charge flip controls </span>
236<span class="sd">  \         Data plot type   data plot type (&#39;Mustrain&#39;, &#39;Size&#39; or </span>
237<span class="sd">                             &#39;Preferred orientation&#39;) for powder data (str)</span>
238<span class="sd">  \         Mass             Mass of unit cell contents in g/mol</span>
239<span class="sd">  \         POhkl            March-Dollase preferred orientation direction</span>
240<span class="sd">  \         Z                dict of atomic numbers for each atom type </span>
241<span class="sd">  \         vdWRadii         dict of van der Waals radii for each atom type </span>
242<span class="sd">  \         Color            Colors for atoms (list of (r,b,g) triplets)</span>
243<span class="sd">  \         AtomTypes        List of atom types</span>
244<span class="sd">  \         AtomMass         List of masses for atoms</span>
245<span class="sd">  \         doPawley         Flag for Pawley intensity extraction (bool)</span>
246<span class="sd">  \         NoAtoms          Number of atoms per unit cell of each type (dict)</span>
247<span class="sd">  \         Pawley dmin      maximum Q (as d-space) to use for Pawley </span>
248<span class="sd">                             extraction (float)</span>
249<span class="sd">  \         BondRadii        Default radius for each atom used to compute </span>
250<span class="sd">                             interatomic distances (list of floats)</span>
251<span class="sd">  \         AngleRadii       Default radius for each atom used to compute </span>
252<span class="sd">                             interatomic angles (list of floats)</span>
253<span class="sd">  \         DisAglCtls       Dict with distance/angle search controls,</span>
254<span class="sd">                             which has keys &#39;Name&#39;, &#39;AtomTypes&#39;,</span>
255<span class="sd">                             &#39;BondRadii&#39;, &#39;AngleRadii&#39; which are as above</span>
256<span class="sd">                             except are possibly edited. Also contains</span>
257<span class="sd">                             &#39;Factors&#39;, which is a 2 element list with</span>
258<span class="sd">                             a multiplier for bond and angle search range</span>
259<span class="sd">                             [typically (0.85,0.85)].</span>
260<span class="sd">ranId           \            unique random number Id for phase (int)</span>
261<span class="sd">pId             \            Phase Id number for current project (int).</span>
262<span class="sd">Atoms           \            Atoms in phase as a list of lists. The outer list</span>
263<span class="sd">                             is for each atom, the inner list contains varying</span>
264<span class="sd">                             items depending on the type of phase, see</span>
265<span class="sd">                             the :ref:`Atom Records &lt;Atoms_table&gt;` description.</span>
266<span class="sd">                             (list of lists)</span>
267<span class="sd">Drawing         \            Display parameters (dict)</span>
268<span class="sd">\           ballScale        Size of spheres in ball-and-stick display (float)</span>
269<span class="sd">\           bondList         dict with bonds</span>
270<span class="sd">\           contourLevel     map contour level in e/A^3 (float)</span>
271<span class="sd">\           showABC          Flag to show view point triplet (bool). True=show.</span>
272<span class="sd">\           viewDir          cartesian viewing direction (np.array with three</span>
273<span class="sd">                             elements)</span>
274<span class="sd">\           Zclip            clipping distance in A (float)</span>
275<span class="sd">\           backColor        background for plot as and R,G,B triplet</span>
276<span class="sd">                             (default = [0, 0, 0], black).</span>
277<span class="sd">                             (list with three atoms)</span>
278<span class="sd">\           selectedAtoms    List of selected atoms (list of int values)</span>
279<span class="sd">\           showRigidBodies  Flag to highlight rigid body placement</span>
280<span class="sd">\           sizeH            Size ratio for H atoms (float) </span>
281<span class="sd">\           bondRadius       Size of binds in A (float)</span>
282<span class="sd">\           atomPtrs         positions of x, type, site sym, ADP flag in Draw Atoms (list)</span>
283<span class="sd">\           viewPoint        list of lists. First item in list is [x,y,z]</span>
284<span class="sd">                             in fractional coordinates for the center of</span>
285<span class="sd">                             the plot. Second item list of previous &amp; current </span>
286<span class="sd">                             atom number viewed (may be [0,0])</span>
287<span class="sd">\           showHydrogen     Flag to control plotting of H atoms.</span>
288<span class="sd">\           unitCellBox      Flag to control display of the unit cell.</span>
289<span class="sd">\           ellipseProb      Probability limit for display of thermal</span>
290<span class="sd">                             ellipsoids in % (float).</span>
291<span class="sd">\           vdwScale         Multiplier of van der Waals radius for</span>
292<span class="sd">                             display of vdW spheres. </span>
293<span class="sd">\           Atoms            A list of lists with an entry for each atom</span>
294<span class="sd">                             that is plotted.</span>
295<span class="sd">\           Zstep            Step to de/increase Z-clip (float)</span>
296<span class="sd">\           Quaternion       Viewing quaternion (4 element np.array)</span>
297<span class="sd">\           radiusFactor     Distance ratio for searching for bonds. ? Bonds</span>
298<span class="sd">                             are located that are within r(Ra+Rb) and (Ra+Rb)/r</span>
299<span class="sd">                             where Ra and Rb are the atomic radii.</span>
300<span class="sd">\           oldxy            previous view point (list with two floats)</span>
301<span class="sd">\           cameraPos        Viewing position in A for plot (float)</span>
302<span class="sd">\           depthFog         True if use depthFog on plot - set currently as False (bool)</span>
303<span class="sd">RBModels        \            Rigid body assignments (note Rigid body definitions</span>
304<span class="sd">                             are stored in their own main top-level tree entry.)</span>
305<span class="sd">Pawley ref      \            Pawley reflections</span>
306<span class="sd">Histograms      \            A dict of dicts. The key for the outer dict is</span>
307<span class="sd">                             the histograms tied to this phase. The inner</span>
308<span class="sd">                             dict contains the combined phase/histogram</span>
309<span class="sd">                             parameters for items such as scale factors,</span>
310<span class="sd">                             size and strain parameters. (dict)</span>
311<span class="sd">MCSA            \            Monte-Carlo simulated annealing parameters (dict)</span>
312<span class="sd">\           </span>
313<span class="sd">==========  ===============  ====================================================</span>
314
315<span class="sd">Rigid Body Objects</span>
316<span class="sd">------------------</span>
317
318<span class="sd">.. _RBData_table:</span>
319
320<span class="sd">.. index::</span>
321<span class="sd">   single: Rigid Body Data description</span>
322<span class="sd">   single: Data object descriptions; Rigid Body Data</span>
323<span class="sd">   </span>
324<span class="sd">Rigid body descriptions are available for two types of rigid bodies: &#39;Vector&#39; </span>
325<span class="sd">and &#39;Residue&#39;. Vector rigid bodies are developed by a sequence of translations each</span>
326<span class="sd">with a refinable magnitude and Residue rigid bodies are described as Cartesian coordinates</span>
327<span class="sd">with defined refinable torsion angles.</span>
328
329<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
330
331<span class="sd">==========  ===============  ====================================================</span>
332<span class="sd">  key         sub-key        explanation</span>
333<span class="sd">==========  ===============  ====================================================</span>
334<span class="sd">Vector      RBId             vector rigid bodies (dict of dict)</span>
335<span class="sd">\           AtInfo           Drad, Color: atom drawing radius &amp; color for each atom type (dict)</span>
336<span class="sd">\           RBname           Name assigned by user to rigid body (str)</span>
337<span class="sd">\           VectMag          vector magnitudes in A (list)</span>
338<span class="sd">\           rbXYZ            Cartesian coordinates for Vector rigid body (list of 3 float)</span>
339<span class="sd">\           rbRef            3 assigned reference atom nos. in rigid body for origin </span>
340<span class="sd">                             definition, use center of atoms flag (list of 3 int &amp; 1 bool)</span>
341<span class="sd">\           VectRef          refinement flags for VectMag values (list of bool)</span>
342<span class="sd">\           rbTypes          Atom types for each atom in rigid body (list of str)</span>
343<span class="sd">\           rbVect           Cartesian vectors for each translation used to build rigid body (list of lists)</span>
344<span class="sd">\           useCount         Number of times rigid body is used in any structure (int)</span>
345<span class="sd">Residue     RBId             residue rigid bodies (dict of dict)</span>
346<span class="sd">\           AtInfo           Drad, Color: atom drawing radius &amp; color for each atom type(dict)</span>
347<span class="sd">\           RBname           Name assigned by user to rigid body (str)</span>
348<span class="sd">\           rbXYZ            Cartesian coordinates for Residue rigid body (list of 3 float)</span>
349<span class="sd">\           rbTypes          Atom types for each atom in rigid body (list of str)</span>
350<span class="sd">\           atNames          Names of each atom in rigid body (e.g. C1,N2...) (list of str)</span>
351<span class="sd">\           rbRef            3 assigned reference atom nos. in rigid body for origin </span>
352<span class="sd">                             definition, use center of atoms flag (list of 3 int &amp; 1 bool)</span>
353<span class="sd">\           rbSeq            Orig,Piv,angle,Riding (list): definition of internal rigid body</span>
354<span class="sd">                             torsion; origin atom (int), pivot atom (int), torsion angle (float),</span>
355<span class="sd">                             riding atoms (list of int)</span>
356<span class="sd">\           SelSeq           [int,int] used by SeqSizer to identify objects</span>
357<span class="sd">\           useCount         Number of times rigid body is used in any structure (int)</span>
358<span class="sd">RBIds           \            unique Ids generated upon creation of each rigid body (dict)</span>
359<span class="sd">\           Vector           Ids for each Vector rigid body (list)</span>
360<span class="sd">\           Residue          Ids for each Residue rigid body (list)</span>
361<span class="sd">==========  ===============  ====================================================</span>
362
363<span class="sd">Space Group Objects </span>
364<span class="sd">-------------------</span>
365
366<span class="sd">.. _SGData_table:</span>
367
368<span class="sd">.. index::</span>
369<span class="sd">   single: Space Group Data description</span>
370<span class="sd">   single: Data object descriptions; Space Group Data</span>
371
372<span class="sd">Space groups are interpreted by :func:`GSASIIspc.SpcGroup` </span>
373<span class="sd">and the information is placed in a SGdata object </span>
374<span class="sd">which is a dict with these keys:</span>
375
376<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
377
378<span class="sd">==========  ====================================================</span>
379<span class="sd">  key         explanation</span>
380<span class="sd">==========  ====================================================</span>
381<span class="sd">SpGrp       space group symbol (str)</span>
382<span class="sd">Laue        one of the following 14 Laue classes:</span>
383<span class="sd">            -1, 2/m, mmm, 4/m, 4/mmm, 3R,</span>
384<span class="sd">            3mR, 3, 3m1, 31m, 6/m, 6/mmm, m3, m3m (str)</span>
385<span class="sd">SGInv       True if centrosymmetric, False if not (bool)</span>
386<span class="sd">SGLatt      Lattice centering type. Will be one of</span>
387<span class="sd">            P, A, B, C, I, F, R (str)</span>
388<span class="sd">SGUniq      unique axis if monoclinic. Will be</span>
389<span class="sd">            a, b, or c for monoclinic space groups.</span>
390<span class="sd">            Will be blank for non-monoclinic. (str)</span>
391<span class="sd">SGCen       Symmetry cell centering vectors. A (n,3) np.array</span>
392<span class="sd">            of centers. Will always have at least one row:</span>
393<span class="sd">            ``np.array([[0, 0, 0]])``</span>
394<span class="sd">SGOps       symmetry operations as a list of form</span>
395<span class="sd">            ``[[M1,T1], [M2,T2],...]``</span>
396<span class="sd">            where :math:`M_n` is a 3x3 np.array</span>
397<span class="sd">            and :math:`T_n` is a length 3 np.array.</span>
398<span class="sd">            Atom coordinates are transformed where the</span>
399<span class="sd">            Asymmetric unit coordinates [X is (x,y,z)]</span>
400<span class="sd">            are transformed using</span>
401<span class="sd">            :math:`X^\prime = M_n*X+T_n`</span>
402<span class="sd">SGSys       symmetry unit cell: type one of</span>
403<span class="sd">            &#39;triclinic&#39;, &#39;monoclinic&#39;, &#39;orthorhombic&#39;,</span>
404<span class="sd">            &#39;tetragonal&#39;, &#39;rhombohedral&#39;, &#39;trigonal&#39;,</span>
405<span class="sd">            &#39;hexagonal&#39;, &#39;cubic&#39; (str)</span>
406<span class="sd">SGPolax     Axes for space group polarity. Will be one of</span>
407<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>
408<span class="sd">            &#39;xyz&#39;. In the case where axes are arbitrary </span>
409<span class="sd">            &#39;111&#39; is used (P 1, and ?).</span>
410<span class="sd">==========  ====================================================</span>
411
412<span class="sd">Atom Records</span>
413<span class="sd">------------</span>
414
415<span class="sd">.. _Atoms_table:</span>
416
417<span class="sd">.. index::</span>
418<span class="sd">   single: Atoms record description</span>
419<span class="sd">   single: Data object descriptions; Atoms record</span>
420
421
422<span class="sd">If ``phasedict`` points to the phase information in the data tree, then</span>
423<span class="sd">atoms are contained in a list of atom records (list) in</span>
424<span class="sd">``phasedict[&#39;Atoms&#39;]``. Also needed to read atom information </span>
425<span class="sd">are four pointers, ``cx,ct,cs,cia = phasedict[&#39;General&#39;][&#39;atomPtrs&#39;]``,</span>
426<span class="sd">which define locations in the atom record, as shown below. Items shown are </span>
427<span class="sd">always present; additional ones for macromolecular phases are marked &#39;mm&#39;</span>
428
429<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
430
431<span class="sd">==============   ====================================================</span>
432<span class="sd">location         explanation</span>
433<span class="sd">==============   ====================================================</span>
434<span class="sd">ct-4              mm - residue number (str)</span>
435<span class="sd">ct-3              mm - residue name (e.g. ALA) (str)</span>
436<span class="sd">ct-2              mm - chain label (str)</span>
437<span class="sd">ct-1              atom label (str)</span>
438<span class="sd">ct                atom type (str)</span>
439<span class="sd">ct+1              refinement flags; combination of &#39;F&#39;, &#39;X&#39;, &#39;U&#39; (str)</span>
440<span class="sd">cx,cx+1,cx+2      the x,y and z coordinates (3 floats)</span>
441<span class="sd">cs                site symmetry (str)</span>
442<span class="sd">cs+1              site multiplicity (int)</span>
443<span class="sd">cia               ADP flag: Isotropic (&#39;I&#39;) or Anisotropic (&#39;A&#39;)</span>
444<span class="sd">cia+1             Uiso (float)</span>
445<span class="sd">cia+2...cia+6     U11, U22, U33, U12, U13, U23 (6 floats)</span>
446<span class="sd">atom[-1]                unique atom identifier (int)</span>
447<span class="sd">==============   ====================================================</span>
448
449<span class="sd">Drawing Atom Records</span>
450<span class="sd">--------------------</span>
451
452<span class="sd">.. _Drawing_atoms_table:</span>
453
454<span class="sd">.. index::</span>
455<span class="sd">   single: Drawing atoms record description</span>
456<span class="sd">   single: Data object descriptions; Drawing atoms record</span>
457
458
459<span class="sd">If ``phasedict`` points to the phase information in the data tree, then</span>
460<span class="sd">drawing atoms are contained in a list of drawing atom records (list) in</span>
461<span class="sd">``phasedict[&#39;Drawing&#39;][&#39;Atoms&#39;]``. Also needed to read atom information </span>
462<span class="sd">are four pointers, ``cx,ct,cs,ci = phasedict[&#39;Drawing&#39;][&#39;AtomPtrs&#39;]``,</span>
463<span class="sd">which define locations in the atom record, as shown below. Items shown are </span>
464<span class="sd">always present; additional ones for macromolecular phases are marked &#39;mm&#39;</span>
465
466<span class="sd">.. tabularcolumns:: |l|p{4.5in}|</span>
467
468<span class="sd">==============   ====================================================</span>
469<span class="sd">location         explanation</span>
470<span class="sd">==============   ====================================================</span>
471<span class="sd">ct-4              mm - residue number (str)</span>
472<span class="sd">ct-3              mm - residue name (e.g. ALA) (str)</span>
473<span class="sd">ct-2              mm - chain label (str)</span>
474<span class="sd">ct-1              atom label (str)</span>
475<span class="sd">ct                atom type (str)</span>
476<span class="sd">cx,cx+1,cx+2      the x,y and z coordinates (3 floats)</span>
477<span class="sd">cs-1              Sym Op symbol; sym. op number + unit cell id (e.g. &#39;1,0,-1&#39;) (str)</span>
478<span class="sd">cs                atom drawing style; e.g. &#39;balls &amp; sticks&#39; (str)</span>
479<span class="sd">cs+1              atom label style (e.g. &#39;name&#39;) (str)</span>
480<span class="sd">cs+2              atom color (RBG triplet) (int)</span>
481<span class="sd">cs+3              ADP flag: Isotropic (&#39;I&#39;) or Anisotropic (&#39;A&#39;)</span>
482<span class="sd">cs+4              Uiso (float)</span>
483<span class="sd">cs+5...cs+11      U11, U22, U33, U12, U13, U23 (6 floats)</span>
484<span class="sd">ci                unique atom identifier; matches source atom Id in Atom Records (int)</span>
485<span class="sd">==============   ====================================================</span>
486
487<span class="sd">Powder Diffraction Tree Items</span>
488<span class="sd">-----------------------------</span>
489
490<span class="sd">.. _Powder_table:</span>
491
492<span class="sd">.. index::</span>
493<span class="sd">   single: Powder data object description</span>
494<span class="sd">   single: Data object descriptions; Powder Data</span>
495
496<span class="sd">Every powder diffraction histogram is stored in the GSAS-II data tree</span>
497<span class="sd">with a top-level entry named beginning with the string &quot;PWDR &quot;. The</span>
498<span class="sd">diffraction data for that information are directly associated with</span>
499<span class="sd">that tree item and there are a series of children to that item. The</span>
500<span class="sd">routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`</span>
501<span class="sd">and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will</span>
502<span class="sd">load this information into a dictionary where the child tree name is</span>
503<span class="sd">used as a key, and the information in the main entry is assigned</span>
504<span class="sd">a key of ``Data``, as outlined below.</span>
505
506<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
507
508<span class="sd">======================  ===============  ====================================================</span>
509<span class="sd">  key                      sub-key        explanation</span>
510<span class="sd">======================  ===============  ====================================================</span>
511<span class="sd">Comments                      \           Text strings extracted from the original powder </span>
512<span class="sd">                                          data header. These cannot be changed by the user; </span>
513<span class="sd">                                          it may be empty.</span>
514<span class="sd">Limits                       \            A list of two two element lists, as [[Ld,Hd],[L,H]]</span>
515<span class="sd">                                          where L and Ld are the current and default lowest</span>
516<span class="sd">                                          two-theta value to be used and </span>
517<span class="sd">                                          where H and Hd are the current and default highest</span>
518<span class="sd">                                          two-theta value to be used.</span>
519<span class="sd">Reflection Lists              \           A dict with an entry for each phase in the</span>
520<span class="sd">                                          histogram. The contents of each dict item</span>
521<span class="sd">                                          is a dict containing reflections, as described in</span>
522<span class="sd">                                          the :ref:`Powder Reflections &lt;PowderRefl_table&gt;`</span>
523<span class="sd">                                          description.</span>
524<span class="sd">Instrument Parameters         \           A list containing two dicts where the possible</span>
525<span class="sd">                                          keys in each dict are listed below. The value</span>
526<span class="sd">                                          for each item is a list containing three values:</span>
527<span class="sd">                                          the initial value, the current value and a</span>
528<span class="sd">                                          refinement flag which can have a value of</span>
529<span class="sd">                                          True, False or 0 where 0 indicates a value that</span>
530<span class="sd">                                          cannot be refined. The first and second</span>
531<span class="sd">                                          values are floats unless otherwise noted.</span>
532<span class="sd">                                          Items in the first dict are noted as [1]</span>
533<span class="sd">\                         Lam             Specifies a wavelength in Angstroms [1]</span>
534<span class="sd">\                         Lam1            Specifies the primary wavelength in</span>
535<span class="sd">                                          Angstrom, when an alpha1, alpha2</span>
536<span class="sd">                                          source is used [1]</span>
537<span class="sd">\                         Lam2            Specifies the secondary wavelength in</span>
538<span class="sd">                                          Angstrom, when an alpha1, alpha2</span>
539<span class="sd">                                          source is used [1]</span>
540<span class="sd">                          I(L2)/I(L1)     Ratio of Lam2 to Lam1 [1]           </span>
541<span class="sd">\                         Type            Histogram type (str) [1]: </span>
542<span class="sd">                                           * &#39;PXC&#39; for constant wavelength x-ray</span>
543<span class="sd">                                           * &#39;PNC&#39; for constant wavelength neutron</span>
544<span class="sd">                                           * &#39;PNT&#39; for time of flight neutron</span>
545<span class="sd">\                         Zero            Two-theta zero correction in *degrees* [1]</span>
546<span class="sd">\                         Azimuth         Azimuthal setting angle for data recorded</span>
547<span class="sd">                                          with differing setting angles [1]</span>
548<span class="sd">\                         U, V, W         Cagliotti profile coefficients</span>
549<span class="sd">                                          for Gaussian instrumental broadening, where the</span>
550<span class="sd">                                          FWHM goes as</span>
551<span class="sd">                                          :math:`U \\tan^2\\theta + V \\tan\\theta + W` [1]</span>
552<span class="sd">\                         X, Y            Cauchy (Lorentzian) instrumental broadening</span>
553<span class="sd">                                          coefficients [1]</span>
554<span class="sd">\                         SH/L            Variant of the Finger-Cox-Jephcoat asymmetric</span>
555<span class="sd">                                          peak broadening ratio. Note that this is the</span>
556<span class="sd">                                          average between S/L and H/L where S is</span>
557<span class="sd">                                          sample height, H is the slit height and</span>
558<span class="sd">                                          L is the goniometer diameter. [1]</span>
559<span class="sd">\                         Polariz.        Polarization coefficient. [1]</span>
560<span class="sd">wtFactor                      \           A weighting factor to increase or decrease</span>
561<span class="sd">                                          the leverage of data in the histogram (float).</span>
562<span class="sd">                                          A value of 1.0 weights the data with their</span>
563<span class="sd">                                          standard uncertainties and a larger value</span>
564<span class="sd">                                          increases the weighting of the data (equivalent</span>
565<span class="sd">                                          to decreasing the uncertainties).</span>
566<span class="sd">Sample Parameters             \           Specifies a dict with parameters that describe how</span>
567<span class="sd">                                          the data were collected, as listed</span>
568<span class="sd">                                          below. Refinable parameters are a list containing</span>
569<span class="sd">                                          a float and a bool, where the second value</span>
570<span class="sd">                                          specifies if the value is refined, otherwise</span>
571<span class="sd">                                          the value is a float unless otherwise noted.</span>
572<span class="sd">\                         Scale           The histogram scale factor (refinable) </span>
573<span class="sd">\                         Absorption      The sample absorption coefficient as</span>
574<span class="sd">                                          :math:`\\mu r` where r is the radius</span>
575<span class="sd">                                          (refinable). Only valid for Debye-Scherrer geometry.</span>
576<span class="sd">\                         SurfaceRoughA   Surface roughness parameter A as defined by</span>
577<span class="sd">                                          Surotti,J. Appl. Cryst, 5,325-331, 1972.(refinable - </span>
578<span class="sd">                                          only valid for Bragg-Brentano geometry)                                         </span>
579<span class="sd">\                         SurfaceRoughB   Surface roughness parameter B (refinable - </span>
580<span class="sd">                                          only valid for Bragg-Brentano geometry)                                          </span>
581<span class="sd">\                         DisplaceX,      Sample displacement from goniometer center</span>
582<span class="sd">                          DisplaceY       where Y is along the beam direction and</span>
583<span class="sd">                                          X is perpendicular. Units are :math:`\\mu m`</span>
584<span class="sd">                                          (refinable).</span>
585<span class="sd">\                         Phi, Chi,       Goniometer sample setting angles, in degrees.</span>
586<span class="sd">                          Omega</span>
587<span class="sd">\                         Gonio. radius   Radius of the diffractometer in mm</span>
588<span class="sd">\                         InstrName       A name for the instrument, used in preparing</span>
589<span class="sd">                                          a CIF (str).</span>
590<span class="sd">\                         Force,          Variables that describe how the measurement</span>
591<span class="sd">                          Temperature,    was performed. Not used directly in </span>
592<span class="sd">                          Humidity,       any computations. </span>
593<span class="sd">                          Pressure,</span>
594<span class="sd">                          Voltage</span>
595<span class="sd">\                         ranId           The random-number Id for the histogram</span>
596<span class="sd">                                          (same value as where top-level key is ranId)</span>
597<span class="sd">\                         Type            Type of diffraction data, may be &#39;Debye-Scherrer&#39;</span>
598<span class="sd">                                          or &#39;Bragg-Brentano&#39; (str).</span>
599<span class="sd">\                         Diffuse         not in use?</span>
600<span class="sd">hId                           \           The number assigned to the histogram when</span>
601<span class="sd">                                          the project is loaded or edited (can change)</span>
602<span class="sd">ranId                         \           A random number id for the histogram</span>
603<span class="sd">                                          that does not change</span>
604<span class="sd">Background                    \           The background is stored as a list with where</span>
605<span class="sd">                                          the first item in the list is list and the second</span>
606<span class="sd">                                          item is a dict. The list contains the background</span>
607<span class="sd">                                          function and its coefficients; the dict contains</span>
608<span class="sd">                                          Debye diffuse terms and background peaks.</span>
609<span class="sd">                                          (TODO: this needs to be expanded.)</span>
610<span class="sd">Data                          \           The data consist of a list of 6 np.arrays </span>
611<span class="sd">                                          containing in order:</span>
612
613<span class="sd">                                           1. the x-postions (two-theta in degrees),</span>
614<span class="sd">                                           2. the intensity values (Yobs),</span>
615<span class="sd">                                           3. the weights for each Yobs value</span>
616<span class="sd">                                           4. the computed intensity values (Ycalc)</span>
617<span class="sd">                                           5. the background values</span>
618<span class="sd">                                           6. Yobs-Ycalc</span>
619<span class="sd">======================  ===============  ====================================================</span>
620
621<span class="sd">Powder Reflection Data Structure</span>
622<span class="sd">--------------------------------</span>
623
624<span class="sd">.. _PowderRefl_table:</span>
625
626<span class="sd">.. index::</span>
627<span class="sd">   single: Powder reflection object description</span>
628<span class="sd">   single: Data object descriptions; Powder Reflections</span>
629<span class="sd">   </span>
630<span class="sd">For every phase in a histogram, the ``Reflection Lists`` value is a dict</span>
631<span class="sd">one element of which is `&#39;RefList&#39;`, which is a np.array containing</span>
632<span class="sd">reflections. The columns in that array are documented below.</span>
633
634<span class="sd">==========  ====================================================</span>
635<span class="sd">  index         explanation</span>
636<span class="sd">==========  ====================================================</span>
637<span class="sd"> 0,1,2       h,k,l (float)</span>
638<span class="sd"> 3           multiplicity</span>
639<span class="sd"> 4           d-space, Angstrom</span>
640<span class="sd"> 5           pos, two-theta</span>
641<span class="sd"> 6           sig, Gaussian width</span>
642<span class="sd"> 7           gam, Lorenzian width</span>
643<span class="sd"> 8           :math:`F_{obs}^2`</span>
644<span class="sd"> 9           :math:`F_{calc}^2`</span>
645<span class="sd"> 10          reflection phase, in degrees</span>
646<span class="sd"> 11          intensity correction for reflection, this times</span>
647<span class="sd">             :math:`F_{obs}^2` or :math:`F_{calc}^2` gives Iobs or Icalc </span>
648<span class="sd">==========  ====================================================</span>
649
650<span class="sd">Single Crystal Tree Items</span>
651<span class="sd">-------------------------</span>
652
653<span class="sd">.. _Xtal_table:</span>
654
655<span class="sd">.. index::</span>
656<span class="sd">   single: Single Crystal data object description</span>
657<span class="sd">   single: Data object descriptions; Single crystal data</span>
658
659<span class="sd">Every single crystal diffraction histogram is stored in the GSAS-II data tree</span>
660<span class="sd">with a top-level entry named beginning with the string &quot;HKLF &quot;. The</span>
661<span class="sd">diffraction data for that information are directly associated with</span>
662<span class="sd">that tree item and there are a series of children to that item. The</span>
663<span class="sd">routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`</span>
664<span class="sd">and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will</span>
665<span class="sd">load this information into a dictionary where the child tree name is</span>
666<span class="sd">used as a key, and the information in the main entry is assigned</span>
667<span class="sd">a key of ``Data``, as outlined below.</span>
668
669<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
670
671<span class="sd">======================  ===============  ====================================================</span>
672<span class="sd">  key                      sub-key        explanation</span>
673<span class="sd">======================  ===============  ====================================================</span>
674<span class="sd">Data                          \           A dict that contains the </span>
675<span class="sd">                                          reflection table,</span>
676<span class="sd">                                          as described in the</span>
677<span class="sd">                                          :ref:`Single Crystal Reflections</span>
678<span class="sd">                                          &lt;XtalRefl_table&gt;`</span>
679<span class="sd">                                          description.</span>
680
681<span class="sd">Instrument Parameters         \           A list containing two dicts where the possible</span>
682<span class="sd">                                          keys in each dict are listed below. The value</span>
683<span class="sd">                                          for most items is a list containing two values:</span>
684<span class="sd">                                          the initial value, the current value.</span>
685<span class="sd">                                          The first and second</span>
686<span class="sd">                                          values are floats unless otherwise noted.</span>
687<span class="sd">\                         Lam             Specifies a wavelength in Angstroms (two floats)</span>
688<span class="sd">\                         Type            Histogram type (two str values): </span>
689<span class="sd">                                           * &#39;SXC&#39; for constant wavelength x-ray</span>
690<span class="sd">                                           * &#39;SNC&#39; for constant wavelength neutron</span>
691<span class="sd">                                           * &#39;SNT&#39; for time of flight neutron</span>
692<span class="sd">\                         InstrName       A name for the instrument, used in preparing</span>
693<span class="sd">                                          a CIF (str).</span>
694
695<span class="sd">wtFactor                      \           A weighting factor to increase or decrease</span>
696<span class="sd">                                          the leverage of data in the histogram (float).</span>
697<span class="sd">                                          A value of 1.0 weights the data with their</span>
698<span class="sd">                                          standard uncertainties and a larger value</span>
699<span class="sd">                                          increases the weighting of the data (equivalent</span>
700<span class="sd">                                          to decreasing the uncertainties).</span>
701
702<span class="sd">hId                           \           The number assigned to the histogram when</span>
703<span class="sd">                                          the project is loaded or edited (can change)</span>
704<span class="sd">ranId                         \           A random number id for the histogram</span>
705<span class="sd">                                          that does not change</span>
706<span class="sd">======================  ===============  ====================================================</span>
707
708<span class="sd">Single Crystal Reflection Data Structure</span>
709<span class="sd">----------------------------------------</span>
710
711<span class="sd">.. _XtalRefl_table:</span>
712
713<span class="sd">.. index::</span>
714<span class="sd">   single: Single Crystal reflection object description</span>
715<span class="sd">   single: Data object descriptions; Single Crystal Reflections</span>
716<span class="sd">   </span>
717<span class="sd">For every single crystal a histogram, the ``&#39;Data&#39;`` item contains</span>
718<span class="sd">the structure factors as an np.array in item `&#39;RefList&#39;`.</span>
719<span class="sd">The columns in that array are documented below.</span>
720
721<span class="sd">==========  ====================================================</span>
722<span class="sd">  index         explanation</span>
723<span class="sd">==========  ====================================================</span>
724<span class="sd"> 0,1,2       h,k,l (float)</span>
725<span class="sd"> 3           multiplicity</span>
726<span class="sd"> 4           d-space, Angstrom</span>
727<span class="sd"> 5           :math:`F_{obs}^2`</span>
728<span class="sd"> 6           :math:`\sigma(F_{obs}^2)`</span>
729<span class="sd"> 7           :math:`F_{calc}^2`</span>
730<span class="sd"> 8           :math:`F_{obs}^2T`</span>
731<span class="sd"> 9           :math:`F_{calc}^2T`</span>
732<span class="sd"> 10          reflection phase, in degrees</span>
733<span class="sd"> 11          intensity correction for reflection, this times</span>
734<span class="sd">             :math:`F_{obs}^2` or :math:`F_{calc}^2`</span>
735<span class="sd">             gives Iobs or Icalc</span>
736<span class="sd">==========  ====================================================</span>
737
738<span class="sd">Image Data Structure</span>
739<span class="sd">--------------------</span>
740
741<span class="sd">.. _Image_table:</span>
742
743<span class="sd">.. index::</span>
744<span class="sd">   image: Image data object description</span>
745<span class="sd">   image: Image object descriptions</span>
746<span class="sd">   </span>
747<span class="sd">Every 2-dimensional image is stored in the GSAS-II data tree</span>
748<span class="sd">with a top-level entry named beginning with the string &quot;IMG &quot;. The</span>
749<span class="sd">image data are directly associated with that tree item and there </span>
750<span class="sd">are a series of children to that item. The routines :func:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`</span>
751<span class="sd">and :func:`GSASIIstrIO.GetUsedHistogramsAndPhases` will</span>
752<span class="sd">load this information into a dictionary where the child tree name is</span>
753<span class="sd">used as a key, and the information in the main entry is assigned</span>
754<span class="sd">a key of ``Data``, as outlined below.</span>
755
756<span class="sd">.. tabularcolumns:: |l|l|p{4in}|</span>
757
758<span class="sd">======================  ======================  ====================================================</span>
759<span class="sd">  key                      sub-key              explanation</span>
760<span class="sd">======================  ======================  ====================================================</span>
761<span class="sd">Comments                       \                Text strings extracted from the original image data </span>
762<span class="sd">                                                header or a metafile. These cannot be changed by  </span>
763<span class="sd">                                                the user; it may be empty.                                                </span>
764<span class="sd">Image Controls              azmthOff            (float) The offset to be applied to an azimuthal </span>
765<span class="sd">                                                value. Accomodates </span>
766<span class="sd">                                                detector orientations other than with the detector </span>
767<span class="sd">                                                X-axis</span>
768<span class="sd">                                                horizontal.</span>
769<span class="sd">\                           background image    (list:str,float) The name of a tree item (&quot;IMG ...&quot;) that is to be subtracted</span>
770<span class="sd">                                                during image integration multiplied by value. It must have the same size/shape as </span>
771<span class="sd">                                                the integrated image. NB: value &lt; 0 for subtraction.</span>
772<span class="sd">\                           calibrant           (str) The material used for determining the position/orientation</span>
773<span class="sd">                                                of the image. The data is obtained from :func:`ImageCalibrants` </span>
774<span class="sd">                                                and UserCalibrants.py (supplied by user).</span>
775<span class="sd">\                           calibdmin           (float) The minimum d-spacing used during the last calibration run.</span>
776<span class="sd">\                           calibskip           (int) The number of expected diffraction lines skipped during the last</span>
777<span class="sd">                                                calibration run.</span>
778<span class="sd">\                           center              (list:floats) The [X,Y] point in detector coordinates (mm) where the direct beam</span>
779<span class="sd">                                                strikes the detector plane as determined by calibration. This point </span>
780<span class="sd">                                                does not have to be within the limits of the detector boundaries. </span>
781<span class="sd">\                           centerAzm           (bool) If True then the azimuth reported for the integrated slice</span>
782<span class="sd">                                                of the image is at the center line otherwise it is at the leading edge.</span>
783<span class="sd">\                           color               (str) The name of the colormap used to display the image. Default = &#39;Paired&#39;.</span>
784<span class="sd">\                           cutoff              (float) The minimum value of I/Ib for a point selected in a diffraction ring for </span>
785<span class="sd">                                                calibration calculations. See pixLimit for details as how point is found.           </span>
786<span class="sd">\                           DetDepth            (float) Coefficient for penetration correction to distance; accounts for diffraction</span>
787<span class="sd">                                                ring offset at higher angles. Optionally determined by calibration.</span>
788<span class="sd">\                           DetDepthRef         (bool) If True then refine DetDepth during calibration/recalibration calculation.</span>
789<span class="sd">\                           distance            (float) The distance (mm) from sample to detector plane.</span>
790<span class="sd">\                           ellipses            (list:lists) Each object in ellipses is a list [center,phi,radii,color] where</span>
791<span class="sd">                                                center (list) is location (mm) of the ellipse center on the detector plane, phi is the </span>
792<span class="sd">                                                rotation of the ellipse minor axis from the x-axis, and radii are the minor &amp; major</span>
793<span class="sd">                                                radii of the ellipse. If radii[0] is negative then parameters describe a hyperbola. Color</span>
794<span class="sd">                                                is the selected drawing color (one of &#39;b&#39;, &#39;g&#39; ,&#39;r&#39;) for the ellipse/hyperbola.</span>
795<span class="sd">\                           edgemin             (float) Not used;  parameter in EdgeFinder code.</span>
796<span class="sd">\                           fullIntegrate       (bool) If True then integrate over full 360 deg azimuthal range.</span>
797<span class="sd">\                           GonioAngles         (list:floats) The &#39;Omega&#39;,&#39;Chi&#39;,&#39;Phi&#39; goniometer angles used for this image. </span>
798<span class="sd">                                                Required for texture calculations.</span>
799<span class="sd">\                           invert_x            (bool) If True display the image with the x-axis inverted.</span>
800<span class="sd">\                           invert_y            (bool) If True display the image with the y-axis inverted.</span>
801<span class="sd">\                           IOtth               (list:floats) The minimum and maximum 2-theta values to be used for integration.</span>
802<span class="sd">\                           LRazimuth           (list:floats) The minimum and maximum azimuth values to be used for integration.</span>
803<span class="sd">\                           Oblique             (list:float,bool) If True apply a detector absorption correction using the value to the</span>
804<span class="sd">                                                intensities obtained during integration.</span>
805<span class="sd">\                           outAzimuths         (int) The number of azimuth pie slices.</span>
806<span class="sd">\                           outChannels         (int) The number of 2-theta steps. </span>
807<span class="sd">\                           pixelSize           (list:ints) The X,Y dimensions (microns) of each pixel.</span>
808<span class="sd">\                           pixLimit            (int) A box in the image with 2*pixLimit+1 edges is searched to find the maximum.</span>
809<span class="sd">                                                This value (I) along with the minimum (Ib) in the box is reported by :func:`GSASIIimage.ImageLocalMax`</span>
810<span class="sd">                                                and subject to cutoff in :func:`GSASIIimage.makeRing`. </span>
811<span class="sd">                                                Locations are used to construct rings of points for calibration calcualtions.</span>
812<span class="sd">\                           PolaVal             (list:float,bool) If type=&#39;SASD&#39; and if True, apply polarization correction to intensities from </span>
813<span class="sd">                                                integration using value.</span>
814<span class="sd">\                           rings               (list:lists) Each entry is [X,Y,dsp] where X &amp; Y are lists of x,y coordinates around a </span>
815<span class="sd">                                                diffraction ring with the same d-spacing (dsp)</span>
816<span class="sd">\                           ring                (list) The x,y coordinates of the &gt;5 points on an inner ring </span>
817<span class="sd">                                                selected by the user,</span>
818<span class="sd">\                           Range               (list) The minimum &amp; maximum values of the image</span>
819<span class="sd">\                           rotation            (float) The angle between the x-axis and the vector about which the </span>
820<span class="sd">                                                detector is tilted. Constrained to -180 to 180 deg.     </span>
821<span class="sd">\                           SampleShape         (str) Currently only &#39;Cylinder&#39;. Sample shape for Debye-Scherrer experiments; used for absorption</span>
822<span class="sd">                                                calculations.</span>
823<span class="sd">\                           SampleAbs           (list: float,bool) Value of absorption coefficient for Debye-Scherrer experimnents, flag if True</span>
824<span class="sd">                                                to cause correction to be applied.</span>
825<span class="sd">\                           setDefault          (bool) If True the use the image controls values for all new images to be read. (might be removed)</span>
826<span class="sd">\                           setRings            (bool) If True then display all the selected x,y ring positions (vida supra rings) used in the calibration.            </span>
827<span class="sd">\                           showLines           (bool) If True then isplay the integration limits to be used.</span>
828<span class="sd">\                           size                (list:int) The number of pixels on the image x &amp; y axes</span>
829<span class="sd">\                           type                (str) One of &#39;PWDR&#39;, &#39;SASD&#39; or &#39;REFL&#39; for powder, small angle or reflectometry data, respectively.</span>
830<span class="sd">\                           tilt                (float) The angle the detector normal makes with the incident beam; range -90 to 90.</span>
831<span class="sd">\                           wavelength          (float) Tha radiation wavelength (Angstroms) as entered by the user (or someday obtained from the image header).</span>
832<span class="sd">                                                </span>
833<span class="sd">Masks                       Arcs                (list: lists) Each entry [2-theta,[azimuth[0],azimuth[1]],thickness] describes an arc mask</span>
834<span class="sd">                                                to be excluded from integration</span>
835<span class="sd">\                           Frames              (list:lists) Each entry describes the x,y points (3 or more - mm) that describe a frame outside</span>
836<span class="sd">                                                of which is excluded from recalibration and integration. Only one frame is allowed.</span>
837<span class="sd">\                           Points              (list:lists) Each entry [x,y,radius] (mm) describes an excluded spot on the image to be excluded</span>
838<span class="sd">                                                from integration.</span>
839<span class="sd">\                           Polygons            (list:lists) Each entry is a list of 3+ [x,y] points (mm) that describe a polygon on the image</span>
840<span class="sd">                                                to be excluded from integration.</span>
841<span class="sd">\                           Rings               (list: lists) Each entry [2-theta,thickness] describes a ring mask</span>
842<span class="sd">                                                to be excluded from integration.</span>
843<span class="sd">\                           Thresholds          (list:[tuple,list]) [(Imin,Imax),[Imin,Imax]] This gives lower and upper limits for points on the image to be included</span>
844<span class="sd">                                                in integrsation. The tuple is the image intensity limits and the list are those set by the user.    </span>
845<span class="sd">                                                </span>
846<span class="sd">Stress/Strain               Sample phi          (float) Sample rotation about vertical axis.</span>
847<span class="sd">\                           Sample z            (float) Sample translation from the calibration sample position (for Sample phi = 0)</span>
848<span class="sd">\                           strain              (list: 3x3 array of float) The strain tensor coefficients [[&#39; e11&#39;,&#39;e12&#39;,&#39;e13&#39;],[&#39; e21&#39;,&#39;e22&#39;,&#39;e23&#39;],[&#39; e31&#39;,&#39;e32&#39;,&#39;e33&#39;]].</span>
849<span class="sd">                                                These will be restricted by space group symmetry; result of strain fit refinement.</span>
850<span class="sd">\                           Type                (str) &#39;True&#39; or &#39;Conventional&#39;: The strain model used for the calculation.</span>
851<span class="sd">\                           d-zero              (list:dict) Each item is for a diffraction ring on the image; all items are from the same phase and are used to determine the strain tensor.</span>
852<span class="sd">                                                The dictionary items are:</span>
853<span class="sd">                                                &#39;Dset&#39;: (float) True d-spacing for the diffraction ring; entered by the user.</span>
854<span class="sd">                                                &#39;Dcalc&#39;: (float) d-spacing...</span>
855<span class="sd">                                                &#39;pixLimit&#39;: (int) Search range to find highest point on ring for each data point</span>
856<span class="sd">                                                &#39;cutoff&#39;: (float) I/Ib cutoff for searching.</span>
857<span class="sd">                                                &#39;ImxyObs&#39;: (list:lists) [[X],[Y]] observed points to be used for strain calculations.</span>
858<span class="sd">                                                &#39;ImxyCalc&#39;:(list:lists) [[X],[Y]] calculated points based on refined strain.                                           </span>
859<span class="sd">                                                </span>
860<span class="sd">======================  ======================  ====================================================</span>
861
862<span class="sd">Parameter Dictionary</span>
863<span class="sd">-------------------------</span>
864
865<span class="sd">.. _parmDict_table:</span>
866
867<span class="sd">.. index::</span>
868<span class="sd">   single: Parameter dictionary</span>
869
870<span class="sd">The parameter dictionary contains all of the variable parameters for the refinement.</span>
871<span class="sd">The dictionary keys are the name of the parameter (&lt;phase&gt;:&lt;hist&gt;:&lt;name&gt;:&lt;atom&gt;). </span>
872<span class="sd">It is prepared in two ways. When loaded from the tree</span>
873<span class="sd">(in :meth:`GSASII.GSASII.MakeLSParmDict` and</span>
874<span class="sd">:meth:`GSASIIIO.ExportBaseclass.loadParmDict`), </span>
875<span class="sd">the values are lists with two elements: ``[value, refine flag]``</span>
876
877<span class="sd">When loaded from the GPX file (in</span>
878<span class="sd">:func:`GSASIIstrMain.Refine` and :func:`GSASIIstrMain.SeqRefine`), the value in the</span>
879<span class="sd">dict is the actual parameter value (usually a float, but sometimes a </span>
880<span class="sd">letter or string flag value (such as I or A for iso/anisotropic). </span>
881
882
883<span class="sd">*Classes and routines*</span>
884<span class="sd">----------------------</span>
885
886<span class="sd">&#39;&#39;&#39;</span>
887<span class="kn">import</span> <span class="nn">random</span> <span class="kn">as</span> <span class="nn">ran</span>
888<span class="kn">import</span> <span class="nn">sys</span>
889<span class="kn">import</span> <span class="nn">GSASIIpath</span>
890<span class="kn">import</span> <span class="nn">GSASIImath</span> <span class="kn">as</span> <span class="nn">G2mth</span>
891
892<span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1181 $&quot;</span><span class="p">)</span>
893
894<span class="n">DefaultControls</span> <span class="o">=</span> <span class="p">{</span>
895    <span class="s">&#39;deriv type&#39;</span><span class="p">:</span><span class="s">&#39;analytic Hessian&#39;</span><span class="p">,</span>    <span class="c">#default controls</span>
896    <span class="s">&#39;min dM/M&#39;</span><span class="p">:</span><span class="mf">0.0001</span><span class="p">,</span><span class="s">&#39;shift factor&#39;</span><span class="p">:</span><span class="mf">1.</span><span class="p">,</span><span class="s">&#39;max cyc&#39;</span><span class="p">:</span><span class="mi">3</span><span class="p">,</span><span class="s">&#39;F**2&#39;</span><span class="p">:</span><span class="bp">True</span><span class="p">,</span>
897    <span class="s">&#39;minF/sig&#39;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
898    <span class="s">&#39;Author&#39;</span><span class="p">:</span><span class="s">&#39;no name&#39;</span><span class="p">,</span>
899    <span class="s">&#39;FreeVar1&#39;</span><span class="p">:</span><span class="s">&#39;Sample humidity (%)&#39;</span><span class="p">,</span>
900    <span class="s">&#39;FreeVar2&#39;</span><span class="p">:</span><span class="s">&#39;Sample voltage (V)&#39;</span><span class="p">,</span>
901    <span class="s">&#39;FreeVar3&#39;</span><span class="p">:</span><span class="s">&#39;Applied load (MN)&#39;</span><span class="p">,</span>
902    <span class="p">}</span>
903<span class="sd">&#39;&#39;&#39;Values to be used as defaults for the initial contents of the ``Controls``</span>
904<span class="sd">data tree item.</span>
905<span class="sd">&#39;&#39;&#39;</span>
906
907<div class="viewcode-block" id="MakeUniqueLabel"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.MakeUniqueLabel">[docs]</a><span class="k">def</span> <span class="nf">MakeUniqueLabel</span><span class="p">(</span><span class="n">lbl</span><span class="p">,</span><span class="n">labellist</span><span class="p">):</span>
908    <span class="sd">&#39;&#39;&#39;Make sure that every a label is unique against a list by adding</span>
909<span class="sd">    digits at the end until it is not found in list.</span>
910
911<span class="sd">    :param str lbl: the input label</span>
912<span class="sd">    :param list labellist: the labels that have already been encountered</span>
913<span class="sd">    :returns: lbl if not found in labellist or lbl with ``_1-9`` (or</span>
914<span class="sd">      ``_10-99``, etc.) appended at the end</span>
915<span class="sd">    &#39;&#39;&#39;</span>
916    <span class="n">lbl</span> <span class="o">=</span> <span class="n">lbl</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
917    <span class="k">if</span> <span class="ow">not</span> <span class="n">lbl</span><span class="p">:</span> <span class="c"># deal with a blank label</span>
918        <span class="n">lbl</span> <span class="o">=</span> <span class="s">&#39;_1&#39;</span>
919    <span class="k">if</span> <span class="n">lbl</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">labellist</span><span class="p">:</span>
920        <span class="n">labellist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lbl</span><span class="p">)</span>
921        <span class="k">return</span> <span class="n">lbl</span>
922    <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span>
923    <span class="n">prefix</span> <span class="o">=</span> <span class="n">lbl</span>
924    <span class="k">if</span> <span class="s">&#39;_&#39;</span> <span class="ow">in</span> <span class="n">lbl</span><span class="p">:</span>
925        <span class="n">prefix</span> <span class="o">=</span> <span class="n">lbl</span><span class="p">[:</span><span class="n">lbl</span><span class="o">.</span><span class="n">rfind</span><span class="p">(</span><span class="s">&#39;_&#39;</span><span class="p">)]</span>
926        <span class="n">suffix</span> <span class="o">=</span> <span class="n">lbl</span><span class="p">[</span><span class="n">lbl</span><span class="o">.</span><span class="n">rfind</span><span class="p">(</span><span class="s">&#39;_&#39;</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">:]</span>
927        <span class="k">try</span><span class="p">:</span>
928            <span class="n">i</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">suffix</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span>
929        <span class="k">except</span><span class="p">:</span> <span class="c"># suffix could not be parsed</span>
930            <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span>
931            <span class="n">prefix</span> <span class="o">=</span> <span class="n">lbl</span>
932    <span class="k">while</span> <span class="n">prefix</span><span class="o">+</span><span class="s">&#39;_&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="ow">in</span> <span class="n">labellist</span><span class="p">:</span>
933        <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
934    <span class="k">else</span><span class="p">:</span>
935        <span class="n">lbl</span> <span class="o">=</span> <span class="n">prefix</span><span class="o">+</span><span class="s">&#39;_&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
936        <span class="n">labellist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lbl</span><span class="p">)</span>
937    <span class="k">return</span> <span class="n">lbl</span>
938</div>
939<span class="n">PhaseIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
940<span class="sd">&#39;&#39;&#39;dict listing phase name and random Id keyed by sequential phase index as a str;</span>
941<span class="sd">best to access this using :func:`LookupPhaseName`</span>
942<span class="sd">&#39;&#39;&#39;</span>
943<span class="n">PhaseRanIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
944<span class="sd">&#39;&#39;&#39;dict listing phase sequential index keyed by phase random Id;</span>
945<span class="sd">best to access this using :func:`LookupPhaseId`</span>
946<span class="sd">&#39;&#39;&#39;</span>
947<span class="n">HistIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
948<span class="sd">&#39;&#39;&#39;dict listing histogram name and random Id, keyed by sequential histogram index as a str;</span>
949<span class="sd">best to access this using :func:`LookupHistName`</span>
950<span class="sd">&#39;&#39;&#39;</span>
951<span class="n">HistRanIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
952<span class="sd">&#39;&#39;&#39;dict listing histogram sequential index keyed by histogram random Id;</span>
953<span class="sd">best to access this using :func:`LookupHistId`</span>
954<span class="sd">&#39;&#39;&#39;</span>
955<span class="n">AtomIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
956<span class="sd">&#39;&#39;&#39;dict listing for each phase index as a str, the atom label and atom random Id,</span>
957<span class="sd">keyed by atom sequential index as a str;</span>
958<span class="sd">best to access this using :func:`LookupAtomLabel`</span>
959<span class="sd">&#39;&#39;&#39;</span>
960<span class="n">AtomRanIdLookup</span> <span class="o">=</span> <span class="p">{}</span>
961<span class="sd">&#39;&#39;&#39;dict listing for each phase the atom sequential index keyed by atom random Id;</span>
962<span class="sd">best to access this using :func:`LookupAtomId`</span>
963<span class="sd">&#39;&#39;&#39;</span>
964<span class="n">ShortPhaseNames</span> <span class="o">=</span> <span class="p">{}</span>
965<span class="sd">&#39;&#39;&#39;a dict containing a possibly shortened and when non-unique numbered</span>
966<span class="sd">version of the phase name. Keyed by the phase sequential index.</span>
967<span class="sd">&#39;&#39;&#39;</span>
968<span class="n">ShortHistNames</span> <span class="o">=</span> <span class="p">{}</span>
969<span class="sd">&#39;&#39;&#39;a dict containing a possibly shortened and when non-unique numbered</span>
970<span class="sd">version of the histogram name. Keyed by the histogram sequential index.</span>
971<span class="sd">&#39;&#39;&#39;</span>
972
973<span class="n">VarDesc</span> <span class="o">=</span> <span class="p">{}</span>
974<span class="sd">&#39;&#39;&#39; This dictionary lists descriptions for GSAS-II variables,</span>
975<span class="sd">as set in :func:`CompileVarDesc`. See that function for a description</span>
976<span class="sd">for how keys and values are written.</span>
977<span class="sd">&#39;&#39;&#39;</span>
978
979<span class="n">reVarDesc</span> <span class="o">=</span> <span class="p">{}</span>
980<span class="sd">&#39;&#39;&#39; This dictionary lists descriptions for GSAS-II variables with</span>
981<span class="sd">the same values as :attr:`VarDesc` except that keys have been compiled as</span>
982<span class="sd">regular expressions. Initialized in :func:`CompileVarDesc`.</span>
983<span class="sd">&#39;&#39;&#39;</span>
984
985<div class="viewcode-block" id="IndexAllIds"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.IndexAllIds">[docs]</a><span class="k">def</span> <span class="nf">IndexAllIds</span><span class="p">(</span><span class="n">Histograms</span><span class="p">,</span><span class="n">Phases</span><span class="p">):</span>
986    <span class="sd">&#39;&#39;&#39;Scan through the used phases &amp; histograms and create an index</span>
987<span class="sd">    to the random numbers of phases, histograms and atoms. While doing this,</span>
988<span class="sd">    confirm that assigned random numbers are unique -- just in case lightning</span>
989<span class="sd">    strikes twice in the same place.</span>
990
991<span class="sd">    Note: this code assumes that the atom random Id (ranId) is the last </span>
992<span class="sd">    element each atom record.</span>
993
994<span class="sd">    This is called in two places (only) :func:`GSASIIstrIO.GetUsedHistogramsAndPhases`</span>
995<span class="sd">    (which loads the histograms and phases from a GPX file) and</span>
996<span class="sd">    :meth:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`</span>
997<span class="sd">    (which loads the histograms and phases from the data tree.)</span>
998
999<span class="sd">    TODO: do we need a lookup for rigid body variables?</span>
1000<span class="sd">    &#39;&#39;&#39;</span>
1001    <span class="c"># process phases and atoms</span>
1002    <span class="n">PhaseIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1003    <span class="n">PhaseRanIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>   
1004    <span class="n">AtomIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1005    <span class="n">AtomRanIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1006    <span class="n">ShortPhaseNames</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1007    <span class="k">for</span> <span class="n">ph</span> <span class="ow">in</span> <span class="n">Phases</span><span class="p">:</span>
1008        <span class="n">cx</span><span class="p">,</span><span class="n">ct</span><span class="p">,</span><span class="n">cs</span><span class="p">,</span><span class="n">cia</span> <span class="o">=</span> <span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;General&#39;</span><span class="p">][</span><span class="s">&#39;AtomPtrs&#39;</span><span class="p">]</span>
1009        <span class="n">ranId</span> <span class="o">=</span> <span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;ranId&#39;</span><span class="p">]</span> 
1010        <span class="k">while</span> <span class="n">ranId</span> <span class="ow">in</span> <span class="n">PhaseRanIdLookup</span><span class="p">:</span>
1011            <span class="c"># Found duplicate random Id! note and reassign</span>
1012            <span class="k">print</span> <span class="p">(</span><span class="s">&quot;</span><span class="se">\n\n</span><span class="s">*** Phase &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">ph</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; has repeated ranId. Fixing.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span>
1013            <span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;ranId&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ranId</span> <span class="o">=</span> <span class="n">ran</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">sys</span><span class="o">.</span><span class="n">maxint</span><span class="p">)</span>
1014        <span class="n">pId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;pId&#39;</span><span class="p">])</span>
1015        <span class="n">PhaseIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">ph</span><span class="p">,</span><span class="n">ranId</span><span class="p">)</span>
1016        <span class="n">PhaseRanIdLookup</span><span class="p">[</span><span class="n">ranId</span><span class="p">]</span> <span class="o">=</span> <span class="n">pId</span>
1017        <span class="n">shortname</span> <span class="o">=</span> <span class="n">ph</span><span class="p">[:</span><span class="mi">10</span><span class="p">]</span>
1018        <span class="k">while</span> <span class="n">shortname</span> <span class="ow">in</span> <span class="n">ShortPhaseNames</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
1019            <span class="n">shortname</span> <span class="o">=</span> <span class="n">ph</span><span class="p">[:</span><span class="mi">8</span><span class="p">]</span> <span class="o">+</span> <span class="s">&#39; (&#39;</span><span class="o">+</span> <span class="n">pId</span> <span class="o">+</span> <span class="s">&#39;)&#39;</span>
1020        <span class="n">ShortPhaseNames</span><span class="p">[</span><span class="n">pId</span><span class="p">]</span> <span class="o">=</span> <span class="n">shortname</span>
1021        <span class="n">AtomIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
1022        <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
1023        <span class="k">for</span> <span class="n">iatm</span><span class="p">,</span><span class="n">at</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;Atoms&#39;</span><span class="p">]):</span>
1024            <span class="n">ranId</span> <span class="o">=</span> <span class="n">at</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
1025            <span class="k">while</span> <span class="n">ranId</span> <span class="ow">in</span> <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]:</span> <span class="c"># check for dups</span>
1026                <span class="k">print</span> <span class="p">(</span><span class="s">&quot;</span><span class="se">\n\n</span><span class="s">*** Phase &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">ph</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; atom &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">iatm</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; has repeated ranId. Fixing.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span>
1027                <span class="n">at</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">ranId</span> <span class="o">=</span> <span class="n">ran</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">sys</span><span class="o">.</span><span class="n">maxint</span><span class="p">)</span>
1028            <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">][</span><span class="n">ranId</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">iatm</span><span class="p">)</span>
1029            <span class="k">if</span> <span class="n">Phases</span><span class="p">[</span><span class="n">ph</span><span class="p">][</span><span class="s">&#39;General&#39;</span><span class="p">][</span><span class="s">&#39;Type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;macromolecular&#39;</span><span class="p">:</span>
1030                <span class="n">label</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">_</span><span class="si">%s</span><span class="s">_</span><span class="si">%s</span><span class="s">_</span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">at</span><span class="p">[</span><span class="n">ct</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">at</span><span class="p">[</span><span class="n">ct</span><span class="o">-</span><span class="mi">3</span><span class="p">],</span><span class="n">at</span><span class="p">[</span><span class="n">ct</span><span class="o">-</span><span class="mi">4</span><span class="p">],</span><span class="n">at</span><span class="p">[</span><span class="n">ct</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span>
1031            <span class="k">else</span><span class="p">:</span>
1032                <span class="n">label</span> <span class="o">=</span> <span class="n">at</span><span class="p">[</span><span class="n">ct</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
1033            <span class="n">AtomIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">iatm</span><span class="p">)]</span> <span class="o">=</span> <span class="p">(</span><span class="n">label</span><span class="p">,</span><span class="n">ranId</span><span class="p">)</span>
1034    <span class="c"># process histograms</span>
1035    <span class="n">HistIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1036    <span class="n">HistRanIdLookup</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1037    <span class="n">ShortHistNames</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
1038    <span class="k">for</span> <span class="n">hist</span> <span class="ow">in</span> <span class="n">Histograms</span><span class="p">:</span>
1039        <span class="n">ranId</span> <span class="o">=</span> <span class="n">Histograms</span><span class="p">[</span><span class="n">hist</span><span class="p">][</span><span class="s">&#39;ranId&#39;</span><span class="p">]</span>
1040        <span class="k">while</span> <span class="n">ranId</span> <span class="ow">in</span> <span class="n">HistRanIdLookup</span><span class="p">:</span>
1041            <span class="c"># Found duplicate random Id! note and reassign</span>
1042            <span class="k">print</span> <span class="p">(</span><span class="s">&quot;</span><span class="se">\n\n</span><span class="s">*** Histogram &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hist</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; has repeated ranId. Fixing.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">)</span>
1043            <span class="n">Histograms</span><span class="p">[</span><span class="n">hist</span><span class="p">][</span><span class="s">&#39;ranId&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ranId</span> <span class="o">=</span> <span class="n">ran</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">sys</span><span class="o">.</span><span class="n">maxint</span><span class="p">)</span>
1044        <span class="n">hId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">Histograms</span><span class="p">[</span><span class="n">hist</span><span class="p">][</span><span class="s">&#39;hId&#39;</span><span class="p">])</span>
1045        <span class="n">HistIdLookup</span><span class="p">[</span><span class="n">hId</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">hist</span><span class="p">,</span><span class="n">ranId</span><span class="p">)</span>
1046        <span class="n">HistRanIdLookup</span><span class="p">[</span><span class="n">ranId</span><span class="p">]</span> <span class="o">=</span> <span class="n">hId</span>
1047        <span class="n">shortname</span> <span class="o">=</span> <span class="n">hist</span><span class="p">[:</span><span class="mi">15</span><span class="p">]</span>
1048        <span class="k">while</span> <span class="n">shortname</span> <span class="ow">in</span> <span class="n">ShortHistNames</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
1049            <span class="n">shortname</span> <span class="o">=</span> <span class="n">hist</span><span class="p">[:</span><span class="mi">11</span><span class="p">]</span> <span class="o">+</span> <span class="s">&#39; (&#39;</span><span class="o">+</span> <span class="n">hId</span> <span class="o">+</span> <span class="s">&#39;)&#39;</span>
1050        <span class="n">ShortHistNames</span><span class="p">[</span><span class="n">hId</span><span class="p">]</span> <span class="o">=</span> <span class="n">shortname</span>
1051</div>
1052<div class="viewcode-block" id="LookupAtomId"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupAtomId">[docs]</a><span class="k">def</span> <span class="nf">LookupAtomId</span><span class="p">(</span><span class="n">pId</span><span class="p">,</span><span class="n">ranId</span><span class="p">):</span>
1053    <span class="sd">&#39;&#39;&#39;Get the atom number from a phase and atom random Id</span>
1054
1055<span class="sd">    :param int/str pId: the sequential number of the phase</span>
1056<span class="sd">    :param int ranId: the random Id assigned to an atom</span>
1057
1058<span class="sd">    :returns: the index number of the atom (str)</span>
1059<span class="sd">    &#39;&#39;&#39;</span>
1060    <span class="k">if</span> <span class="ow">not</span> <span class="n">AtomRanIdLookup</span><span class="p">:</span>
1061        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomId called before IndexAllIds was run&#39;</span>
1062    <span class="k">if</span> <span class="n">pId</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">pId</span> <span class="o">==</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
1063        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: phase is invalid (None or blank)&#39;</span>
1064    <span class="n">pId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">pId</span><span class="p">)</span>
1065    <span class="k">if</span> <span class="n">pId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">AtomRanIdLookup</span><span class="p">:</span>
1066        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomId does not have phase &#39;</span><span class="o">+</span><span class="n">pId</span>
1067    <span class="k">if</span> <span class="n">ranId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]:</span>
1068        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomId, ranId &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">ranId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39; not in AtomRanIdLookup[&#39;</span><span class="o">+</span><span class="n">pId</span><span class="o">+</span><span class="s">&#39;]&#39;</span>
1069    <span class="k">return</span> <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">][</span><span class="n">ranId</span><span class="p">]</span>
1070</div>
1071<div class="viewcode-block" id="LookupAtomLabel"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupAtomLabel">[docs]</a><span class="k">def</span> <span class="nf">LookupAtomLabel</span><span class="p">(</span><span class="n">pId</span><span class="p">,</span><span class="n">index</span><span class="p">):</span>
1072    <span class="sd">&#39;&#39;&#39;Get the atom label from a phase and atom index number</span>
1073
1074<span class="sd">    :param int/str pId: the sequential number of the phase</span>
1075<span class="sd">    :param int index: the index of the atom in the list of atoms</span>
1076
1077<span class="sd">    :returns: the label for the atom (str) and the random Id of the atom (int)</span>
1078<span class="sd">    &#39;&#39;&#39;</span>
1079    <span class="k">if</span> <span class="ow">not</span> <span class="n">AtomIdLookup</span><span class="p">:</span>
1080        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomLabel called before IndexAllIds was run&#39;</span>
1081    <span class="k">if</span> <span class="n">pId</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">pId</span> <span class="o">==</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
1082        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: phase is invalid (None or blank)&#39;</span>
1083    <span class="n">pId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">pId</span><span class="p">)</span>
1084    <span class="k">if</span> <span class="n">pId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">AtomIdLookup</span><span class="p">:</span>
1085        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomLabel does not have phase &#39;</span><span class="o">+</span><span class="n">pId</span>
1086    <span class="k">if</span> <span class="n">index</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">AtomIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]:</span>
1087        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupAtomLabel, ranId &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">index</span><span class="p">)</span><span class="o">+</span><span class="s">&#39; not in AtomRanIdLookup[&#39;</span><span class="o">+</span><span class="n">pId</span><span class="o">+</span><span class="s">&#39;]&#39;</span>
1088    <span class="k">return</span> <span class="n">AtomIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">][</span><span class="n">index</span><span class="p">]</span>
1089</div>
1090<div class="viewcode-block" id="LookupPhaseId"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupPhaseId">[docs]</a><span class="k">def</span> <span class="nf">LookupPhaseId</span><span class="p">(</span><span class="n">ranId</span><span class="p">):</span>
1091    <span class="sd">&#39;&#39;&#39;Get the phase number and name from a phase random Id</span>
1092
1093<span class="sd">    :param int ranId: the random Id assigned to a phase</span>
1094<span class="sd">    :returns: the sequential Id (pId) number for the phase (str)</span>
1095<span class="sd">    &#39;&#39;&#39;</span>
1096    <span class="k">if</span> <span class="ow">not</span> <span class="n">PhaseRanIdLookup</span><span class="p">:</span>
1097        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupPhaseId called before IndexAllIds was run&#39;</span>
1098    <span class="k">if</span> <span class="n">ranId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">PhaseRanIdLookup</span><span class="p">:</span>
1099        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupPhaseId does not have ranId &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">ranId</span><span class="p">)</span>
1100    <span class="k">return</span> <span class="n">PhaseRanIdLookup</span><span class="p">[</span><span class="n">ranId</span><span class="p">]</span>
1101</div>
1102<div class="viewcode-block" id="LookupPhaseName"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupPhaseName">[docs]</a><span class="k">def</span> <span class="nf">LookupPhaseName</span><span class="p">(</span><span class="n">pId</span><span class="p">):</span>
1103    <span class="sd">&#39;&#39;&#39;Get the phase number and name from a phase Id</span>
1104
1105<span class="sd">    :param int/str pId: the sequential assigned to a phase</span>
1106<span class="sd">    :returns:  (phase,ranId) where phase is the name of the phase (str)</span>
1107<span class="sd">      and ranId is the random # id for the phase (int)</span>
1108<span class="sd">    &#39;&#39;&#39;</span>
1109    <span class="k">if</span> <span class="ow">not</span> <span class="n">PhaseIdLookup</span><span class="p">:</span>
1110        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupPhaseName called before IndexAllIds was run&#39;</span>
1111    <span class="k">if</span> <span class="n">pId</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">pId</span> <span class="o">==</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
1112        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: phase is invalid (None or blank)&#39;</span>
1113    <span class="n">pId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">pId</span><span class="p">)</span>
1114    <span class="k">if</span> <span class="n">pId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">PhaseIdLookup</span><span class="p">:</span>
1115        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupPhaseName does not have index &#39;</span><span class="o">+</span><span class="n">pId</span>
1116    <span class="k">return</span> <span class="n">PhaseIdLookup</span><span class="p">[</span><span class="n">pId</span><span class="p">]</span>
1117</div>
1118<div class="viewcode-block" id="LookupHistId"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupHistId">[docs]</a><span class="k">def</span> <span class="nf">LookupHistId</span><span class="p">(</span><span class="n">ranId</span><span class="p">):</span>
1119    <span class="sd">&#39;&#39;&#39;Get the histogram number and name from a histogram random Id</span>
1120
1121<span class="sd">    :param int ranId: the random Id assigned to a histogram</span>
1122<span class="sd">    :returns: the sequential Id (hId) number for the histogram (str)</span>
1123<span class="sd">    &#39;&#39;&#39;</span>
1124    <span class="k">if</span> <span class="ow">not</span> <span class="n">HistRanIdLookup</span><span class="p">:</span>
1125        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupHistId called before IndexAllIds was run&#39;</span>
1126    <span class="k">if</span> <span class="n">ranId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">HistRanIdLookup</span><span class="p">:</span>
1127        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupHistId does not have ranId &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">ranId</span><span class="p">)</span>
1128    <span class="k">return</span> <span class="n">HistRanIdLookup</span><span class="p">[</span><span class="n">ranId</span><span class="p">]</span>
1129</div>
1130<div class="viewcode-block" id="LookupHistName"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.LookupHistName">[docs]</a><span class="k">def</span> <span class="nf">LookupHistName</span><span class="p">(</span><span class="n">hId</span><span class="p">):</span>
1131    <span class="sd">&#39;&#39;&#39;Get the histogram number and name from a histogram Id</span>
1132
1133<span class="sd">    :param int/str hId: the sequential assigned to a histogram</span>
1134<span class="sd">    :returns:  (hist,ranId) where hist is the name of the histogram (str)</span>
1135<span class="sd">      and ranId is the random # id for the histogram (int)</span>
1136<span class="sd">    &#39;&#39;&#39;</span>
1137    <span class="k">if</span> <span class="ow">not</span> <span class="n">HistIdLookup</span><span class="p">:</span>
1138        <span class="k">raise</span> <span class="ne">Exception</span><span class="p">,</span><span class="s">&#39;Error: LookupHistName called before IndexAllIds was run&#39;</span>
1139    <span class="k">if</span> <span class="n">hId</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">hId</span> <span class="o">==</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
1140        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: histogram is invalid (None or blank)&#39;</span>
1141    <span class="n">hId</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span>
1142    <span class="k">if</span> <span class="n">hId</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">HistIdLookup</span><span class="p">:</span>
1143        <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">,</span><span class="s">&#39;Error: LookupHistName does not have index &#39;</span><span class="o">+</span><span class="n">hId</span>
1144    <span class="k">return</span> <span class="n">HistIdLookup</span><span class="p">[</span><span class="n">hId</span><span class="p">]</span>
1145</div>
1146<div class="viewcode-block" id="fmtVarDescr"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.fmtVarDescr">[docs]</a><span class="k">def</span> <span class="nf">fmtVarDescr</span><span class="p">(</span><span class="n">varname</span><span class="p">):</span>
1147    <span class="sd">&#39;&#39;&#39;Return a string with a more complete description for a GSAS-II variable </span>
1148
1149<span class="sd">    TODO: This will not handle rigid body parameters yet</span>
1150
1151<span class="sd">    :param str name: A full G2 variable name with 2 or 3</span>
1152<span class="sd">       colons (&lt;p&gt;:&lt;h&gt;:name[:&lt;a&gt;])</span>
1153<span class="sd">       </span>
1154<span class="sd">    :returns: a string with the description</span>
1155<span class="sd">    &#39;&#39;&#39;</span>
1156   
1157    <span class="n">l</span> <span class="o">=</span> <span class="n">getVarDescr</span><span class="p">(</span><span class="n">varname</span><span class="p">)</span>
1158    <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="p">:</span>
1159        <span class="k">return</span> <span class="s">&quot;invalid variable name (&quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">varname</span><span class="p">)</span><span class="o">+</span><span class="s">&quot;)!&quot;</span>
1160
1161    <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="p">[</span><span class="mi">4</span><span class="p">]:</span>
1162        <span class="n">l</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="s">&quot;(variable needs a definition!)&quot;</span>
1163
1164    <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>
1165    <span class="k">if</span> <span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> <span class="c"># HAP: keep short</span>
1166        <span class="n">lbl</span> <span class="o">=</span> <span class="n">ShortPhaseNames</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="s">&#39;? #&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
1167        <span class="n">hlbl</span> <span class="o">=</span> <span class="n">ShortHistNames</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="s">&#39;? #&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
1168        <span class="k">if</span> <span class="n">hlbl</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;HKLF&#39;</span><span class="p">:</span>
1169            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Xtl=&#39;</span><span class="o">+</span><span class="n">hlbl</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span>
1170        <span class="k">elif</span> <span class="n">hlbl</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;PWDR&#39;</span><span class="p">:</span>
1171            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Pwd=&#39;</span><span class="o">+</span><span class="n">hlbl</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span>
1172        <span class="k">else</span><span class="p">:</span>
1173            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Hist=&#39;</span><span class="o">+</span><span class="n">hlbl</span>
1174        <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;Ph=&quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">lbl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; * &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hlbl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot;: &quot;</span>
1175    <span class="k">elif</span> <span class="n">l</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> <span class="c"># atom parameter, </span>
1176        <span class="n">lbl</span> <span class="o">=</span> <span class="n">ShortPhaseNames</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="s">&#39;phase?&#39;</span><span class="p">)</span>
1177        <span class="k">try</span><span class="p">:</span>
1178            <span class="n">albl</span> <span class="o">=</span> <span class="n">LookupAtomLabel</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">l</span><span class="p">[</span><span class="mi">3</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
1179        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
1180            <span class="n">albl</span> <span class="o">=</span> <span class="s">&#39;Atom?&#39;</span>
1181        <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;Atom &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">albl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot; in &quot;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">lbl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot;: &quot;</span>
1182    <span class="k">elif</span> <span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
1183        <span class="n">lbl</span> <span class="o">=</span> <span class="n">ShortPhaseNames</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="s">&#39;phase?&#39;</span><span class="p">)</span>
1184        <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="n">lbl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot;: &quot;</span>
1185    <span class="k">elif</span> <span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
1186        <span class="n">hlbl</span> <span class="o">=</span> <span class="n">ShortHistNames</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="s">&#39;? #&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
1187        <span class="k">if</span> <span class="n">hlbl</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;HKLF&#39;</span><span class="p">:</span>
1188            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Xtl=&#39;</span><span class="o">+</span><span class="n">hlbl</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span>
1189        <span class="k">elif</span> <span class="n">hlbl</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;PWDR&#39;</span><span class="p">:</span>
1190            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Pwd=&#39;</span><span class="o">+</span><span class="n">hlbl</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span>
1191        <span class="k">else</span><span class="p">:</span>
1192            <span class="n">hlbl</span> <span class="o">=</span> <span class="s">&#39;Hist=&#39;</span><span class="o">+</span><span class="n">hlbl</span>
1193        <span class="n">s</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">hlbl</span><span class="p">)</span><span class="o">+</span><span class="s">&quot;: &quot;</span>   
1194    <span class="k">if</span> <span class="ow">not</span> <span class="n">s</span><span class="p">:</span>
1195        <span class="n">s</span> <span class="o">=</span> <span class="s">&#39;Global: &#39;</span>
1196    <span class="n">s</span> <span class="o">+=</span> <span class="n">l</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>
1197    <span class="k">return</span> <span class="n">s</span>
1198</div>
1199<div class="viewcode-block" id="getVarDescr"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.getVarDescr">[docs]</a><span class="k">def</span> <span class="nf">getVarDescr</span><span class="p">(</span><span class="n">varname</span><span class="p">):</span>
1200    <span class="sd">&#39;&#39;&#39;Return a short description for a GSAS-II variable </span>
1201
1202<span class="sd">    :param str name: A full G2 variable name with 2 or 3</span>
1203<span class="sd">       colons (&lt;p&gt;:&lt;h&gt;:name[:&lt;a&gt;])</span>
1204<span class="sd">      </span>
1205<span class="sd">    :returns: a five element list as [`p`,`h`,`name`,`a`,`description`],</span>
1206<span class="sd">      where `p`, `h`, `a` are str values or `None`, for the phase number,</span>
1207<span class="sd">      the histogram number and the atom number; `name` will always be</span>
1208<span class="sd">      an str; and `description` is str or `None`.</span>
1209<span class="sd">      If the variable name is incorrectly formed (for example, wrong</span>
1210<span class="sd">      number of colons), `None` is returned instead of a list.</span>
1211<span class="sd">    &#39;&#39;&#39;</span>
1212    <span class="n">l</span> <span class="o">=</span> <span class="n">varname</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;:&#39;</span><span class="p">)</span>
1213    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
1214        <span class="n">l</span> <span class="o">+=</span> <span class="p">[</span><span class="bp">None</span><span class="p">]</span>
1215    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">4</span><span class="p">:</span>
1216        <span class="k">return</span> <span class="bp">None</span>
1217    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">):</span>
1218        <span class="k">if</span> <span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="s">&quot;&quot;</span><span class="p">:</span>
1219            <span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="bp">None</span>
1220    <span class="n">l</span> <span class="o">+=</span> <span class="p">[</span><span class="n">getDescr</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="mi">2</span><span class="p">])]</span>
1221    <span class="k">return</span> <span class="n">l</span>
1222    </div>
1223<div class="viewcode-block" id="CompileVarDesc"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.CompileVarDesc">[docs]</a><span class="k">def</span> <span class="nf">CompileVarDesc</span><span class="p">():</span>
1224    <span class="sd">&#39;&#39;&#39;Set the values in the variable description lookup table (:attr:`VarDesc`)</span>
1225<span class="sd">    into :attr:`reVarDesc`. This is called in :func:`getDescr` so the initialization</span>
1226<span class="sd">    is always done before use.</span>
1227
1228<span class="sd">    Note that keys may contain regular expressions, where &#39;[xyz]&#39;</span>
1229<span class="sd">    matches &#39;x&#39; &#39;y&#39; or &#39;z&#39; (equivalently &#39;[x-z]&#39; describes this as range of values).</span>
1230<span class="sd">    &#39;.*&#39; matches any string. For example::</span>
1231
1232<span class="sd">    &#39;AUiso&#39;:&#39;Atomic isotropic displacement parameter&#39;,</span>
1233
1234<span class="sd">    will match variable ``&#39;p::AUiso:a&#39;``.</span>
1235<span class="sd">    If parentheses are used in the key, the contents of those parentheses can be</span>
1236<span class="sd">    used in the value, such as::</span>
1237
1238<span class="sd">    &#39;AU([123][123])&#39;:&#39;Atomic anisotropic displacement parameter U\\1&#39;,</span>
1239
1240<span class="sd">    will match ``AU11``, ``AU23``,.. and `U11`, `U23` etc will be displayed</span>
1241<span class="sd">    in the value when used.</span>
1242<span class="sd">    </span>
1243<span class="sd">    &#39;&#39;&#39;</span>
1244    <span class="kn">import</span> <span class="nn">re</span>
1245    <span class="k">if</span> <span class="n">reVarDesc</span><span class="p">:</span> <span class="k">return</span> <span class="c"># already done</span>
1246    <span class="k">for</span> <span class="n">key</span><span class="p">,</span><span class="n">value</span> <span class="ow">in</span> <span class="p">{</span>
1247        <span class="c"># Phase vars (p::&lt;var&gt;)</span>
1248        <span class="s">&#39;A([0-5])&#39;</span> <span class="p">:</span> <span class="s">&#39;Reciprocal metric tensor component </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1249        <span class="s">&#39;Vol&#39;</span> <span class="p">:</span> <span class="s">&#39;Unit cell volume????&#39;</span><span class="p">,</span>
1250        <span class="c"># Atom vars (p::&lt;var&gt;:a)</span>
1251        <span class="s">&#39;dA([xyz])&#39;</span> <span class="p">:</span> <span class="s">&#39;change to atomic position </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1252        <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>
1253        <span class="s">&#39;AU([123][123])&#39;</span><span class="p">:</span><span class="s">&#39;Atomic anisotropic displacement parameter U</span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1254        <span class="s">&#39;Afrac&#39;</span><span class="p">:</span> <span class="s">&#39;Atomic occupancy parameter&#39;</span><span class="p">,</span>
1255        <span class="c"># Hist &amp; Phase (HAP) vars (p:h:&lt;var&gt;)</span>
1256        <span class="s">&#39;Bab([AU])&#39;</span><span class="p">:</span> <span class="s">&#39;Babinet solvent scattering coef. </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1257        <span class="s">&#39;D([123][123])&#39;</span> <span class="p">:</span> <span class="s">&#39;Anisotropic strain coef. </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1258        <span class="s">&#39;Extinction&#39;</span> <span class="p">:</span> <span class="s">&#39;Extinction coef.&#39;</span><span class="p">,</span>
1259        <span class="s">&#39;MD&#39;</span> <span class="p">:</span> <span class="s">&#39;March-Dollase coef.&#39;</span><span class="p">,</span>
1260        <span class="s">&#39;Mustrain;.*&#39;</span> <span class="p">:</span> <span class="s">&#39;Microstrain coef.&#39;</span><span class="p">,</span>
1261        <span class="s">&#39;Scale&#39;</span> <span class="p">:</span> <span class="s">&#39;Phase scale factor&#39;</span><span class="p">,</span>
1262        <span class="s">&#39;Size;.*&#39;</span> <span class="p">:</span> <span class="s">&#39;Crystallite size value&#39;</span><span class="p">,</span>
1263        <span class="s">&#39;eA&#39;</span> <span class="p">:</span> <span class="s">&#39;?&#39;</span><span class="p">,</span>
1264        <span class="c">#Histogram vars (:h:&lt;var&gt;)</span>
1265        <span class="s">&#39;Absorption&#39;</span> <span class="p">:</span> <span class="s">&#39;Absorption coef.&#39;</span><span class="p">,</span>
1266        <span class="s">&#39;Displace([XY])&#39;</span> <span class="p">:</span> <span class="s">&#39;Debye-Scherrer sample displacement </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1267        <span class="s">&#39;Lam&#39;</span> <span class="p">:</span> <span class="s">&#39;Wavelength&#39;</span><span class="p">,</span>
1268        <span class="s">&#39;Polariz\.&#39;</span> <span class="p">:</span> <span class="s">&#39;Polarization correction&#39;</span><span class="p">,</span>
1269        <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>
1270        <span class="s">&#39;Scale&#39;</span> <span class="p">:</span> <span class="s">&#39;Histogram scale factor&#39;</span><span class="p">,</span>
1271        <span class="s">&#39;([UVW])&#39;</span> <span class="p">:</span> <span class="s">&#39;Gaussian instrument broadening </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1272        <span class="s">&#39;([XY])&#39;</span> <span class="p">:</span> <span class="s">&#39;Cauchy instrument broadening </span><span class="se">\\</span><span class="s">1&#39;</span><span class="p">,</span>
1273        <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>
1274        <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>
1275        <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>
1276        <span class="c"># Global vars (::&lt;var&gt;)</span>
1277        <span class="p">}</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
1278        <span class="n">VarDesc</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
1279        <span class="n">reVarDesc</span><span class="p">[</span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">key</span><span class="p">)]</span> <span class="o">=</span> <span class="n">value</span>
1280</div>
1281<div class="viewcode-block" id="getDescr"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.getDescr">[docs]</a><span class="k">def</span> <span class="nf">getDescr</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
1282    <span class="sd">&#39;&#39;&#39;Return a short description for a GSAS-II variable </span>
1283
1284<span class="sd">    :param str name: The descriptive part of the variable name without colons (:)</span>
1285<span class="sd">      </span>
1286<span class="sd">    :returns: a short description or None if not found</span>
1287<span class="sd">    &#39;&#39;&#39;</span>
1288
1289    <span class="n">CompileVarDesc</span><span class="p">()</span> <span class="c"># compile the regular expressions, if needed</span>
1290    <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">reVarDesc</span><span class="p">:</span>
1291        <span class="n">m</span> <span class="o">=</span> <span class="n">key</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
1292        <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
1293            <span class="k">return</span> <span class="n">m</span><span class="o">.</span><span class="n">expand</span><span class="p">(</span><span class="n">reVarDesc</span><span class="p">[</span><span class="n">key</span><span class="p">])</span>
1294    <span class="k">return</span> <span class="bp">None</span>
1295</div>
1296<span class="k">def</span> <span class="nf">_lookup</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span><span class="n">key</span><span class="p">):</span>
1297    <span class="sd">&#39;&#39;&#39;Lookup a key in a dictionary, where None returns an empty string</span>
1298<span class="sd">    but an unmatched key returns a question mark. Used in :class:`G2VarObj`</span>
1299<span class="sd">    &#39;&#39;&#39;</span>
1300    <span class="k">if</span> <span class="n">key</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
1301        <span class="k">return</span> <span class="s">&quot;&quot;</span>
1302    <span class="k">else</span><span class="p">:</span>
1303        <span class="k">return</span> <span class="n">dic</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">,</span><span class="s">&#39;?&#39;</span><span class="p">)</span>
1304
1305<div class="viewcode-block" id="G2VarObj"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.G2VarObj">[docs]</a><span class="k">class</span> <span class="nc">G2VarObj</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
1306    <span class="sd">&#39;&#39;&#39;Defines a GSAS-II variable either using the phase/atom/histogram</span>
1307<span class="sd">    unique Id numbers or using a character string that specifies</span>
1308<span class="sd">    variables by phase/atom/histogram number (which can change).</span>
1309<span class="sd">    Note that :func:`LoadID` should be used to (re)load the current Ids</span>
1310<span class="sd">    before creating or later using the G2VarObj object.</span>
1311
1312<span class="sd">    A :class:`G2VarObj` object can be created with a single parameter:</span>
1313<span class="sd">    </span>
1314<span class="sd">    :param str/tuple varname: a single value can be used to create a :class:`G2VarObj`</span>
1315<span class="sd">      object. If a string, it must be of form &quot;p:h:var&quot; or &quot;p:h:var:a&quot;, where</span>
1316
1317<span class="sd">     * p is the phase number (which may be left blank); </span>
1318<span class="sd">     * h is the histogram number (which may be left blank); </span>
1319<span class="sd">     * a is the atom number (which may be left blank in which case the third colon is omitted).</span>
1320
1321<span class="sd">      Alternately a single tuple of form (Phase,Histogram,VarName,AtomID) can be used, where</span>
1322<span class="sd">      Phase, Histogram, and AtomID are None or are ranId values and VarName is a string.     </span>
1323
1324<span class="sd">    If four positional arguments are supplied, they are:</span>
1325
1326<span class="sd">    :param str/int phasenum: The number for the phase</span>
1327<span class="sd">    :param str/int histnum: The number for the histogram</span>
1328<span class="sd">    :param str varname: a single value can be used to create a :class:`G2VarObj`</span>
1329<span class="sd">    :param str/int atomnum: The number for the atom</span>
1330<span class="sd">    </span>
1331<span class="sd">    &#39;&#39;&#39;</span>
1332    <span class="n">IDdict</span> <span class="o">=</span> <span class="p">{}</span>
1333    <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>
1334    <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>
1335    <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>
1336    <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>
1337        <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="bp">None</span>
1338        <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="bp">None</span>
1339        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
1340        <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="bp">None</span>
1341        <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="ow">and</span> <span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">is</span> <span class="nb">list</span> <span class="ow">or</span> <span class="nb">type</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">is</span> <span class="nb">tuple</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</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="mi">4</span><span class="p">:</span>
1342            <span class="bp">self</span><span class="o">.</span><span class="n">phase</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="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span><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">0</span><span class="p">]</span>
1343        <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">1</span> <span class="ow">and</span> <span class="s">&#39;:&#39;</span> <span class="ow">in</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>           
1344            <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>
1345            <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="n">PhaseIdLookup</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">lst</span><span class="p">[</span><span class="mi">0</span><span class="p">],[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1346            <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="n">HistIdLookup</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">lst</span><span class="p">[</span><span class="mi">1</span><span class="p">],[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1347            <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>
1348            <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>
1349                <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="n">AtomIdLookup</span><span class="p">[</span><span class="n">lst</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">lst</span><span class="p">[</span><span class="mi">3</span><span class="p">],[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1350        <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>
1351            <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">=</span> <span class="n">PhaseIdLookup</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]),[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1352            <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">=</span> <span class="n">HistIdLookup</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]),[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1353            <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>
1354            <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">=</span> <span class="n">AtomIdLookup</span><span class="p">[</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">get</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">3</span><span class="p">]),[</span><span class="bp">None</span><span class="p">,</span><span class="bp">None</span><span class="p">])[</span><span class="mi">1</span><span class="p">]</span>
1355        <span class="k">else</span><span class="p">:</span>
1356            <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>
1357
1358        <span class="c">#print &quot;DEBUG: created &quot;,self.phase,self.histogram,self.name,self.atom</span>
1359
1360    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1361        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">varname</span><span class="p">()</span>
1362
1363<div class="viewcode-block" id="G2VarObj.varname"><a class="viewcode-back" href="../GSASIIobj.html#GSASIIobj.G2VarObj.varname">[docs]</a>    <span class="k">def</span> <span class="nf">varname</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1364        <span class="sd">&#39;&#39;&#39;Formats the GSAS-II variable name as a &quot;traditional&quot; GSAS-II variable </span>
1365<span class="sd">        string (p:h:&lt;var&gt;:a) or (p:h:&lt;var&gt;)</span>
1366
1367<span class="sd">        :returns: the variable name as a str</span>
1368<span class="sd">        &#39;&#39;&#39;</span>
1369        <span class="n">ph</span> <span class="o">=</span> <span class="n">_lookup</span><span class="p">(</span><span class="n">PhaseRanIdLookup</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">phase</span><span class="p">)</span>
1370        <span class="n">hist</span> <span class="o">=</span> <span class="n">_lookup</span><span class="p">(</span><span class="n">HistRanIdLookup</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">histogram</span><span class="p">)</span>
1371        <span class="n">s</span> <span class="o">=</span> <span class="p">(</span><span class="n">ph</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">hist</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> 
1372             <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>
1373        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">atom</span><span class="p">:</span>
1374            <span class="k">if</span> <span class="n">ph</span> <span class="ow">in</span> <span class="n">AtomRanIdLookup</span><span class="p">:</span>
1375                <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">ph</span><span class="p">]</span><span class="o">.</span><span class="n">get</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="s">&#39;?&#39;</span><span class="p">)</span>
1376            <span class="k">else</span><span class="p">:</span>
1377                <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;:?&quot;</span>
1378        <span class="k">return</span> <span class="n">s</span>
1379    </div>
1380    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1381        <span class="sd">&#39;&#39;&#39;Return the detailed contents of the object</span>
1382<span class="sd">        &#39;&#39;&#39;</span>
1383        <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;&lt;&quot;</span>
1384        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
1385            <span class="n">ph</span> <span class="o">=</span>  <span class="n">_lookup</span><span class="p">(</span><span class="n">PhaseRanIdLookup</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">phase</span><span class="p">)</span>
1386            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Phase: rId=&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><span class="o">+</span> <span class="n">ph</span> <span class="o">+</span> <span class="s">&quot;); &quot;</span>
1387        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
1388            <span class="n">hist</span> <span class="o">=</span> <span class="n">_lookup</span><span class="p">(</span><span class="n">HistRanIdLookup</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">histogram</span><span class="p">)</span>
1389            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Histogram: rId=&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><span class="o">+</span> <span class="n">hist</span> <span class="o">+</span> <span class="s">&quot;); &quot;</span>
1390        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
1391            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;Atom rId=&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>
1392            <span class="k">if</span> <span class="n">ph</span> <span class="ow">in</span> <span class="n">AtomRanIdLookup</span><span class="p">:</span>
1393                <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; (#&quot;</span> <span class="o">+</span> <span class="n">AtomRanIdLookup</span><span class="p">[</span><span class="n">ph</span><span class="p">]</span><span class="o">.</span><span class="n">get</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="s">&#39;?&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;); &quot;</span>
1394            <span class="k">else</span><span class="p">:</span>
1395                <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; (#? -- not found!); &quot;</span>
1396        <span class="n">s</span> <span class="o">+=</span> <span class="s">&#39;Variable name=&quot;&#39;</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">&#39;&quot;&gt;&#39;</span>
1397        <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">varname</span><span class="p">()</span><span class="o">+</span><span class="s">&quot;)&quot;</span>
1398
1399    <span class="k">def</span> <span class="nf">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
1400        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1401            <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">phase</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">phase</span> <span class="ow">and</span>
1402                    <span class="bp">self</span><span class="o">.</span><span class="n">histogram</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">histogram</span> <span class="ow">and</span>
1403                    <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">name</span> <span class="ow">and</span>
1404                    <span class="bp">self</span><span class="o">.</span><span class="n">atom</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">atom</span><span class="p">)</span>
1405        <span class="k">return</span> <span class="bp">False</span>
1406
1407    <span class="k">def</span> <span class="nf">_show</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
1408        <span class="s">&#39;For testing, shows the current lookup table&#39;</span>
1409        <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>
1410        <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>
1411        <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>
1412</pre></div></div>
1413
1414          </div>
1415        </div>
1416      </div>
1417      <div class="sphinxsidebar">
1418        <div class="sphinxsidebarwrapper">
1419            <p class="logo"><a href="../index.html">
1420              <img class="logo" src="../_static/G2_html_logo.png" alt="Logo"/>
1421            </a></p>
1422<div id="searchbox" style="display: none">
1423  <h3>Quick search</h3>
1424    <form class="search" action="../search.html" method="get">
1425      <input type="text" name="q" />
1426      <input type="submit" value="Go" />
1427      <input type="hidden" name="check_keywords" value="yes" />
1428      <input type="hidden" name="area" value="default" />
1429    </form>
1430    <p class="searchtip" style="font-size: 90%">
1431    Enter search terms or a module, class or function name.
1432    </p>
1433</div>
1434<script type="text/javascript">$('#searchbox').show(0);</script>
1435        </div>
1436      </div>
1437      <div class="clearer"></div>
1438    </div>
1439    <div class="related">
1440      <h3>Navigation</h3>
1441      <ul>
1442        <li class="right" style="margin-right: 10px">
1443          <a href="../genindex.html" title="General Index"
1444             >index</a></li>
1445        <li class="right" >
1446          <a href="../py-modindex.html" title="Python Module Index"
1447             >modules</a> |</li>
1448        <li><a href="../index.html">GSAS-II 0.2.0 documentation</a> &raquo;</li>
1449          <li><a href="index.html" >Module code</a> &raquo;</li> 
1450      </ul>
1451    </div>
1452    <div class="footer">
1453        &copy; Copyright 2013, Von Dreele and Toby for Argonne National Laboratory.
1454      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
1455    </div>
1456  </body>
1457</html>
Note: See TracBrowser for help on using the repository browser.