Ignore:
Timestamp:
Apr 23, 2014 5:11:13 PM (8 years ago)
Author:
toby
Message:

Start on parametric fitting; Time for new manual; fix minor formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sphinxdocs/build/html/_modules/GSASIIpwdGUI.html

    r1183 r1298  
    5454<span class="c">#GSASIIpwdGUI - powder data display routines</span>
    5555<span class="c">########### SVN repository information ###################</span>
    56 <span class="c"># $Date: 2013-12-19 13:34:54 -0600 (Thu, 19 Dec 2013) $</span>
     56<span class="c"># $Date: 2014-04-22 09:37:51 -0500 (Tue, 22 Apr 2014) $</span>
    5757<span class="c"># $Author: vondreele $</span>
    58 <span class="c"># $Revision: 1177 $</span>
     58<span class="c"># $Revision: 1295 $</span>
    5959<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIIpwdGUI.py $</span>
    60 <span class="c"># $Id: GSASIIpwdGUI.py 1177 2013-12-19 19:34:54Z vondreele $</span>
     60<span class="c"># $Id: GSASIIpwdGUI.py 1295 2014-04-22 14:37:51Z vondreele $</span>
    6161<span class="c">########### SVN repository information ###################</span>
    6262<span class="sd">&#39;&#39;&#39;</span>
     
    7272<span class="kn">import</span> <span class="nn">wx</span>
    7373<span class="kn">import</span> <span class="nn">wx.grid</span> <span class="kn">as</span> <span class="nn">wg</span>
     74<span class="kn">import</span> <span class="nn">wx.lib.scrolledpanel</span> <span class="kn">as</span> <span class="nn">wxscroll</span>
    7475<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
    7576<span class="kn">import</span> <span class="nn">numpy.ma</span> <span class="kn">as</span> <span class="nn">ma</span>
     
    8081<span class="kn">import</span> <span class="nn">cPickle</span>
    8182<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    82 <span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1177 $&quot;</span><span class="p">)</span>
     83<span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1295 $&quot;</span><span class="p">)</span>
    8384<span class="kn">import</span> <span class="nn">GSASIImath</span> <span class="kn">as</span> <span class="nn">G2mth</span>
    8485<span class="kn">import</span> <span class="nn">GSASIIpwd</span> <span class="kn">as</span> <span class="nn">G2pwd</span>
     
    9192<span class="kn">import</span> <span class="nn">GSASIIElemGUI</span> <span class="kn">as</span> <span class="nn">G2elemGUI</span>
    9293<span class="kn">import</span> <span class="nn">GSASIIElem</span> <span class="kn">as</span> <span class="nn">G2elem</span>
     94<span class="kn">import</span> <span class="nn">GSASIIsasd</span> <span class="kn">as</span> <span class="nn">G2sasd</span>
    9395<span class="n">VERY_LIGHT_GREY</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Colour</span><span class="p">(</span><span class="mi">235</span><span class="p">,</span><span class="mi">235</span><span class="p">,</span><span class="mi">235</span><span class="p">)</span>
     96<span class="n">WACV</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span>
     97<span class="n">Pwr10</span> <span class="o">=</span> <span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b9</span><span class="p">)</span><span class="o">+</span><span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b0</span><span class="p">)</span>
     98<span class="n">Pwr20</span> <span class="o">=</span> <span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b2</span><span class="p">)</span><span class="o">+</span><span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b0</span><span class="p">)</span>
     99<span class="n">Pwrm1</span> <span class="o">=</span> <span class="nb">unichr</span><span class="p">(</span><span class="mh">0x207b</span><span class="p">)</span><span class="o">+</span><span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b9</span><span class="p">)</span>
     100<span class="n">Pwrm2</span> <span class="o">=</span> <span class="nb">unichr</span><span class="p">(</span><span class="mh">0x207b</span><span class="p">)</span><span class="o">+</span><span class="nb">unichr</span><span class="p">(</span><span class="mh">0x0b2</span><span class="p">)</span>
     101<span class="n">Pwrm4</span> <span class="o">=</span> <span class="nb">unichr</span><span class="p">(</span><span class="mh">0x207b</span><span class="p">)</span><span class="o">+</span><span class="nb">unichr</span><span class="p">(</span><span class="mh">0x2074</span><span class="p">)</span>   <span class="c">#really -d but looks like -4 as a superscript</span>
    94102<span class="c"># trig functions in degrees</span>
    95103<span class="n">sind</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">math</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">math</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mf">180.</span><span class="p">)</span>
     
    114122</div>
    115123<div class="viewcode-block" id="SetDefaultSample"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.SetDefaultSample">[docs]</a><span class="k">def</span> <span class="nf">SetDefaultSample</span><span class="p">():</span>
    116     <span class="s">&#39;Needs a doc string&#39;</span>
     124    <span class="s">&#39;Fills in default items for the Sample dictionary&#39;</span>
    117125    <span class="k">return</span> <span class="p">{</span>
     126        <span class="s">&#39;InstrName&#39;</span><span class="p">:</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    118127        <span class="s">&#39;ranId&#39;</span><span class="p">:</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>
    119128        <span class="s">&#39;Scale&#39;</span><span class="p">:[</span><span class="mf">1.0</span><span class="p">,</span><span class="bp">True</span><span class="p">],</span><span class="s">&#39;Type&#39;</span><span class="p">:</span><span class="s">&#39;Debye-Scherrer&#39;</span><span class="p">,</span><span class="s">&#39;Absorption&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span>
    120129        <span class="s">&#39;DisplaceX&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;DisplaceY&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Diffuse&#39;</span><span class="p">:[],</span>
    121         <span class="s">&#39;Temperature&#39;</span><span class="p">:</span><span class="mf">300.</span><span class="p">,</span><span class="s">&#39;Pressure&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span>
     130        <span class="s">&#39;Temperature&#39;</span><span class="p">:</span><span class="mf">300.</span><span class="p">,</span><span class="s">&#39;Pressure&#39;</span><span class="p">:</span><span class="mf">0.1</span><span class="p">,</span>
    122131        <span class="s">&#39;FreePrm1&#39;</span><span class="p">:</span><span class="mf">0.</span><span class="p">,</span><span class="s">&#39;FreePrm2&#39;</span><span class="p">:</span><span class="mf">0.</span><span class="p">,</span><span class="s">&#39;FreePrm3&#39;</span><span class="p">:</span><span class="mf">0.</span><span class="p">,</span>
    123132        <span class="s">&#39;Gonio. radius&#39;</span><span class="p">:</span><span class="mf">200.0</span><span class="p">,</span>
    124         <span class="s">&#39;Omega&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;Chi&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;Phi&#39;</span><span class="p">:</span><span class="mf">0.0</span>
     133        <span class="s">&#39;Omega&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;Chi&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;Phi&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span>
     134<span class="c">#SASD items</span>
     135        <span class="s">&#39;Materials&#39;</span><span class="p">:[{</span><span class="s">&#39;Name&#39;</span><span class="p">:</span><span class="s">&#39;vacuum&#39;</span><span class="p">,</span><span class="s">&#39;VolFrac&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,},{</span><span class="s">&#39;Name&#39;</span><span class="p">:</span><span class="s">&#39;vacuum&#39;</span><span class="p">,</span><span class="s">&#39;VolFrac&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,}],</span>
     136        <span class="s">&#39;Thick&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span><span class="s">&#39;Contrast&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">],</span>       <span class="c">#contrast &amp; anomalous contrast</span>
     137        <span class="s">&#39;Trans&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span>                            <span class="c">#measured transmission</span>
     138        <span class="p">}</span></div>
     139<div class="viewcode-block" id="SetupSampleLabels"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.SetupSampleLabels">[docs]</a><span class="k">def</span> <span class="nf">SetupSampleLabels</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">dataType</span><span class="p">):</span>
     140    <span class="sd">&#39;&#39;&#39;Setup a list of labels and number formatting for use in</span>
     141<span class="sd">    labeling sample parameters.</span>
     142<span class="sd">    :param str histName: Name of histogram, (&quot;PWDR ...&quot;)</span>
     143<span class="sd">    :param str dataType: </span>
     144<span class="sd">    &#39;&#39;&#39;</span>
     145    <span class="n">parms</span> <span class="o">=</span> <span class="p">[]</span>
     146    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Scale&#39;</span><span class="p">,</span><span class="s">&#39;Histogram scale factor: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]])</span>
     147    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Gonio. radius&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer radius (mm): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     148    <span class="k">if</span> <span class="s">&#39;PWDR&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     149        <span class="k">if</span> <span class="n">dataType</span> <span class="o">==</span> <span class="s">&#39;Debye-Scherrer&#39;</span><span class="p">:</span>
     150            <span class="n">parms</span> <span class="o">+=</span> <span class="p">[[</span><span class="s">&#39;DisplaceX&#39;</span><span class="p">,</span><span class="s">u&#39;Sample X displ. perp. to beam (</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
     151                <span class="p">[</span><span class="s">&#39;DisplaceY&#39;</span><span class="p">,</span><span class="s">u&#39;Sample Y displ. || to beam (</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
     152                <span class="p">[</span><span class="s">&#39;Absorption&#39;</span><span class="p">,</span><span class="s">u&#39;Sample absorption (</span><span class="se">\xb5\xb7</span><span class="s">r): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],]</span>
     153        <span class="k">elif</span> <span class="n">dataType</span> <span class="o">==</span> <span class="s">&#39;Bragg-Brentano&#39;</span><span class="p">:</span>
     154            <span class="n">parms</span> <span class="o">+=</span> <span class="p">[[</span><span class="s">&#39;Shift&#39;</span><span class="p">,</span><span class="s">u&#39;Sample displacement(</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],</span>
     155                <span class="p">[</span><span class="s">&#39;Transparency&#39;</span><span class="p">,</span><span class="s">u&#39;Sample transparency(1/</span><span class="se">\xb5</span><span class="s">eff, cm): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
     156                <span class="p">[</span><span class="s">&#39;SurfRoughA&#39;</span><span class="p">,</span><span class="s">&#39;Surface roughness A: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],</span>
     157                <span class="p">[</span><span class="s">&#39;SurfRoughB&#39;</span><span class="p">,</span><span class="s">&#39;Surface roughness B: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]]]</span>
     158    <span class="k">elif</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     159        <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Thick&#39;</span><span class="p">,</span><span class="s">&#39;Sample thickness (mm)&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     160        <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Trans&#39;</span><span class="p">,</span><span class="s">&#39;Transmission (meas)&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     161    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Omega&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer omega:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     162    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Chi&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer chi:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     163    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Phi&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer phi:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     164    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Temperature&#39;</span><span class="p">,</span><span class="s">&#39;Sample temperature (K): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     165    <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Pressure&#39;</span><span class="p">,</span><span class="s">&#39;Sample pressure (MPa): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
     166    <span class="k">return</span> <span class="n">parms</span>
     167</div>
     168<div class="viewcode-block" id="SetDefaultSASDModel"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.SetDefaultSASDModel">[docs]</a><span class="k">def</span> <span class="nf">SetDefaultSASDModel</span><span class="p">():</span>
     169    <span class="s">&#39;Fills in default items for the SASD Models dictionary&#39;</span>   
     170    <span class="k">return</span> <span class="p">{</span><span class="s">&#39;Back&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Size&#39;</span><span class="p">:{</span><span class="s">&#39;MinDiam&#39;</span><span class="p">:</span><span class="mi">50</span><span class="p">,</span><span class="s">&#39;MaxDiam&#39;</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="s">&#39;Nbins&#39;</span><span class="p">:</span><span class="mi">100</span><span class="p">,</span>
     171        <span class="s">&#39;logBins&#39;</span><span class="p">:</span><span class="bp">True</span><span class="p">,</span><span class="s">&#39;Method&#39;</span><span class="p">:</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">,</span><span class="s">&#39;Distribution&#39;</span><span class="p">:[],</span>
     172        <span class="s">&#39;Shape&#39;</span><span class="p">:[</span><span class="s">&#39;Spheroid&#39;</span><span class="p">,</span><span class="mf">1.0</span><span class="p">],</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">:{</span><span class="s">&#39;Niter&#39;</span><span class="p">:</span><span class="mi">100</span><span class="p">,</span><span class="s">&#39;Precision&#39;</span><span class="p">:</span><span class="mf">0.01</span><span class="p">,</span><span class="s">&#39;Sky&#39;</span><span class="p">:</span><span class="o">-</span><span class="mi">3</span><span class="p">},</span>
     173        <span class="s">&#39;IPG&#39;</span><span class="p">:{</span><span class="s">&#39;Niter&#39;</span><span class="p">:</span><span class="mi">100</span><span class="p">,</span><span class="s">&#39;Approach&#39;</span><span class="p">:</span><span class="mf">0.8</span><span class="p">,</span><span class="s">&#39;Power&#39;</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">},</span><span class="s">&#39;Reg&#39;</span><span class="p">:{},},</span>           
     174        <span class="s">&#39;Particle&#39;</span><span class="p">:{</span><span class="s">&#39;Matrix&#39;</span><span class="p">:{</span><span class="s">&#39;Name&#39;</span><span class="p">:</span><span class="s">&#39;vacuum&#39;</span><span class="p">,</span><span class="s">&#39;VolFrac&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span><span class="s">&#39;Levels&#39;</span><span class="p">:[],},</span>
     175        <span class="s">&#39;Current&#39;</span><span class="p">:</span><span class="s">&#39;Size dist.&#39;</span><span class="p">,</span>
    125176        <span class="p">}</span>
     177        </div>
     178<div class="viewcode-block" id="SetDefaultSubstances"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.SetDefaultSubstances">[docs]</a><span class="k">def</span> <span class="nf">SetDefaultSubstances</span><span class="p">():</span>
     179    <span class="s">&#39;Fills in default items for the SASD Substances dictionary&#39;</span>
     180    <span class="k">return</span> <span class="p">{</span><span class="s">&#39;Substances&#39;</span><span class="p">:{</span><span class="s">&#39;vacuum&#39;</span><span class="p">:{</span><span class="s">&#39;Elements&#39;</span><span class="p">:{},</span><span class="s">&#39;Volume&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span><span class="s">&#39;Density&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;Scatt density&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">}}}</span>
     181</div>
     182<div class="viewcode-block" id="GetHistsLikeSelected"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.GetHistsLikeSelected">[docs]</a><span class="k">def</span> <span class="nf">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">):</span>
     183    <span class="sd">&#39;&#39;&#39;Get the histograms that match the current selected one:</span>
     184<span class="sd">    The histogram prefix and data type (PXC etc.), the number of</span>
     185<span class="sd">    wavelengths and the instrument geometry (Debye-Scherrer etc.) </span>
     186<span class="sd">    must all match. The current histogram is not included in the list. </span>
     187
     188<span class="sd">    :param wx.Frame G2frame: pointer to main GSAS-II data tree</span>
     189<span class="sd">    &#39;&#39;&#39;</span>
     190    <span class="n">histList</span> <span class="o">=</span> <span class="p">[]</span>
     191    <span class="n">inst</span><span class="p">,</span><span class="n">inst2</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     192        <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span>
     193            <span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Instrument Parameters&#39;</span><span class="p">)</span>
     194        <span class="p">)</span>
     195    <span class="n">hType</span> <span class="o">=</span> <span class="n">inst</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
     196    <span class="k">if</span> <span class="s">&#39;Lam1&#39;</span> <span class="ow">in</span> <span class="n">inst</span><span class="p">:</span>
     197        <span class="n">hLam</span> <span class="o">=</span> <span class="mi">2</span>
     198    <span class="k">elif</span> <span class="s">&#39;Lam&#39;</span> <span class="ow">in</span> <span class="n">inst</span><span class="p">:</span>
     199        <span class="n">hLam</span> <span class="o">=</span> <span class="mi">1</span>
     200    <span class="k">else</span><span class="p">:</span>
     201        <span class="n">hLam</span> <span class="o">=</span> <span class="mi">0</span>
     202    <span class="n">sample</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     203        <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span>
     204            <span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Sample Parameters&#39;</span><span class="p">)</span>
     205        <span class="p">)</span>
     206    <span class="n">hGeom</span> <span class="o">=</span> <span class="n">sample</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;Type&#39;</span><span class="p">)</span>
     207    <span class="n">hstName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     208    <span class="n">hPrefix</span> <span class="o">=</span> <span class="n">hstName</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="s">&#39; &#39;</span>
     209    <span class="c"># cycle through tree looking for items that match the above</span>
     210    <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetFirstChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">)</span>       
     211    <span class="k">while</span> <span class="n">item</span><span class="p">:</span>
     212        <span class="n">name</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
     213        <span class="k">if</span> <span class="n">name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">hPrefix</span><span class="p">)</span> <span class="ow">and</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">hstName</span><span class="p">:</span>
     214            <span class="n">cGeom</span><span class="p">,</span><span class="n">cType</span><span class="p">,</span><span class="n">cLam</span><span class="p">,</span> <span class="o">=</span> <span class="s">&#39;?&#39;</span><span class="p">,</span><span class="s">&#39;?&#39;</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span>
     215            <span class="n">subitem</span><span class="p">,</span> <span class="n">subcookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetFirstChild</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
     216            <span class="k">while</span> <span class="n">subitem</span><span class="p">:</span>
     217                <span class="n">subname</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">subitem</span><span class="p">)</span>
     218                <span class="k">if</span> <span class="n">subname</span> <span class="o">==</span> <span class="s">&#39;Sample Parameters&#39;</span><span class="p">:</span>
     219                    <span class="n">sample</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">subitem</span><span class="p">)</span>
     220                    <span class="n">cGeom</span> <span class="o">=</span> <span class="n">sample</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;Type&#39;</span><span class="p">)</span>
     221                <span class="k">elif</span> <span class="n">subname</span> <span class="o">==</span> <span class="s">&#39;Instrument Parameters&#39;</span><span class="p">:</span>
     222                    <span class="n">inst</span><span class="p">,</span><span class="n">inst2</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">subitem</span><span class="p">)</span>
     223                    <span class="n">cType</span> <span class="o">=</span> <span class="n">inst</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
     224                    <span class="k">if</span> <span class="s">&#39;Lam1&#39;</span> <span class="ow">in</span> <span class="n">inst</span><span class="p">:</span>
     225                        <span class="n">cLam</span> <span class="o">=</span> <span class="mi">2</span>
     226                    <span class="k">elif</span> <span class="s">&#39;Lam&#39;</span> <span class="ow">in</span> <span class="n">inst</span><span class="p">:</span>
     227                        <span class="n">cLam</span> <span class="o">=</span> <span class="mi">1</span>
     228                    <span class="k">else</span><span class="p">:</span>
     229                        <span class="n">cLam</span> <span class="o">=</span> <span class="mi">0</span>
     230                <span class="n">subitem</span><span class="p">,</span> <span class="n">subcookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetNextChild</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">subcookie</span><span class="p">)</span>
     231            <span class="k">if</span> <span class="n">cLam</span> <span class="o">==</span> <span class="n">hLam</span> <span class="ow">and</span> <span class="n">cType</span> <span class="o">==</span> <span class="n">hType</span> <span class="ow">and</span> <span class="n">cGeom</span> <span class="o">==</span> <span class="n">hGeom</span><span class="p">:</span>
     232                <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">histList</span><span class="p">:</span> <span class="n">histList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
     233        <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetNextChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">cookie</span><span class="p">)</span>
     234    <span class="k">return</span> <span class="n">histList</span>
     235</div>
     236<div class="viewcode-block" id="SetCopyNames"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.SetCopyNames">[docs]</a><span class="k">def</span> <span class="nf">SetCopyNames</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">dataType</span><span class="p">,</span><span class="n">addNames</span><span class="o">=</span><span class="p">[]):</span>
     237    <span class="sd">&#39;&#39;&#39;Determine the items in the sample parameters that should be copied,</span>
     238<span class="sd">    depending on the histogram type and the instrument type.</span>
     239<span class="sd">    &#39;&#39;&#39;</span>
     240    <span class="n">copyNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Scale&#39;</span><span class="p">,]</span>
     241    <span class="n">histType</span> <span class="o">=</span> <span class="s">&#39;HKLF&#39;</span>
     242    <span class="k">if</span> <span class="s">&#39;PWDR&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     243        <span class="n">histType</span> <span class="o">=</span> <span class="s">&#39;PWDR&#39;</span>
     244        <span class="k">if</span> <span class="s">&#39;Debye&#39;</span> <span class="ow">in</span> <span class="n">dataType</span><span class="p">:</span>
     245            <span class="n">copyNames</span> <span class="o">+=</span> <span class="p">[</span><span class="s">&#39;DisplaceX&#39;</span><span class="p">,</span><span class="s">&#39;DisplaceY&#39;</span><span class="p">,</span><span class="s">&#39;Absorption&#39;</span><span class="p">]</span>
     246        <span class="k">else</span><span class="p">:</span>       <span class="c">#Bragg-Brentano</span>
     247            <span class="n">copyNames</span> <span class="o">+=</span> <span class="p">[</span><span class="s">&#39;Shift&#39;</span><span class="p">,</span><span class="s">&#39;Transparency&#39;</span><span class="p">,</span><span class="s">&#39;SurfRoughA&#39;</span><span class="p">,</span><span class="s">&#39;SurfRoughB&#39;</span><span class="p">]</span>
     248    <span class="k">elif</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     249        <span class="n">histType</span> <span class="o">=</span> <span class="s">&#39;SASD&#39;</span>
     250        <span class="n">copyNames</span> <span class="o">+=</span> <span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">,</span><span class="s">&#39;Thick&#39;</span><span class="p">,]</span>
     251    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">addNames</span><span class="p">):</span>
     252        <span class="n">copyNames</span> <span class="o">+=</span> <span class="n">addNames</span>
     253    <span class="k">return</span> <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span>
     254</div>
     255<div class="viewcode-block" id="CopySelectedHistItems"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.CopySelectedHistItems">[docs]</a><span class="k">def</span> <span class="nf">CopySelectedHistItems</span><span class="p">(</span><span class="n">G2frame</span><span class="p">):</span>
     256    <span class="sd">&#39;&#39;&#39;Global copy: Copy items from current histogram to others.</span>
     257<span class="sd">    This is called from the menubar and is available only when the top histogram tree entry</span>
     258<span class="sd">    is selected.</span>
     259<span class="sd">    &#39;&#39;&#39;</span>
     260    <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     261    <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     262    <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     263        <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     264        <span class="k">return</span>
     265    <span class="n">choices</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Limits&#39;</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">]</span>
     266    <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     267        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     268        <span class="s">&#39;Copy which histogram sections from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:]),</span>
     269        <span class="s">&#39;Select copy sections&#39;</span><span class="p">,</span> <span class="n">choices</span><span class="p">,</span> <span class="n">filterBox</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
     270    <span class="n">dlg</span><span class="o">.</span><span class="n">SetSelections</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">choices</span><span class="p">)))</span>
     271    <span class="n">choiceList</span> <span class="o">=</span> <span class="p">[]</span>
     272    <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     273        <span class="n">choiceList</span> <span class="o">=</span> <span class="p">[</span><span class="n">choices</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()]</span>
     274    <span class="k">if</span> <span class="ow">not</span> <span class="n">choiceList</span><span class="p">:</span> <span class="k">return</span>
     275   
     276    <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     277        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     278        <span class="s">&#39;Copy parameters from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     279        <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
     280    <span class="n">results</span> <span class="o">=</span> <span class="p">[]</span>
     281    <span class="k">try</span><span class="p">:</span>
     282        <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     283            <span class="n">results</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
     284    <span class="k">finally</span><span class="p">:</span>
     285        <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     286    <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
     287    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">results</span><span class="p">:</span>
     288        <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     289
     290    <span class="k">if</span> <span class="s">&#39;Limits&#39;</span> <span class="ow">in</span> <span class="n">choiceList</span><span class="p">:</span> <span class="c"># Limits</span>
     291        <span class="n">data</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     292            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span><span class="s">&#39;Limits&#39;</span><span class="p">))</span>
     293        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     294            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     295            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span>
     296                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Limits&#39;</span><span class="p">),</span>
     297                <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     298    <span class="k">if</span> <span class="s">&#39;Background&#39;</span> <span class="ow">in</span> <span class="n">choiceList</span><span class="p">:</span>  <span class="c"># Background</span>
     299        <span class="n">data</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     300            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">))</span>
     301        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     302            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     303            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span>
     304                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">),</span>
     305                <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     306    <span class="k">if</span> <span class="s">&#39;Instrument Parameters&#39;</span> <span class="ow">in</span> <span class="n">choiceList</span><span class="p">:</span>  <span class="c"># Instrument Parameters</span>
     307        <span class="c"># for now all items in Inst. parms are copied</span>
     308        <span class="n">data</span><span class="p">,</span><span class="n">data1</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     309            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span>
     310                <span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))</span>
     311        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     312            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     313            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     314                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">)</span>
     315                <span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     316            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     317                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">)</span>
     318                <span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">data1</span><span class="p">))</span>
     319    <span class="k">if</span> <span class="s">&#39;Sample Parameters&#39;</span> <span class="ow">in</span> <span class="n">choiceList</span><span class="p">:</span>  <span class="c"># Sample Parameters</span>
     320        <span class="n">data</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     321            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span>
     322                <span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
     323        <span class="c"># selects items to be copied</span>
     324        <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span> <span class="o">=</span> <span class="n">SetCopyNames</span><span class="p">(</span><span class="n">hst</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">],</span>
     325            <span class="n">addNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Omega&#39;</span><span class="p">,</span><span class="s">&#39;Chi&#39;</span><span class="p">,</span><span class="s">&#39;Phi&#39;</span><span class="p">,</span><span class="s">&#39;Gonio. radius&#39;</span><span class="p">,</span><span class="s">&#39;InstrName&#39;</span><span class="p">])</span>
     326        <span class="n">copyDict</span> <span class="o">=</span> <span class="p">{</span><span class="n">parm</span><span class="p">:</span><span class="n">data</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span> <span class="k">for</span> <span class="n">parm</span> <span class="ow">in</span> <span class="n">copyNames</span><span class="p">}</span>
     327        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     328            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     329            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     330                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">)</span>
     331                <span class="p">)</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">copyDict</span><span class="p">))</span>
    126332                         
    127333<span class="c">################################################################################</span>
     
    165371            <span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2mth</span><span class="o">.</span><span class="n">setPeakparms</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span><span class="n">inst2</span><span class="p">,</span><span class="n">pos</span><span class="p">,</span><span class="n">mag</span><span class="p">))</span>
    166372        <span class="n">UpdatePeakGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
    167         <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>       
     373        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;PWDR&#39;</span><span class="p">)</span>       
    168374   
    169375    <span class="k">def</span> <span class="nf">OnUnDo</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     
    212418            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    213419        <span class="n">UpdatePeakGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">peaks</span><span class="p">)</span>
    214         <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     420        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;PWDR&#39;</span><span class="p">)</span>
    215421       
    216422    <span class="k">def</span> <span class="nf">OnPeakFit</span><span class="p">(</span><span class="n">FitPgm</span><span class="p">,</span><span class="n">oneCycle</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
     
    241447            <span class="n">wx</span><span class="o">.</span><span class="n">EndBusyCursor</span><span class="p">()</span>   
    242448        <span class="n">UpdatePeakGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">peaks</span><span class="p">)</span>
    243         <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     449        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;PWDR&#39;</span><span class="p">)</span>
    244450        <span class="k">print</span> <span class="s">&#39;finished&#39;</span>
    245451        <span class="k">return</span>
     
    331537                    <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="mi">78</span><span class="p">:</span>  <span class="c">#&#39;N&#39;</span>
    332538                        <span class="n">data</span><span class="p">[</span><span class="n">row</span><span class="p">][</span><span class="n">col</span><span class="p">]</span><span class="o">=</span><span class="bp">False</span>
    333         <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     539        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;PWDR&#39;</span><span class="p">)</span>
    334540           
    335541    <span class="n">G2gd</span><span class="o">.</span><span class="n">SetDataMenuBar</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">PeakMenu</span><span class="p">)</span>
     
    411617            <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="n">backDict</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">]:</span>
    412618                <span class="n">PKflags</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">])</span>           
    413         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All&#39;</span><span class="p">,]</span><span class="o">+</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;PWDR&#39;</span><span class="p">,])</span>
     619        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     620        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     621        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     622            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     623            <span class="k">return</span>
     624        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     625            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     626            <span class="s">&#39;Copy bkg ref. flags from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     627            <span class="s">&#39;Copy bkg flags&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    414628        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    415         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
    416             <span class="s">&#39;Copy refinement flags to which histograms?&#39;</span><span class="p">,</span> <span class="s">&#39;Copy flags&#39;</span><span class="p">,</span>
    417             <span class="n">histList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
    418629        <span class="k">try</span><span class="p">:</span>
    419630            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    420                 <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    421                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
     631                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
    422632                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    423                 <span class="k">if</span> <span class="s">&#39;All&#39;</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    424                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    425             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    426                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    427                 <span class="n">backData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">))</span>
    428                 <span class="n">backData</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="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flag</span><span class="p">)</span>
    429                 <span class="n">bkDict</span> <span class="o">=</span> <span class="n">backData</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    430                 <span class="k">if</span> <span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;nDebye&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="n">backDict</span><span class="p">[</span><span class="s">&#39;nDebye&#39;</span><span class="p">]:</span>
    431                     <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">term</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;debyeTerms&#39;</span><span class="p">]):</span>
    432                         <span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">DBflags</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    433                 <span class="k">if</span> <span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="n">backDict</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]:</span>
    434                     <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">term</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">]):</span>
    435                         <span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">PKflags</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>                   
    436633        <span class="k">finally</span><span class="p">:</span>
    437634            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     635        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     636            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     637            <span class="n">backData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">))</span>
     638            <span class="n">backData</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="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flag</span><span class="p">)</span>
     639            <span class="n">bkDict</span> <span class="o">=</span> <span class="n">backData</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
     640            <span class="k">if</span> <span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;nDebye&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="n">backDict</span><span class="p">[</span><span class="s">&#39;nDebye&#39;</span><span class="p">]:</span>
     641                <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">term</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;debyeTerms&#39;</span><span class="p">]):</span>
     642                    <span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">DBflags</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     643            <span class="k">if</span> <span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="n">backDict</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]:</span>
     644                <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">term</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bkDict</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">]):</span>
     645                    <span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">PKflags</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>                   
    438646           
    439647    <span class="k">def</span> <span class="nf">OnBackCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    440         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All&#39;</span><span class="p">,]</span><span class="o">+</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;PWDR&#39;</span><span class="p">,])</span>
     648        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     649        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     650        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     651            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     652            <span class="k">return</span>
    441653        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    442         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
    443             <span class="s">&#39;Copy parameters to which histograms?&#39;</span><span class="p">,</span> <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span>
    444             <span class="n">histList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     654        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     655            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     656            <span class="s">&#39;Copy bkg params from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     657            <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    445658        <span class="k">try</span><span class="p">:</span>
    446659            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    447                 <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    448                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
     660                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
    449661                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    450                 <span class="k">if</span> <span class="s">&#39;All&#39;</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    451                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    452             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    453                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    454                 <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">),</span>
    455                     <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
    456662        <span class="k">finally</span><span class="p">:</span>
    457663            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     664        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     665            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     666            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span>
     667                <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Background&#39;</span><span class="p">),</span><span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
    458668       
    459669    <span class="k">def</span> <span class="nf">BackSizer</span><span class="p">():</span>
     
    491701        <span class="n">backSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
    492702        <span class="n">topSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    493         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Background function: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     703        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Background function: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    494704        <span class="n">bakType</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span>
    495705                <span class="n">choices</span><span class="o">=</span><span class="n">Choices</span><span class="p">,</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     
    500710        <span class="n">bakRef</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
    501711        <span class="n">bakRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnBakRef</span><span class="p">)</span>
    502         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    503         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. coeff.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     712        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     713        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. coeff.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    504714        <span class="n">bakTerms</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">2</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">36</span><span class="p">)],</span>
    505715            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
    506716        <span class="n">bakTerms</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnBakTerms</span><span class="p">)</span>
    507         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakTerms</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     717        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakTerms</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    508718        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    509719        <span class="n">backSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">topSizer</span><span class="p">)</span>
    510         <span class="n">backSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Background coefficients:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     720        <span class="n">backSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Background coefficients:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    511721        <span class="n">bakSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
    512722        <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">value</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">3</span><span class="p">:]):</span>
    513723            <span class="n">bakVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%10.4f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">value</span><span class="p">),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    514             <span class="n">bakSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     724            <span class="n">bakSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bakVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    515725            <span class="n">ValObj</span><span class="p">[</span><span class="n">bakVal</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span>
    516726            <span class="n">bakVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnBakVal</span><span class="p">)</span>
     
    554764        <span class="n">debSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
    555765        <span class="n">topSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    556         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Debye scattering: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    557         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. coeff.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     766        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Debye scattering: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     767        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. coeff.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    558768        <span class="n">debTerms</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;nDebye&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">12</span><span class="p">)],</span>
    559769            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
    560770        <span class="n">debTerms</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnDebTerms</span><span class="p">)</span>
    561         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">debTerms</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     771        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">debTerms</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    562772        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    563773        <span class="n">debSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">topSizer</span><span class="p">)</span>
    564774        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;nDebye&#39;</span><span class="p">]:</span>
    565             <span class="n">debSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Debye diffuse terms:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>       
     775            <span class="n">debSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Debye diffuse terms:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>       
    566776            <span class="n">rowLabels</span> <span class="o">=</span> <span class="p">[]</span>
    567777            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;debyeTerms&#39;</span><span class="p">])):</span> <span class="n">rowLabels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
     
    612822        <span class="n">peaksSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
    613823        <span class="n">topSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    614         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Peaks in background: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    615         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. peaks: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     824        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Peaks in background: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     825        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; No. peaks: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    616826        <span class="n">peaks</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">12</span><span class="p">)],</span>
    617827            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
    618828        <span class="n">peaks</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnPeaks</span><span class="p">)</span>
    619         <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">peaks</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     829        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">peaks</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    620830        <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    621831        <span class="n">peaksSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">topSizer</span><span class="p">)</span>
    622832        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]:</span>
    623             <span class="n">peaksSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Peak list:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>       
     833            <span class="n">peaksSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Peak list:&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>       
    624834            <span class="n">rowLabels</span> <span class="o">=</span> <span class="p">[]</span>
    625835            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;peaksList&#39;</span><span class="p">])):</span> <span class="n">rowLabels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
     
    663873<span class="c">################################################################################           </span>
    664874       </div>
    665 <div class="viewcode-block" id="UpdateLimitsGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateLimitsGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateLimitsGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
     875<div class="viewcode-block" id="UpdateLimitsGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateLimitsGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateLimitsGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span><span class="n">plottype</span><span class="p">):</span>
    666876    <span class="sd">&#39;&#39;&#39;respond to selection of PWDR Limits data tree item.</span>
    667877<span class="sd">    &#39;&#39;&#39;</span>
     
    675885            <span class="k">if</span> <span class="n">row</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="c">#can&#39;t delete limits!</span>
    676886                <span class="k">del</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">row</span><span class="p">])</span>
    677                 <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateLimitsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
    678                 <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     887                <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateLimitsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">,</span><span class="n">plottype</span><span class="p">)</span>
     888                <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="n">plottype</span><span class="p">)</span>
    679889                       
    680890    <span class="k">def</span> <span class="nf">RefreshLimitsGrid</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     
    693903        <span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">old</span><span class="p">,</span><span class="n">new</span><span class="p">]</span><span class="o">+</span><span class="n">excl</span>
    694904        <span class="n">G2frame</span><span class="o">.</span><span class="n">LimitsTable</span><span class="o">.</span><span class="n">SetData</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
    695         <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     905        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="n">plottype</span><span class="p">)</span>
    696906       
    697907    <span class="k">def</span> <span class="nf">OnLimitCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    698         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All&#39;</span><span class="p">,]</span><span class="o">+</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;PWDR&#39;</span><span class="p">,])</span>
     908        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     909        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     910        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     911            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     912            <span class="k">return</span>
    699913        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    700         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
    701             <span class="s">&#39;Copy limits to which histograms?&#39;</span><span class="p">,</span> <span class="s">&#39;Copy limits&#39;</span><span class="p">,</span>
    702             <span class="n">histList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     914        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     915            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     916            <span class="s">&#39;Copy limits from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     917            <span class="s">&#39;Copy limits&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    703918        <span class="k">try</span><span class="p">:</span>
    704919            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    705                 <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    706                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
    707                     <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    708                 <span class="k">if</span> <span class="s">&#39;All&#39;</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    709                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    710             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    711                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    712                 <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Limits&#39;</span><span class="p">),</span>
    713                     <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     920                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
     921                    <span class="n">item</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
     922                    <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     923                    <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span>
     924                        <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Limits&#39;</span><span class="p">),</span><span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
    714925        <span class="k">finally</span><span class="p">:</span>
    715926            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     
    724935    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">-</span><span class="mi">2</span><span class="p">):</span>
    725936        <span class="n">rowLabels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s">&#39;exclude&#39;</span><span class="p">)</span>
    726     <span class="n">Types</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="p">[</span><span class="n">wg</span><span class="o">.</span><span class="n">GRID_VALUE_FLOAT</span><span class="o">+</span><span class="s">&#39;:10,3&#39;</span><span class="p">,]</span>
     937    <span class="n">Types</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="p">[</span><span class="n">wg</span><span class="o">.</span><span class="n">GRID_VALUE_FLOAT</span><span class="o">+</span><span class="s">&#39;:12,5&#39;</span><span class="p">,]</span>
    727938    <span class="n">G2frame</span><span class="o">.</span><span class="n">LimitsTable</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">rowLabels</span><span class="o">=</span><span class="n">rowLabels</span><span class="p">,</span><span class="n">colLabels</span><span class="o">=</span><span class="n">colLabels</span><span class="p">,</span><span class="n">types</span><span class="o">=</span><span class="n">Types</span><span class="p">)</span>
    728939    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SetLabel</span><span class="p">(</span><span class="s">&#39;Limits&#39;</span><span class="p">)</span>
     
    733944    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span><span class="n">OnAddExcl</span><span class="p">,</span><span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_ADDEXCLREGION</span><span class="p">)</span>   
    734945    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GSGrid</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
    735     <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetTable</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">LimitsTable</span><span class="p">,</span> <span class="bp">True</span><span class="p">)</span>
     946    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetTable</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">LimitsTable</span><span class="p">,</span> <span class="bp">True</span><span class="p">)</span>   
     947    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetCellStyle</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">VERY_LIGHT_GREY</span><span class="p">,</span><span class="bp">True</span><span class="p">)</span>
     948    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetCellStyle</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="n">VERY_LIGHT_GREY</span><span class="p">,</span><span class="bp">True</span><span class="p">)</span>
    736949    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wg</span><span class="o">.</span><span class="n">EVT_GRID_CELL_CHANGE</span><span class="p">,</span> <span class="n">RefreshLimitsGrid</span><span class="p">)</span>               
    737950    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KEY_DOWN</span><span class="p">,</span> <span class="n">KeyEditPeakGrid</span><span class="p">)</span>
     
    739952    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">AutoSizeColumns</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
    740953    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">setSizePosLeft</span><span class="p">([</span><span class="mi">230</span><span class="p">,</span><span class="mi">260</span><span class="p">])</span>
     954                               
    741955   
    742956<span class="c">################################################################################</span>
     
    745959       </div>
    746960<div class="viewcode-block" id="UpdateInstrumentGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateInstrumentGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateInstrumentGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
    747     <span class="sd">&#39;&#39;&#39;respond to selection of PWDR Instrument Parameters</span>
     961    <span class="sd">&#39;&#39;&#39;respond to selection of PWDR/SASD Instrument Parameters</span>
    748962<span class="sd">    data tree item.</span>
    749963<span class="sd">    &#39;&#39;&#39;</span>
     
    766980            <span class="k">del</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Polariz.&#39;</span><span class="p">])</span>
    767981            <span class="k">del</span><span class="p">(</span><span class="n">insRef</span><span class="p">[</span><span class="s">&#39;Polariz.&#39;</span><span class="p">])</span>
    768     <span class="k">else</span><span class="p">:</span>                               <span class="c">#single crystal data</span>
     982    <span class="k">elif</span> <span class="s">&#39;S&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>                               <span class="c">#single crystal data</span>
     983        <span class="n">insVal</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,[</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]))</span>
     984        <span class="n">insDef</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,[</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]))</span>
     985        <span class="n">insRef</span> <span class="o">=</span> <span class="p">{}</span>
     986    <span class="k">elif</span> <span class="s">&#39;L&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>                               <span class="c">#low angle data</span>
    769987        <span class="n">insVal</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,[</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]))</span>
    770988        <span class="n">insDef</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,[</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]))</span>
     
    8611079       
    8621080    <span class="k">def</span> <span class="nf">OnInstFlagCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    863         <span class="n">histName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1081        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1082        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     1083        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     1084            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     1085            <span class="k">return</span>
    8641086        <span class="n">keys</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
    8651087        <span class="n">flags</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,[</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]))</span>
    8661088        <span class="n">instType</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    867         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All&#39;</span><span class="p">,]</span><span class="o">+</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;PWDR&#39;</span><span class="p">,])</span>
    8681089        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    869         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
    870             <span class="s">&#39;Copy refinement flags from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">histName</span><span class="p">,</span> <span class="s">&#39;Copy refinement flags&#39;</span><span class="p">,</span>
    871             <span class="n">histList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     1090        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1091            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1092            <span class="s">&#39;Copy inst ref. flags from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:],</span>
     1093            <span class="s">&#39;Copy refinement flags&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    8721094        <span class="k">try</span><span class="p">:</span>
    8731095            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    874                 <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    875                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
     1096                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
    8761097                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    877                 <span class="k">if</span> <span class="s">&#39;All&#39;</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    878                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    879             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    880                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    881                 <span class="n">instData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
    882                 <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">instData</span><span class="p">)</span> <span class="ow">and</span> <span class="n">instType</span> <span class="o">==</span> <span class="n">instData</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>   <span class="c">#don&#39;t mix data types or lam &amp; lam1/lam2 parms!</span>
    883                     <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">instData</span><span class="p">:</span>
    884                         <span class="n">instData</span><span class="p">[</span><span class="n">item</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flags</span><span class="p">[</span><span class="n">item</span><span class="p">])</span>
    885                 <span class="k">else</span><span class="p">:</span>
    886                     <span class="k">print</span> <span class="n">item</span><span class="o">+</span><span class="s">&#39; not copied - instrument parameters not commensurate&#39;</span>
    8871098        <span class="k">finally</span><span class="p">:</span>
    8881099            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     1100        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     1101            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     1102            <span class="n">instData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
     1103            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">instData</span><span class="p">)</span> <span class="ow">and</span> <span class="n">instType</span> <span class="o">==</span> <span class="n">instData</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>   <span class="c">#don&#39;t mix data types or lam &amp; lam1/lam2 parms!</span>
     1104                <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">instData</span><span class="p">:</span>
     1105                    <span class="n">instData</span><span class="p">[</span><span class="n">item</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flags</span><span class="p">[</span><span class="n">item</span><span class="p">])</span>
     1106            <span class="k">else</span><span class="p">:</span>
     1107                <span class="k">print</span> <span class="n">item</span><span class="o">+</span><span class="s">&#39; not copied - instrument parameters not commensurate&#39;</span>
    8891108       
    8901109    <span class="k">def</span> <span class="nf">OnInstCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    8911110        <span class="c">#need fix for dictionary</span>
    892         <span class="n">histName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
    893         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All&#39;</span><span class="p">,]</span><span class="o">+</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;PWDR&#39;</span><span class="p">,])</span>
     1111        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1112        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     1113        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     1114            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     1115            <span class="k">return</span>
    8941116        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    8951117        <span class="n">instType</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    896         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
    897             <span class="s">&#39;Copy parameters from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">histName</span><span class="p">,</span> <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span>
    898             <span class="n">histList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     1118        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1119            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1120            <span class="s">&#39;Copy inst params from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span>
     1121            <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    8991122        <span class="k">try</span><span class="p">:</span>
    9001123            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    901                 <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    902                 <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
     1124                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
    9031125                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    904                 <span class="k">if</span> <span class="s">&#39;All&#39;</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    905                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    906             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    907                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    908                 <span class="n">instData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
    909                 <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">instData</span><span class="p">)</span> <span class="ow">and</span> <span class="n">instType</span> <span class="o">==</span> <span class="n">instData</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>  <span class="c">#don&#39;t mix data types or lam &amp; lam1/lam2 parms!</span>
    910                     <span class="n">instData</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
    911                 <span class="k">else</span><span class="p">:</span>
    912                     <span class="k">print</span> <span class="n">item</span><span class="o">+</span><span class="s">&#39; not copied - instrument parameters not commensurate&#39;</span>
    9131126        <span class="k">finally</span><span class="p">:</span>
    9141127            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     1128        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     1129            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     1130            <span class="n">instData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
     1131            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">instData</span><span class="p">)</span> <span class="ow">and</span> <span class="n">instType</span> <span class="o">==</span> <span class="n">instData</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>  <span class="c">#don&#39;t mix data types or lam &amp; lam1/lam2 parms!</span>
     1132                <span class="n">instData</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
     1133            <span class="k">else</span><span class="p">:</span>
     1134                <span class="k">print</span> <span class="n">item</span><span class="o">+</span><span class="s">&#39; not copied - instrument parameters not commensurate&#39;</span>
    9151135       
    9161136    <span class="k">def</span> <span class="nf">OnWaveChange</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     
    9921212    <span class="n">topSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
    9931213    <span class="n">instSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
    994     <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Histogram Type: &#39;</span><span class="o">+</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1214    <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Histogram Type: &#39;</span><span class="o">+</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    9951215<span class="c">#    topSizer.Add((5,5),0)</span>
    9961216    <span class="k">if</span> <span class="s">&#39;P&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]:</span>                   <span class="c">#powder data</span>
     
    10111231                <span class="n">insRef</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
    10121232            <span class="c">#end of patch</span>
    1013             <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Azimuth: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1233            <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Azimuth: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10141234            <span class="k">if</span> <span class="s">&#39;Lam1&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">:</span>
    10151235                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Ka1/Ka2:&#39;</span><span class="p">),</span>
    1016                         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1236                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10171237                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">u&#39;  </span><span class="si">%8.6f</span><span class="s">/</span><span class="si">%8.6f</span><span class="se">\xc5</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Lam1&#39;</span><span class="p">],</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Lam2&#39;</span><span class="p">])),</span>
    1018                         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1238                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10191239                <span class="n">waveSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    1020                 <span class="n">waveSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Select: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1240                <span class="n">waveSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Select: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10211241                <span class="n">choice</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;TiKa&#39;</span><span class="p">,</span><span class="s">&#39;CrKa&#39;</span><span class="p">,</span><span class="s">&#39;FeKa&#39;</span><span class="p">,</span><span class="s">&#39;CoKa&#39;</span><span class="p">,</span><span class="s">&#39;CuKa&#39;</span><span class="p">,</span><span class="s">&#39;MoKa&#39;</span><span class="p">,</span><span class="s">&#39;AgKa&#39;</span><span class="p">]</span>
    10221242                <span class="n">lamPick</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&#39; &#39;</span><span class="p">,</span><span class="n">choices</span><span class="o">=</span><span class="n">choice</span><span class="p">,</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     
    10251245                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    10261246                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; I(L2)/I(L1): (</span><span class="si">%10.4f</span><span class="s">)&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insDef</span><span class="p">[</span><span class="s">&#39;I(L2)/I(L1)&#39;</span><span class="p">])),</span>
    1027                         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1247                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10281248                <span class="n">ratVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%10.4f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;I(L2)/I(L1)&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    10291249                <span class="n">ratVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnRatValue</span><span class="p">)</span>
     
    10331253                <span class="n">ratRef</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">insRef</span><span class="p">[</span><span class="s">&#39;I(L2)/I(L1)&#39;</span><span class="p">]))</span>
    10341254                <span class="n">ratRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnRatRef</span><span class="p">)</span>
    1035                 <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">ratRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1255                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">ratRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10361256               
    10371257            <span class="k">else</span><span class="p">:</span>
    10381258                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">u&#39; Lam (</span><span class="se">\xc5</span><span class="s">): (</span><span class="si">%10.6f</span><span class="s">)&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insDef</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">])),</span>
    1039                     <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1259                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10401260                <span class="n">waveVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%10.6f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    10411261                <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
    10421262                <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
    1043                 <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1263                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10441264                <span class="k">if</span> <span class="n">ifHisto</span><span class="p">:</span>
    10451265                    <span class="n">waveRef</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Refine?&#39;</span><span class="p">)</span>
    10461266                    <span class="n">waveRef</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">insRef</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">]))</span>
    10471267                    <span class="n">waveRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnWaveRef</span><span class="p">)</span>
    1048                     <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1268                    <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10491269            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Zero&#39;</span><span class="p">,</span><span class="s">&#39;Polariz.&#39;</span><span class="p">]:</span>
    10501270                <span class="n">fmt</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%10.4f</span><span class="s">&#39;</span>
     
    10521272                <span class="k">if</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">insDef</span><span class="p">:</span>
    10531273                    <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">Fmt</span><span class="o">%</span><span class="p">(</span><span class="n">item</span><span class="p">,</span><span class="n">insDef</span><span class="p">[</span><span class="n">item</span><span class="p">])),</span>
    1054                             <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1274                            <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10551275                    <span class="n">itemVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="n">item</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    10561276                    <span class="n">ValObj</span><span class="p">[</span><span class="n">itemVal</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">item</span><span class="p">,</span><span class="n">fmt</span><span class="p">]</span>
    10571277                    <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    10581278                    <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    1059                     <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1279                    <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10601280                    <span class="k">if</span> <span class="n">ifHisto</span><span class="p">:</span>
    10611281                        <span class="n">itemRef</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Refine?&#39;</span><span class="p">)</span>
     
    10631283                        <span class="n">RefObj</span><span class="p">[</span><span class="n">itemRef</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="n">item</span>
    10641284                        <span class="n">itemRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnItemRef</span><span class="p">)</span>
    1065                         <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1285                        <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10661286                    <span class="k">else</span><span class="p">:</span>
    10671287                        <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
     
    10761296                <span class="n">Fmt</span> <span class="o">=</span> <span class="s">&#39; </span><span class="si">%s</span><span class="s">: (&#39;</span><span class="o">+</span><span class="n">fmt</span><span class="o">+</span><span class="s">&#39;)&#39;</span>
    10771297                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">Fmt</span><span class="o">%</span><span class="p">(</span><span class="n">item</span><span class="p">,</span><span class="n">insDef</span><span class="p">[</span><span class="n">item</span><span class="p">])),</span>
    1078                         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1298                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10791299                <span class="n">itemVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="n">item</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    10801300                <span class="n">ValObj</span><span class="p">[</span><span class="n">itemVal</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">item</span><span class="p">,</span><span class="n">fmt</span><span class="p">]</span>
    10811301                <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    10821302                <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    1083                 <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1303                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10841304                <span class="n">itemRef</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Refine?&#39;</span><span class="p">)</span>
    10851305                <span class="n">itemRef</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">bool</span><span class="p">(</span><span class="n">insRef</span><span class="p">[</span><span class="n">item</span><span class="p">]))</span>
    10861306                <span class="n">RefObj</span><span class="p">[</span><span class="n">itemRef</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="n">item</span>
    10871307                <span class="n">itemRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnItemRef</span><span class="p">)</span>
    1088                 <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1308                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10891309        <span class="k">else</span><span class="p">:</span>                                   <span class="c">#time of flight (neutrons)</span>
    1090             <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Azimuth: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1091             <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; 2-theta: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;2-theta&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1310            <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; Azimuth: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1311            <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; 2-theta: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;2-theta&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10921312            <span class="k">if</span> <span class="s">&#39;Pdabc&#39;</span> <span class="ow">in</span> <span class="n">Inst2</span><span class="p">:</span>
    10931313                <span class="n">Items</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;sig-0&#39;</span><span class="p">,</span><span class="s">&#39;sig-1&#39;</span><span class="p">,</span><span class="s">&#39;X&#39;</span><span class="p">,</span><span class="s">&#39;Y&#39;</span><span class="p">]</span>
    1094                 <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; difC: </span><span class="si">%8.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;difC&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1095                 <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; alpha, beta: fixed by table&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1314                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; difC: </span><span class="si">%8.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;difC&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1315                <span class="n">topSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39; alpha, beta: fixed by table&#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    10961316            <span class="k">else</span><span class="p">:</span>
    10971317                <span class="n">Items</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;difC&#39;</span><span class="p">,</span><span class="s">&#39;difA&#39;</span><span class="p">,</span><span class="s">&#39;Zero&#39;</span><span class="p">,</span><span class="s">&#39;alpha&#39;</span><span class="p">,</span><span class="s">&#39;beta-0&#39;</span><span class="p">,</span><span class="s">&#39;beta-1&#39;</span><span class="p">,</span><span class="s">&#39;beta-q&#39;</span><span class="p">,</span><span class="s">&#39;sig-0&#39;</span><span class="p">,</span><span class="s">&#39;sig-1&#39;</span><span class="p">,</span><span class="s">&#39;sig-q&#39;</span><span class="p">,</span><span class="s">&#39;X&#39;</span><span class="p">,</span><span class="s">&#39;Y&#39;</span><span class="p">]</span>
     
    11021322                <span class="n">Fmt</span> <span class="o">=</span> <span class="s">&#39; </span><span class="si">%s</span><span class="s">: (&#39;</span><span class="o">+</span><span class="n">fmt</span><span class="o">+</span><span class="s">&#39;)&#39;</span>
    11031323                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="n">Fmt</span><span class="o">%</span><span class="p">(</span><span class="n">item</span><span class="p">,</span><span class="n">insDef</span><span class="p">[</span><span class="n">item</span><span class="p">])),</span>
    1104                         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1324                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    11051325                <span class="n">itemVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="n">item</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    11061326                <span class="n">ValObj</span><span class="p">[</span><span class="n">itemVal</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">item</span><span class="p">,</span><span class="n">fmt</span><span class="p">]</span>
    11071327                <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    11081328                <span class="n">itemVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnItemValue</span><span class="p">)</span>
    1109                 <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1329                <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    11101330                <span class="k">if</span> <span class="ow">not</span> <span class="n">ifHisto</span> <span class="ow">and</span> <span class="n">item</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;difC&#39;</span><span class="p">,</span><span class="s">&#39;difA&#39;</span><span class="p">,</span><span class="s">&#39;Zero&#39;</span><span class="p">,]:</span>
    11111331                    <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
     
    11151335                    <span class="n">RefObj</span><span class="p">[</span><span class="n">itemRef</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="n">item</span>
    11161336                    <span class="n">itemRef</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnItemRef</span><span class="p">)</span>
    1117                     <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1118        
    1119     <span class="k">else</span><span class="p">:</span>                       <span class="c">#single crystal data</span>
     1337                    <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">itemRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1338       
     1339    <span class="k">elif</span> <span class="s">&#39;S&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]:</span>                       <span class="c">#single crystal data</span>
    11201340        <span class="k">if</span> <span class="s">&#39;C&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]:</span>               <span class="c">#constant wavelength</span>
    11211341            <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">u&#39; Lam (</span><span class="se">\xc5</span><span class="s">): (</span><span class="si">%10.6f</span><span class="s">)&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insDef</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">])),</span>
    1122                 <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1342                <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    11231343            <span class="n">waveVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%10.6f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    11241344            <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
    11251345            <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
    1126             <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1346            <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1347        <span class="k">else</span><span class="p">:</span>                                   <span class="c">#time of flight (neutrons)</span>
     1348            <span class="k">pass</span>                                <span class="c">#for now</span>
     1349    <span class="k">elif</span> <span class="s">&#39;L&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]:</span>
     1350        <span class="k">if</span> <span class="s">&#39;C&#39;</span> <span class="ow">in</span> <span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]:</span>       
     1351            <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">u&#39; Lam (</span><span class="se">\xc5</span><span class="s">): (</span><span class="si">%10.6f</span><span class="s">)&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insDef</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">])),</span>
     1352                <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1353            <span class="n">waveVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%10.6f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Lam&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     1354            <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
     1355            <span class="n">waveVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnWaveValue</span><span class="p">)</span>
     1356            <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">waveVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1357            <span class="n">instSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="s">&#39;  Azimuth: </span><span class="si">%7.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">insVal</span><span class="p">[</span><span class="s">&#39;Azimuth&#39;</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    11271358        <span class="k">else</span><span class="p">:</span>                                   <span class="c">#time of flight (neutrons)</span>
    11281359            <span class="k">pass</span>                                <span class="c">#for now</span>
     
    11401371       </div>
    11411372<div class="viewcode-block" id="UpdateSampleGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateSampleGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateSampleGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
    1142     <span class="sd">&#39;&#39;&#39;respond to selection of PWDR Sample Parameters</span>
     1373    <span class="sd">&#39;&#39;&#39;respond to selection of PWDR/SASD Sample Parameters</span>
    11431374<span class="sd">    data tree item.</span>
    11441375<span class="sd">    &#39;&#39;&#39;</span>
    1145     <span class="k">def</span> <span class="nf">SetCopyNames</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">addNames</span><span class="o">=</span><span class="p">[]):</span>
    1146         <span class="n">copyNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Scale&#39;</span><span class="p">,]</span>
    1147         <span class="n">dataType</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]</span>
    1148         <span class="n">histType</span> <span class="o">=</span> <span class="s">&#39;HKLF&#39;</span>
    1149         <span class="k">if</span> <span class="s">&#39;PWDR&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>          <span class="c">#else HKLF - only Scale</span>
    1150             <span class="n">histType</span> <span class="o">=</span> <span class="s">&#39;PWDR&#39;</span>
    1151             <span class="k">if</span> <span class="s">&#39;Debye&#39;</span> <span class="ow">in</span> <span class="n">dataType</span><span class="p">:</span>
    1152                 <span class="n">copyNames</span> <span class="o">+=</span> <span class="p">[</span><span class="s">&#39;DisplaceX&#39;</span><span class="p">,</span><span class="s">&#39;DisplaceY&#39;</span><span class="p">,</span><span class="s">&#39;Absorption&#39;</span><span class="p">]</span>
    1153             <span class="k">else</span><span class="p">:</span>       <span class="c">#Bragg-Brentano</span>
    1154                 <span class="n">copyNames</span> <span class="o">+=</span> <span class="p">[</span><span class="s">&#39;Shift&#39;</span><span class="p">,</span><span class="s">&#39;Transparency&#39;</span><span class="p">,</span><span class="s">&#39;SurfRoughA&#39;</span><span class="p">,</span><span class="s">&#39;SurfRoughB&#39;</span><span class="p">]</span>
    1155         <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">addNames</span><span class="p">):</span>
    1156          <span class="n">copyNames</span> <span class="o">+=</span> <span class="n">addNames</span>
    1157         <span class="k">return</span> <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span>
    1158        
     1376
    11591377    <span class="k">def</span> <span class="nf">OnSampleSave</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    11601378        <span class="sd">&#39;&#39;&#39;Respond to the Sample Parameters Operations/Save menu</span>
     
    11771395        <span class="k">finally</span><span class="p">:</span>
    11781396            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    1179                                                
    1180        
     1397           
    11811398    <span class="k">def</span> <span class="nf">OnSampleLoad</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    11821399        <span class="sd">&#39;&#39;&#39;Loads sample parameters from a G2 .samprm file</span>
     
    12071424            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    12081425   
     1426    <span class="k">def</span> <span class="nf">OnSetScale</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     1427        <span class="n">histList</span> <span class="o">=</span> <span class="p">[]</span>
     1428        <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetFirstChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">)</span>
     1429        <span class="k">while</span> <span class="n">item</span><span class="p">:</span>
     1430            <span class="n">name</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
     1431            <span class="k">if</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">name</span> <span class="ow">and</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">histName</span><span class="p">:</span>
     1432                <span class="n">histList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
     1433            <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetNextChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">cookie</span><span class="p">)</span>
     1434        <span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">histList</span><span class="p">):</span>      <span class="c">#nothing to copy to!</span>
     1435            <span class="k">return</span>
     1436        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SingleChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="s">&#39;Select reference histogram for scaling&#39;</span><span class="p">,</span>
     1437            <span class="s">&#39;Reference histogram&#39;</span><span class="p">,</span><span class="n">histList</span><span class="p">)</span>
     1438        <span class="k">try</span><span class="p">:</span>
     1439            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     1440                <span class="n">sel</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">()</span>
     1441                <span class="n">refHist</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="n">sel</span><span class="p">]</span>
     1442        <span class="k">finally</span><span class="p">:</span>
     1443            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     1444        <span class="n">Limits</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Limits&#39;</span><span class="p">))</span>
     1445        <span class="n">Profile</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
     1446        <span class="n">Data</span> <span class="o">=</span> <span class="p">[</span><span class="n">Profile</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">data</span><span class="p">]</span>
     1447        <span class="n">refId</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">refHist</span><span class="p">)</span>
     1448        <span class="n">refSample</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">refId</span><span class="p">,</span> <span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
     1449        <span class="n">refLimits</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">refId</span><span class="p">,</span> <span class="s">&#39;Limits&#39;</span><span class="p">))</span>
     1450        <span class="n">refProfile</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">refId</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
     1451        <span class="n">refData</span> <span class="o">=</span> <span class="p">[</span><span class="n">refProfile</span><span class="p">,</span><span class="n">refLimits</span><span class="p">,</span><span class="n">refSample</span><span class="p">]</span>
     1452        <span class="n">G2sasd</span><span class="o">.</span><span class="n">SetScale</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span><span class="n">refData</span><span class="p">)</span>
     1453        <span class="n">UpdateSampleGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>       
     1454        <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;SASD&#39;</span><span class="p">,</span><span class="n">newPlot</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
     1455       
    12091456    <span class="k">def</span> <span class="nf">OnSampleCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    1210         <span class="n">histName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
    1211         <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span> <span class="o">=</span> <span class="n">SetCopyNames</span><span class="p">(</span>
    1212             <span class="n">histName</span><span class="p">,</span>
    1213             <span class="n">addNames</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;Omega&#39;</span><span class="p">,</span><span class="s">&#39;Chi&#39;</span><span class="p">,</span><span class="s">&#39;Phi&#39;</span><span class="p">,</span><span class="s">&#39;Gonio. radius&#39;</span><span class="p">,</span><span class="s">&#39;InstrName&#39;</span><span class="p">])</span>
     1457        <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span> <span class="o">=</span> <span class="n">SetCopyNames</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">],</span>
     1458            <span class="n">addNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Omega&#39;</span><span class="p">,</span><span class="s">&#39;Chi&#39;</span><span class="p">,</span><span class="s">&#39;Phi&#39;</span><span class="p">,</span><span class="s">&#39;Gonio. radius&#39;</span><span class="p">,</span><span class="s">&#39;InstrName&#39;</span><span class="p">])</span>
    12141459        <span class="n">copyDict</span> <span class="o">=</span> <span class="p">{}</span>
    12151460        <span class="k">for</span> <span class="n">parm</span> <span class="ow">in</span> <span class="n">copyNames</span><span class="p">:</span>
    12161461            <span class="n">copyDict</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span>
    1217         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">histType</span><span class="p">,]</span>
    1218         <span class="n">AllList</span> <span class="o">=</span> <span class="p">{}</span>
    1219         <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetFirstChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">)</span>
    1220         <span class="k">while</span> <span class="n">item</span><span class="p">:</span>
    1221             <span class="n">name</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
    1222             <span class="k">if</span> <span class="n">histType</span> <span class="ow">in</span> <span class="n">name</span> <span class="ow">and</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">histName</span><span class="p">:</span>
    1223                 <span class="n">allname</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39; Azm=&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
    1224                 <span class="k">if</span> <span class="n">allname</span> <span class="ow">in</span> <span class="n">AllList</span><span class="p">:</span>
    1225                     <span class="n">AllList</span><span class="p">[</span><span class="n">allname</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span>
    1226                 <span class="k">else</span><span class="p">:</span>
    1227                     <span class="n">AllList</span><span class="p">[</span><span class="n">allname</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
    1228                 <span class="n">histList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
    1229             <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetNextChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">cookie</span><span class="p">)</span>
    1230         <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">histList</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>      <span class="c">#nothing to copy to!</span>
     1462        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1463        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     1464        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     1465            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
    12311466            <span class="k">return</span>
    1232         <span class="n">nAll</span> <span class="o">=</span> <span class="mi">0</span>
    1233         <span class="n">AllNames</span> <span class="o">=</span> <span class="n">AllList</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
    1234         <span class="n">AllNames</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
    1235         <span class="k">for</span> <span class="n">allname</span> <span class="ow">in</span> <span class="n">AllNames</span><span class="p">:</span>
    1236             <span class="k">if</span> <span class="n">AllList</span><span class="p">[</span><span class="n">allname</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
    1237                 <span class="n">histList</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">nAll</span><span class="p">,</span><span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">allname</span><span class="p">)</span>
    1238                 <span class="n">nAll</span> <span class="o">+=</span> <span class="mi">1</span>
    1239         <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    1240         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="s">&#39;Copy parameters from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">histName</span><span class="p">,</span>
    1241             <span class="s">&#39;Copy parameters&#39;</span><span class="p">,</span><span class="n">histList</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     1467        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1468            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1469            <span class="s">&#39;Copy sample params from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     1470            <span class="s">&#39;Copy sample parameters&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    12421471        <span class="k">try</span><span class="p">:</span>
    12431472            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    12441473                <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    12451474                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
    1246                     <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    1247                 <span class="k">for</span> <span class="n">allname</span> <span class="ow">in</span> <span class="n">AllList</span><span class="p">:</span>
    1248                     <span class="k">if</span> <span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">allname</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    1249                         <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    1250                         <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">histList</span><span class="p">:</span>
    1251                             <span class="k">if</span> <span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39; Azm=&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">allname</span><span class="p">:</span>
    1252                                 <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
    1253                         <span class="k">break</span>       <span class="c">#only one All allowed</span>
    1254                 <span class="k">if</span> <span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">histType</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    1255                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="o">+</span><span class="n">nAll</span><span class="p">:]</span>
    1256             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    1257                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    1258                 <span class="n">sampleData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
    1259                 <span class="n">sampleData</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">copyDict</span><span class="p">))</span>
     1475                    <span class="n">item</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
     1476                    <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     1477                    <span class="n">sampleData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
     1478                    <span class="n">sampleData</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">copyDict</span><span class="p">))</span>
     1479        <span class="k">finally</span><span class="p">:</span>
     1480            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     1481
     1482    <span class="k">def</span> <span class="nf">OnSampleCopySelected</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     1483        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1484        <span class="n">Controls</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     1485            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="s">&#39;Controls&#39;</span><span class="p">))</span>
     1486        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     1487        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     1488            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     1489            <span class="k">return</span>
     1490        <span class="c"># Assemble a list of item labels</span>
     1491        <span class="n">TextTable</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span><span class="n">label</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span><span class="n">label</span><span class="p">,</span><span class="n">dig</span> <span class="ow">in</span>
     1492                     <span class="n">SetupSampleLabels</span><span class="p">(</span><span class="n">hst</span><span class="p">,</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;Type&#39;</span><span class="p">))</span>
     1493                     <span class="p">}</span>
     1494        <span class="c"># get flexible labels</span>
     1495        <span class="n">TextTable</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
     1496            <span class="n">key</span><span class="p">:</span><span class="n">Controls</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">Controls</span> <span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">&#39;FreePrm&#39;</span><span class="p">)</span>
     1497            <span class="p">})</span>
     1498        <span class="c"># add a few extra</span>
     1499        <span class="n">TextTable</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
     1500            <span class="s">&#39;Type&#39;</span><span class="p">:</span><span class="s">&#39;Diffractometer type&#39;</span><span class="p">,</span>
     1501            <span class="s">&#39;InstrName&#39;</span><span class="p">:</span><span class="s">&#39;Instrument Name&#39;</span><span class="p">,</span>
     1502            <span class="p">})</span>
     1503        <span class="c"># Assemble a list of dict entries that would be labeled in the Sample</span>
     1504        <span class="c"># params data window (drop ranId and items not used).</span>
     1505        <span class="n">keyList</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span> <span class="k">if</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">TextTable</span><span class="p">]</span>
     1506        <span class="n">keyText</span> <span class="o">=</span> <span class="p">[</span><span class="n">TextTable</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">keyList</span><span class="p">]</span>
     1507        <span class="c"># sort both lists together, ordered by keyText</span>
     1508        <span class="n">keyText</span><span class="p">,</span> <span class="n">keyList</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="nb">sorted</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">keyText</span><span class="p">,</span><span class="n">keyList</span><span class="p">)))</span> <span class="c"># sort lists </span>
     1509        <span class="n">selectedKeys</span> <span class="o">=</span> <span class="p">[]</span>
     1510        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1511            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1512            <span class="s">&#39;Select which sample parameters</span><span class="se">\n</span><span class="s">to copy&#39;</span><span class="p">,</span>
     1513            <span class="s">&#39;Select sample parameters&#39;</span><span class="p">,</span> <span class="n">keyText</span><span class="p">)</span>
     1514        <span class="k">try</span><span class="p">:</span>
     1515            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     1516                <span class="n">selectedKeys</span> <span class="o">=</span> <span class="p">[</span><span class="n">keyList</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()]</span>
     1517        <span class="k">finally</span><span class="p">:</span>
     1518            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     1519        <span class="k">if</span> <span class="ow">not</span> <span class="n">selectedKeys</span><span class="p">:</span> <span class="k">return</span> <span class="c"># nothing to copy</span>
     1520        <span class="n">copyDict</span> <span class="o">=</span> <span class="p">{}</span>
     1521        <span class="k">for</span> <span class="n">parm</span> <span class="ow">in</span> <span class="n">selectedKeys</span><span class="p">:</span>
     1522            <span class="n">copyDict</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span>
     1523        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1524            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1525            <span class="s">&#39;Copy sample params from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     1526            <span class="s">&#39;Copy sample parameters&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
     1527        <span class="k">try</span><span class="p">:</span>
     1528            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     1529                <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
     1530                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
     1531                    <span class="n">item</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
     1532                    <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     1533                    <span class="n">sampleData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
     1534                    <span class="n">sampleData</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">copyDict</span><span class="p">))</span>
    12601535        <span class="k">finally</span><span class="p">:</span>
    12611536            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    12621537
    12631538    <span class="k">def</span> <span class="nf">OnSampleFlagCopy</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    1264         <span class="n">histName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
    1265         <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span> <span class="o">=</span> <span class="n">SetCopyNames</span><span class="p">(</span><span class="n">histName</span><span class="p">)</span>
     1539        <span class="n">histType</span><span class="p">,</span><span class="n">copyNames</span> <span class="o">=</span> <span class="n">SetCopyNames</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">])</span>
    12661540        <span class="n">flagDict</span> <span class="o">=</span> <span class="p">{}</span>
    12671541        <span class="k">for</span> <span class="n">parm</span> <span class="ow">in</span> <span class="n">copyNames</span><span class="p">:</span>
    12681542            <span class="n">flagDict</span><span class="p">[</span><span class="n">parm</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">parm</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
    1269         <span class="n">histList</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">histType</span><span class="p">,]</span>
    1270         <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetFirstChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">)</span>
    1271         <span class="k">while</span> <span class="n">item</span><span class="p">:</span>
    1272             <span class="n">name</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
    1273             <span class="k">if</span> <span class="n">histType</span> <span class="ow">in</span> <span class="n">name</span> <span class="ow">and</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">histName</span><span class="p">:</span>
    1274                 <span class="n">histList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
    1275             <span class="n">item</span><span class="p">,</span> <span class="n">cookie</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetNextChild</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">cookie</span><span class="p">)</span>
    1276         <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">histList</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>      <span class="c">#nothing to copy to!</span>
     1543        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     1544        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     1545        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     1546            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
    12771547            <span class="k">return</span>
    1278         <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
    1279         <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="s">&#39;Copy parameters from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">histName</span><span class="p">,</span>
    1280             <span class="s">&#39;Copy refinement flags&#39;</span><span class="p">,</span><span class="n">histList</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     1548        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     1549            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     1550            <span class="s">&#39;Copy sample ref. flags from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:])</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     1551            <span class="s">&#39;Copy sample flags&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
    12811552        <span class="k">try</span><span class="p">:</span>
    12821553            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
    12831554                <span class="n">result</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">()</span>
    12841555                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
    1285                     <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
    1286                 <span class="k">if</span> <span class="s">&#39;All &#39;</span><span class="o">+</span><span class="n">histType</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    1287                     <span class="n">copyList</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
    1288             <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
    1289                 <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
    1290                 <span class="n">sampleData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
    1291                 <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">copyNames</span><span class="p">:</span>
    1292                     <span class="n">sampleData</span><span class="p">[</span><span class="n">name</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flagDict</span><span class="p">[</span><span class="n">name</span><span class="p">])</span>
     1556                    <span class="n">item</span> <span class="o">=</span> <span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
     1557                    <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     1558                    <span class="n">sampleData</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">))</span>
     1559                    <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">copyNames</span><span class="p">:</span>
     1560                        <span class="n">sampleData</span><span class="p">[</span><span class="n">name</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">flagDict</span><span class="p">[</span><span class="n">name</span><span class="p">])</span>
    12931561        <span class="k">finally</span><span class="p">:</span>
    12941562            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    12951563
    1296     <span class="k">def</span> <span class="nf">OnScaleRef</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    1297         <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
    1298         <span class="n">data</span><span class="p">[</span><span class="s">&#39;Scale&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
    1299        
    1300     <span class="k">def</span> <span class="nf">OnScaleVal</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    1301         <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
    1302         <span class="k">try</span><span class="p">:</span>
    1303             <span class="n">scale</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span>
    1304             <span class="k">if</span> <span class="n">scale</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
    1305                 <span class="n">data</span><span class="p">[</span><span class="s">&#39;Scale&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">scale</span>
    1306         <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
    1307             <span class="k">pass</span>
    1308         <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%.4f</span><span class="s">&quot;</span><span class="o">%</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Scale&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>          <span class="c">#reset in case of error</span>
    1309        
    13101564    <span class="k">def</span> <span class="nf">OnHistoType</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    13111565        <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     
    13221576    <span class="k">def</span> <span class="nf">OnNameVal</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
    13231577        <span class="n">event</span><span class="o">.</span><span class="n">Skip</span><span class="p">()</span>
    1324         <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">SetNameVal</span><span class="p">)</span>       
     1578        <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">SetNameVal</span><span class="p">)</span>
     1579       
     1580    <span class="k">def</span> <span class="nf">AfterChange</span><span class="p">(</span><span class="n">invalid</span><span class="p">,</span><span class="n">value</span><span class="p">,</span><span class="n">tc</span><span class="p">):</span>
     1581        <span class="k">if</span> <span class="n">invalid</span><span class="p">:</span>
     1582            <span class="k">return</span>
     1583        <span class="k">if</span> <span class="n">tc</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>          <span class="c">#a kluge for Scale!</span>
     1584            <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;SASD&#39;</span><span class="p">,</span><span class="n">newPlot</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
     1585        <span class="k">elif</span> <span class="n">tc</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;Thick&#39;</span><span class="p">:</span>
     1586            <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateSampleGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>           
     1587           
     1588    <span class="k">def</span> <span class="nf">OnMaterial</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     1589        <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     1590        <span class="nb">id</span><span class="p">,</span><span class="n">key</span> <span class="o">=</span> <span class="n">Info</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     1591        <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;Name&#39;</span><span class="p">:</span>
     1592            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">][</span><span class="nb">id</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     1593        <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;VolFrac&#39;</span><span class="p">:</span>
     1594            <span class="k">try</span><span class="p">:</span>
     1595                <span class="n">value</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="mf">0.</span><span class="p">,</span><span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())),</span><span class="mf">1.</span><span class="p">)</span>
     1596            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     1597                <span class="n">value</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">][</span><span class="nb">id</span><span class="p">][</span><span class="n">key</span><span class="p">]</span>
     1598            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">][</span><span class="nb">id</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     1599            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">][</span><span class="ow">not</span> <span class="nb">id</span><span class="p">][</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.</span><span class="o">-</span><span class="n">value</span>
     1600        <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateSampleGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
    13251601
    13261602    <span class="c">######## DEBUG #######################################################</span>
     
    13291605    <span class="c">#reload(G2gd)</span>
    13301606    <span class="c">######################################################################</span>
     1607    <span class="n">histName</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
    13311608    <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">:</span>
    13321609        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Clear</span><span class="p">()</span>
    13331610    <span class="n">G2gd</span><span class="o">.</span><span class="n">SetDataMenuBar</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SampleMenu</span><span class="p">)</span>
    13341611    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SetLabel</span><span class="p">(</span><span class="s">&#39;Sample Parameters&#39;</span><span class="p">)</span>
     1612    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSetScale</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SETSCALE</span><span class="p">)</span>
    13351613    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSampleCopy</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SAMPLECOPY</span><span class="p">)</span>
     1614    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSampleCopySelected</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SAMPLECOPYSOME</span><span class="p">)</span>
    13361615    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSampleFlagCopy</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SAMPLEFLAGCOPY</span><span class="p">)</span>
    13371616    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSampleSave</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SAMPLESAVE</span><span class="p">)</span>
    13381617    <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSampleLoad</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SAMPLELOAD</span><span class="p">)</span>
     1618    <span class="k">if</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     1619        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SetScale</span><span class="o">.</span><span class="n">Enable</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
    13391620    <span class="k">if</span> <span class="ow">not</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">GetStatusBar</span><span class="p">():</span>
    13401621        <span class="n">Status</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">CreateStatusBar</span><span class="p">()</span>   
     
    13631644    <span class="k">if</span> <span class="s">&#39;FreePrm3&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
    13641645        <span class="n">data</span><span class="p">[</span><span class="s">&#39;FreePrm3&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span>
    1365     <span class="k">if</span> <span class="s">&#39;SurfRoughA&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
     1646    <span class="k">if</span> <span class="s">&#39;SurfRoughA&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span> <span class="s">&#39;PWDR&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
    13661647        <span class="n">data</span><span class="p">[</span><span class="s">&#39;SurfRoughA&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.</span><span class="p">,</span><span class="bp">False</span><span class="p">]</span>
    13671648        <span class="n">data</span><span class="p">[</span><span class="s">&#39;SurfRoughB&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.</span><span class="p">,</span><span class="bp">False</span><span class="p">]</span>
     1649    <span class="k">if</span> <span class="s">&#39;Trans&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     1650        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Trans&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span>
    13681651<span class="c">#patch end</span>
    13691652   
    1370     <span class="n">parms</span> <span class="o">=</span> <span class="p">[]</span>
    1371     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Scale&#39;</span><span class="p">,</span><span class="s">&#39;Histogram scale factor: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]])</span>
    1372     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Gonio. radius&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer radius (mm): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1373     <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Debye-Scherrer&#39;</span><span class="p">:</span>
    1374         <span class="n">parms</span> <span class="o">+=</span> <span class="p">[[</span><span class="s">&#39;DisplaceX&#39;</span><span class="p">,</span><span class="s">u&#39;Sample X displ. perp. to beam (</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
    1375             <span class="p">[</span><span class="s">&#39;DisplaceY&#39;</span><span class="p">,</span><span class="s">u&#39;Sample Y displ. || to beam (</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
    1376             <span class="p">[</span><span class="s">&#39;Absorption&#39;</span><span class="p">,</span><span class="s">u&#39;Sample absorption (</span><span class="se">\xb5\xb7</span><span class="s">r): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],]</span>
    1377     <span class="k">elif</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Bragg-Brentano&#39;</span><span class="p">:</span>
    1378         <span class="n">parms</span> <span class="o">+=</span> <span class="p">[[</span><span class="s">&#39;Shift&#39;</span><span class="p">,</span><span class="s">u&#39;Sample displacement(</span><span class="se">\xb5</span><span class="s">m): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],</span>
    1379             <span class="p">[</span><span class="s">&#39;Transparency&#39;</span><span class="p">,</span><span class="s">u&#39;Sample transparency(1/</span><span class="se">\xb5</span><span class="s">eff, cm): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]],</span>
    1380             <span class="p">[</span><span class="s">&#39;SurfRoughA&#39;</span><span class="p">,</span><span class="s">&#39;Surface roughness A: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]],</span>
    1381             <span class="p">[</span><span class="s">&#39;SurfRoughB&#39;</span><span class="p">,</span><span class="s">&#39;Surface roughness B: &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">4</span><span class="p">]]]</span>
    1382     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Omega&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer omega:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1383     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Chi&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer chi:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1384     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Phi&#39;</span><span class="p">,</span><span class="s">&#39;Goniometer phi:&#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1385     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Temperature&#39;</span><span class="p">,</span><span class="s">&#39;Sample temperature (K): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1386     <span class="n">parms</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="s">&#39;Pressure&#39;</span><span class="p">,</span><span class="s">&#39;Sample pressure (MPa): &#39;</span><span class="p">,[</span><span class="mi">10</span><span class="p">,</span><span class="mi">3</span><span class="p">]])</span>
    1387                
     1653    <span class="n">parms</span> <span class="o">=</span> <span class="n">SetupSampleLabels</span><span class="p">(</span><span class="n">histName</span><span class="p">,</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;Type&#39;</span><span class="p">))</span>
    13881654    <span class="n">mainSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
    13891655    <span class="n">topSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
     
    13941660    <span class="n">nameSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    13951661    <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39; Instrument Name&#39;</span><span class="p">),</span>
    1396                 <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     1662                <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    13971663    <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="mi">1</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
    13981664    <span class="n">instNameVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;InstrName&#39;</span><span class="p">,</span><span class="s">&#39;&#39;</span><span class="p">),</span>
     
    14031669    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    14041670
    1405     <span class="n">nameSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    1406     <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39; Diffractometer type: &#39;</span><span class="p">),</span>
    1407                 <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1408     <span class="n">choices</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Debye-Scherrer&#39;</span><span class="p">,</span><span class="s">&#39;Bragg-Brentano&#39;</span><span class="p">,]</span>
    1409     <span class="n">histoType</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">choices</span><span class="p">,</span>
    1410         <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
    1411     <span class="n">histoType</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span> <span class="n">OnHistoType</span><span class="p">)</span>
    1412     <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">histoType</span><span class="p">)</span>
    1413     <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">nameSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
    1414     <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
     1671    <span class="k">if</span> <span class="s">&#39;PWDR&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     1672        <span class="n">nameSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
     1673        <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="s">&#39; Diffractometer type: &#39;</span><span class="p">),</span>
     1674                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1675        <span class="n">choices</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Debye-Scherrer&#39;</span><span class="p">,</span><span class="s">&#39;Bragg-Brentano&#39;</span><span class="p">,]</span>
     1676        <span class="n">histoType</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ID_ANY</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Type&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">choices</span><span class="p">,</span>
     1677            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     1678        <span class="n">histoType</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span> <span class="n">OnHistoType</span><span class="p">)</span>
     1679        <span class="n">nameSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">histoType</span><span class="p">)</span>
     1680        <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">nameSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
     1681        <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    14151682
    14161683    <span class="n">parmSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     
    14181685        <span class="k">if</span> <span class="s">&#39;list&#39;</span> <span class="ow">in</span> <span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">])):</span>
    14191686            <span class="n">parmRef</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="s">&#39; &#39;</span><span class="o">+</span><span class="n">lbl</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">],</span><span class="mi">1</span><span class="p">)</span>
    1420             <span class="n">parmSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">parmRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
    1421             <span class="n">parmVal</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">],</span><span class="mi">0</span><span class="p">,</span><span class="n">nDig</span><span class="o">=</span><span class="n">nDig</span><span class="p">,</span><span class="n">typeHint</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span>
     1687            <span class="n">parmSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">parmRef</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
     1688            <span class="n">parmVal</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">],</span><span class="mi">0</span><span class="p">,</span>
     1689                <span class="n">nDig</span><span class="o">=</span><span class="n">nDig</span><span class="p">,</span><span class="n">typeHint</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span><span class="n">OnLeave</span><span class="o">=</span><span class="n">AfterChange</span><span class="p">)</span>
    14221690        <span class="k">else</span><span class="p">:</span>
    14231691            <span class="n">parmSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; &#39;</span><span class="o">+</span><span class="n">lbl</span><span class="p">),</span>
    1424                 <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
    1425             <span class="n">parmVal</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">data</span><span class="p">,</span><span class="n">key</span><span class="p">,</span><span class="n">typeHint</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span>
     1692                <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
     1693            <span class="n">parmVal</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">data</span><span class="p">,</span><span class="n">key</span><span class="p">,</span>
     1694                <span class="n">typeHint</span><span class="o">=</span><span class="nb">float</span><span class="p">,</span><span class="n">OnLeave</span><span class="o">=</span><span class="n">AfterChange</span><span class="p">)</span>
    14261695        <span class="n">parmSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">parmVal</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
     1696    <span class="n">Info</span> <span class="o">=</span> <span class="p">{}</span>
     1697
     1698       
    14271699    <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="p">(</span><span class="s">&#39;FreePrm1&#39;</span><span class="p">,</span><span class="s">&#39;FreePrm2&#39;</span><span class="p">,</span><span class="s">&#39;FreePrm3&#39;</span><span class="p">):</span>
    14281700        <span class="n">parmVal</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">Controls</span><span class="p">,</span><span class="n">key</span><span class="p">,</span><span class="n">typeHint</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span>
     
    14331705    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">parmSizer</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="p">)</span>
    14341706    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>   
     1707    <span class="k">if</span> <span class="s">&#39;SASD&#39;</span> <span class="ow">in</span> <span class="n">histName</span><span class="p">:</span>
     1708        <span class="n">rho</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.</span><span class="p">,</span><span class="mf">0.</span><span class="p">]</span>
     1709        <span class="n">anomrho</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.</span><span class="p">,</span><span class="mf">0.</span><span class="p">]</span>
     1710        <span class="n">mu</span> <span class="o">=</span> <span class="mf">0.</span>
     1711        <span class="n">subSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     1712        <span class="n">Substances</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span>
     1713            <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Substances&#39;</span><span class="p">))</span>
     1714        <span class="k">for</span> <span class="nb">id</span><span class="p">,</span><span class="n">item</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Materials&#39;</span><span class="p">]):</span>
     1715            <span class="n">subSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Material: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1716            <span class="n">matsel</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s">&#39;Name&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">Substances</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span>
     1717                <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     1718            <span class="n">Info</span><span class="p">[</span><span class="n">matsel</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="nb">id</span><span class="p">,</span><span class="s">&#39;Name&#39;</span><span class="p">]</span>
     1719            <span class="n">matsel</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnMaterial</span><span class="p">)</span>       
     1720            <span class="n">subSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">matsel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1721            <span class="n">subSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Volume fraction: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1722            <span class="n">volfrac</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%.3f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s">&#39;VolFrac&#39;</span><span class="p">])),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     1723            <span class="n">Info</span><span class="p">[</span><span class="n">volfrac</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="nb">id</span><span class="p">,</span><span class="s">&#39;VolFrac&#39;</span><span class="p">]</span>
     1724            <span class="n">volfrac</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnMaterial</span><span class="p">)</span>
     1725            <span class="n">volfrac</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnMaterial</span><span class="p">)</span>
     1726            <span class="n">subSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">volfrac</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1727            <span class="n">material</span> <span class="o">=</span> <span class="n">Substances</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">item</span><span class="p">[</span><span class="s">&#39;Name&#39;</span><span class="p">]]</span>
     1728            <span class="n">mu</span> <span class="o">+=</span> <span class="n">item</span><span class="p">[</span><span class="s">&#39;VolFrac&#39;</span><span class="p">]</span><span class="o">*</span><span class="n">material</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">,</span><span class="mf">0.</span><span class="p">)</span>
     1729            <span class="n">rho</span><span class="p">[</span><span class="nb">id</span><span class="p">]</span> <span class="o">=</span> <span class="n">material</span><span class="p">[</span><span class="s">&#39;Scatt density&#39;</span><span class="p">]</span>
     1730            <span class="n">anomrho</span><span class="p">[</span><span class="nb">id</span><span class="p">]</span> <span class="o">=</span> <span class="n">material</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;XAnom density&#39;</span><span class="p">,</span><span class="mf">0.</span><span class="p">)</span>
     1731        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Contrast&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[(</span><span class="n">rho</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">rho</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">**</span><span class="mi">2</span><span class="p">,(</span><span class="n">anomrho</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">anomrho</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">**</span><span class="mi">2</span><span class="p">]</span>
     1732        <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">subSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     1733        <span class="n">conSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
     1734        <span class="n">conSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Contrast: </span><span class="si">%10.2f</span><span class="s"> &#39;</span><span class="o">%</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Contrast&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1735        <span class="n">conSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Anom. Contrast: </span><span class="si">%10.2f</span><span class="s"> &#39;</span><span class="o">%</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Contrast&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">])),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1736        <span class="n">mut</span> <span class="o">=</span>  <span class="n">mu</span><span class="o">*</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Thick&#39;</span><span class="p">]</span>
     1737        <span class="n">conSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Transmission (calc): </span><span class="si">%10.3f</span><span class="s">  &#39;</span><span class="o">%</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">mut</span><span class="p">))),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     1738        <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">conSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    14351739   
    14361740    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Layout</span><span class="p">()</span>   
     
    19002204        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">MakeNewPhase</span><span class="o">.</span><span class="n">Enable</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>       
    19012205    <span class="n">mainSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
    1902     <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Indexing controls: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2206    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Indexing controls: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19032207    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    19042208    <span class="n">littleSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
    1905     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Max Nc/Nobs &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2209    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Max Nc/Nobs &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19062210    <span class="n">NcNo</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SpinCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">)</span>
    19072211    <span class="n">NcNo</span><span class="o">.</span><span class="n">SetRange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">6</span><span class="p">)</span>
    19082212    <span class="n">NcNo</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
    19092213    <span class="n">NcNo</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_SPINCTRL</span><span class="p">,</span><span class="n">OnNcNo</span><span class="p">)</span>
    1910     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">NcNo</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1911     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Start Volume &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2214    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">NcNo</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2215    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Start Volume &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19122216    <span class="n">startVol</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%d</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">3</span><span class="p">])),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    19132217    <span class="n">startVol</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnStartVol</span><span class="p">)</span>
    19142218    <span class="n">startVol</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnStartVol</span><span class="p">)</span>
    1915     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">startVol</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2219    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">startVol</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19162220    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">littleSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    19172221    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    19182222    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Select Bravais Lattices for indexing: &#39;</span><span class="p">),</span>
    1919         <span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2223        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19202224    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    19212225    <span class="n">littleSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     
    19272231        <span class="n">bravCk</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">brav</span><span class="p">)</span>
    19282232        <span class="n">bravCk</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span><span class="n">OnBravais</span><span class="p">)</span>
    1929         <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bravCk</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2233        <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bravCk</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19302234    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">littleSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    19312235    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    19322236   
    1933     <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Cell Refinement: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2237    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Cell Refinement: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19342238    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
    19352239    <span class="n">littleSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
    1936     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Bravais lattice &quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2240    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Bravais lattice &quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19372241    <span class="n">bravSel</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Choice</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">choices</span><span class="o">=</span><span class="n">bravaisSymb</span><span class="p">)</span>
    19382242    <span class="n">bravSel</span><span class="o">.</span><span class="n">SetSelection</span><span class="p">(</span><span class="n">bravaisSymb</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">5</span><span class="p">]))</span>
    19392243    <span class="n">bravSel</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHOICE</span><span class="p">,</span><span class="n">OnBravSel</span><span class="p">)</span>
    1940     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bravSel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1941     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Space group &quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2244    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">bravSel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2245    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Space group &quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19422246    <span class="n">spcSel</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Choice</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">choices</span><span class="o">=</span><span class="n">SPGlist</span><span class="p">[</span><span class="n">controls</span><span class="p">[</span><span class="mi">5</span><span class="p">]])</span>
    19432247    <span class="n">spcSel</span><span class="o">.</span><span class="n">SetSelection</span><span class="p">(</span><span class="n">SPGlist</span><span class="p">[</span><span class="n">controls</span><span class="p">[</span><span class="mi">5</span><span class="p">]]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">13</span><span class="p">]))</span>
    19442248    <span class="n">spcSel</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHOICE</span><span class="p">,</span><span class="n">OnSpcSel</span><span class="p">)</span>
    1945     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">spcSel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
    1946     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Zero offset&quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2249    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">spcSel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2250    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot; Zero offset&quot;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19472251    <span class="n">zero</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&quot;</span><span class="si">%.4f</span><span class="s">&quot;</span><span class="o">%</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    19482252    <span class="n">zero</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnZero</span><span class="p">)</span>
    19492253    <span class="n">zero</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnZero</span><span class="p">)</span>
    1950     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">zero</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2254    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">zero</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19512255    <span class="n">zeroVar</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot;Refine?&quot;</span><span class="p">)</span>
    19522256    <span class="n">zeroVar</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
    19532257    <span class="n">zeroVar</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span><span class="n">OnZeroVar</span><span class="p">)</span>
    1954     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">zeroVar</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2258    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">zeroVar</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19552259    <span class="n">hklShow</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&quot;Show hkl positions&quot;</span><span class="p">)</span>
    19562260    <span class="n">hklShow</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_BUTTON</span><span class="p">,</span><span class="n">OnHklShow</span><span class="p">)</span>
    1957     <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">hklShow</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2261    <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">hklShow</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19582262    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">littleSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    19592263   
     
    19662270    <span class="n">littleSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="n">useGUI</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
    19672271    <span class="k">for</span> <span class="n">txt</span><span class="p">,</span><span class="n">fmt</span><span class="p">,</span><span class="n">ifEdit</span><span class="p">,</span><span class="n">Id</span> <span class="ow">in</span> <span class="n">useGUI</span><span class="p">[</span><span class="mi">2</span><span class="p">]:</span>
    1968         <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="n">txt</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2272        <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="n">txt</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19692273        <span class="k">if</span> <span class="n">ifEdit</span><span class="p">:</span>          <span class="c">#a,b,c,etc.</span>
    19702274            <span class="n">cellVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="p">(</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">6</span><span class="o">+</span><span class="n">Id</span><span class="p">])),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
    19712275            <span class="n">cellVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnCellChange</span><span class="p">)</span>       
    19722276            <span class="n">cellVal</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnCellChange</span><span class="p">)</span>
    1973             <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">cellVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2277            <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">cellVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19742278            <span class="n">cellList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cellVal</span><span class="o">.</span><span class="n">GetId</span><span class="p">())</span>
    19752279        <span class="k">else</span><span class="p">:</span>               <span class="c">#volume</span>
    19762280            <span class="n">volVal</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="p">(</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">controls</span><span class="p">[</span><span class="mi">12</span><span class="p">])),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_READONLY</span><span class="p">)</span>
    19772281            <span class="n">volVal</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="n">VERY_LIGHT_GREY</span><span class="p">)</span>
    1978             <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">volVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">wx</span><span class="o">.</span><span class="n">ALIGN_CENTER_VERTICAL</span><span class="p">)</span>
     2282            <span class="n">littleSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">volVal</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
    19792283    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">littleSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
    19802284       
     
    20592363                <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
    20602364            <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     2365           
     2366        <span class="k">def</span> <span class="nf">OnPlotHKL</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2367            <span class="n">FoMax</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">8</span><span class="p">])</span>
     2368            <span class="n">controls</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Type&#39;</span> <span class="p">:</span> <span class="s">&#39;Fo&#39;</span><span class="p">,</span><span class="s">&#39;ifFc&#39;</span> <span class="p">:</span> <span class="bp">True</span><span class="p">,</span>     
     2369                <span class="s">&#39;HKLmax&#39;</span> <span class="p">:</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">1</span><span class="p">])),</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">2</span><span class="p">]))],</span>
     2370                <span class="s">&#39;HKLmin&#39;</span> <span class="p">:</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">0</span><span class="p">])),</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">1</span><span class="p">])),</span><span class="nb">int</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">refList</span><span class="o">.</span><span class="n">T</span><span class="p">[</span><span class="mi">2</span><span class="p">]))],</span>
     2371                <span class="s">&#39;FoMax&#39;</span> <span class="p">:</span> <span class="n">FoMax</span><span class="p">,</span><span class="s">&#39;Zone&#39;</span> <span class="p">:</span> <span class="s">&#39;001&#39;</span><span class="p">,</span><span class="s">&#39;Layer&#39;</span> <span class="p">:</span> <span class="mi">0</span><span class="p">,</span><span class="s">&#39;Scale&#39;</span> <span class="p">:</span> <span class="mf">1.0</span><span class="p">,}</span>
     2372            <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotSngl</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newPlot</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span><span class="n">Data</span><span class="o">=</span><span class="n">controls</span><span class="p">,</span><span class="n">hklRef</span><span class="o">=</span><span class="n">refList</span><span class="p">,</span><span class="n">Title</span><span class="o">=</span><span class="n">phaseName</span><span class="p">)</span>
    20612373       
    20622374    <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">:</span>
     
    20712383            <span class="n">Status</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">CreateStatusBar</span><span class="p">()</span>   
    20722384        <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnSelectPhase</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_SELECTPHASE</span><span class="p">)</span>
     2385        <span class="n">G2frame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnPlotHKL</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_PWDHKLPLOT</span><span class="p">)</span>   <span class="c">#not work yet</span>
    20732386        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SelectPhase</span><span class="o">.</span><span class="n">Enable</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
    20742387        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
     
    21022415    <span class="n">size</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">GetSize</span><span class="p">()</span>
    21032416    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">setSizePosLeft</span><span class="p">([</span><span class="n">size</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="mi">32</span><span class="p">,</span><span class="mi">350</span><span class="p">])</span>
     2417   
     2418<span class="c">################################################################################</span>
     2419<span class="c">#####  SASD Substances </span>
     2420<span class="c">################################################################################</span>
     2421           </div>
     2422<div class="viewcode-block" id="UpdateSubstanceGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateSubstanceGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
     2423    <span class="sd">&#39;&#39;&#39;respond to selection of SASD Substance data tree item.</span>
     2424<span class="sd">    &#39;&#39;&#39;</span>
     2425    <span class="kn">import</span> <span class="nn">Substances</span> <span class="kn">as</span> <span class="nn">substFile</span>
     2426   
     2427    <span class="k">def</span> <span class="nf">OnLoadSubstance</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2428        <span class="n">names</span> <span class="o">=</span> <span class="n">substFile</span><span class="o">.</span><span class="n">Substances</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
     2429        <span class="n">names</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
     2430        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SingleChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="s">&#39;Which substance?&#39;</span><span class="p">,</span> <span class="s">&#39;Select substance&#39;</span><span class="p">,</span> <span class="n">names</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     2431        <span class="k">try</span><span class="p">:</span>
     2432            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2433                <span class="n">name</span> <span class="o">=</span> <span class="n">names</span><span class="p">[</span><span class="n">dlg</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">()]</span>
     2434            <span class="k">else</span><span class="p">:</span>
     2435                <span class="k">return</span>
     2436        <span class="k">finally</span><span class="p">:</span>
     2437            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2438        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Elements&#39;</span><span class="p">:{},</span><span class="s">&#39;Volume&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span><span class="s">&#39;Density&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span>
     2439            <span class="s">&#39;Scatt density&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;XAnom density&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">}</span>
     2440        <span class="n">subst</span> <span class="o">=</span> <span class="n">substFile</span><span class="o">.</span><span class="n">Substances</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
     2441        <span class="n">ElList</span> <span class="o">=</span> <span class="n">subst</span><span class="p">[</span><span class="s">&#39;Elements&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
     2442        <span class="k">for</span> <span class="n">El</span> <span class="ow">in</span> <span class="n">ElList</span><span class="p">:</span>
     2443            <span class="n">Info</span> <span class="o">=</span> <span class="n">G2elem</span><span class="o">.</span><span class="n">GetAtomInfo</span><span class="p">(</span><span class="n">El</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span>
     2444            <span class="n">Info</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">subst</span><span class="p">[</span><span class="s">&#39;Elements&#39;</span><span class="p">][</span><span class="n">El</span><span class="p">])</span>
     2445            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">][</span><span class="n">El</span><span class="p">]</span> <span class="o">=</span> <span class="n">Info</span>
     2446            <span class="k">if</span> <span class="s">&#39;Volume&#39;</span> <span class="ow">in</span> <span class="n">subst</span><span class="p">:</span>
     2447                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">subst</span><span class="p">[</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span>
     2448                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2449                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])</span>
     2450            <span class="k">elif</span> <span class="s">&#39;Density&#39;</span> <span class="ow">in</span> <span class="n">subst</span><span class="p">:</span>
     2451                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">subst</span><span class="p">[</span><span class="s">&#39;Density&#39;</span><span class="p">]</span>
     2452                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2453                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Den2Vol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">])</span>
     2454            <span class="k">else</span><span class="p">:</span>
     2455                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">El2EstVol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">])</span>
     2456                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2457                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])</span>
     2458            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Scatt density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2459                <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
     2460            <span class="n">contrst</span><span class="p">,</span><span class="n">absorb</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">],</span><span class="n">wave</span><span class="p">)</span>         
     2461            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAnom density&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">contrst</span>
     2462            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">absorb</span>
     2463                         
     2464        <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2465       
     2466    <span class="k">def</span> <span class="nf">OnCopySubstance</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2467        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     2468        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     2469        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     2470            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     2471            <span class="k">return</span>
     2472        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
     2473        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     2474            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     2475            <span class="s">&#39;Copy substances from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     2476            <span class="s">&#39;Copy substances&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
     2477        <span class="k">try</span><span class="p">:</span>
     2478            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2479                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
     2480                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     2481        <span class="k">finally</span><span class="p">:</span>
     2482            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>       
     2483        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     2484            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     2485            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Substances&#39;</span><span class="p">),</span>
     2486                <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     2487   
     2488    <span class="k">def</span> <span class="nf">OnAddSubstance</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2489        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextEntryDialog</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span><span class="s">&#39;Enter a name for this substance&#39;</span><span class="p">,</span><span class="s">&#39;Substance Name Entry&#39;</span><span class="p">,</span><span class="s">&#39;New substance&#39;</span><span class="p">,</span>
     2490            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">OK</span><span class="p">)</span>
     2491        <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2492            <span class="n">Name</span> <span class="o">=</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     2493            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">Name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Elements&#39;</span><span class="p">:{},</span><span class="s">&#39;Volume&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span><span class="s">&#39;Density&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span>
     2494                <span class="s">&#39;Scatt density&#39;</span><span class="p">:</span><span class="mf">0.0</span><span class="p">,</span><span class="s">&#39;XAnom density&#39;</span><span class="p">:</span><span class="mf">0.</span><span class="p">,</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">:</span><span class="mf">0.</span><span class="p">}</span>
     2495        <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2496        <span class="n">AddElement</span><span class="p">(</span><span class="n">Name</span><span class="p">)</span>
     2497        <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2498       
     2499    <span class="k">def</span> <span class="nf">OnDeleteSubstance</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2500        <span class="n">TextList</span> <span class="o">=</span> <span class="p">[]</span>
     2501        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]:</span>
     2502            <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="s">&#39;vacuum&#39;</span><span class="p">:</span>
     2503                <span class="n">TextList</span> <span class="o">+=</span> <span class="p">[</span><span class="n">name</span><span class="p">,]</span>
     2504        <span class="k">if</span> <span class="ow">not</span> <span class="n">TextList</span><span class="p">:</span>
     2505            <span class="k">return</span>
     2506        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SingleChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="s">&#39;Which substance?&#39;</span><span class="p">,</span> <span class="s">&#39;Select substance to delete&#39;</span><span class="p">,</span> <span class="n">TextList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     2507        <span class="k">try</span><span class="p">:</span>
     2508            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2509                <span class="n">name</span> <span class="o">=</span> <span class="n">TextList</span><span class="p">[</span><span class="n">dlg</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">()]</span>
     2510            <span class="k">else</span><span class="p">:</span>
     2511                <span class="k">return</span>
     2512        <span class="k">finally</span><span class="p">:</span>
     2513            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2514        <span class="k">del</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">])</span>
     2515        <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>       
     2516               
     2517    <span class="k">def</span> <span class="nf">OnAddElement</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>       
     2518        <span class="n">TextList</span> <span class="o">=</span> <span class="p">[]</span>
     2519        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]:</span>
     2520            <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="s">&#39;vacuum&#39;</span><span class="p">:</span>
     2521                <span class="n">TextList</span> <span class="o">+=</span> <span class="p">[</span><span class="n">name</span><span class="p">,]</span>
     2522        <span class="k">if</span> <span class="ow">not</span> <span class="n">TextList</span><span class="p">:</span>
     2523            <span class="k">return</span>
     2524        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SingleChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="s">&#39;Which substance?&#39;</span><span class="p">,</span> <span class="s">&#39;Select substance&#39;</span><span class="p">,</span> <span class="n">TextList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     2525        <span class="k">try</span><span class="p">:</span>
     2526            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2527                <span class="n">name</span> <span class="o">=</span> <span class="n">TextList</span><span class="p">[</span><span class="n">dlg</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">()]</span>
     2528            <span class="k">else</span><span class="p">:</span>
     2529                <span class="k">return</span>
     2530        <span class="k">finally</span><span class="p">:</span>
     2531            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2532        <span class="n">AddElement</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
     2533        <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2534       
     2535    <span class="k">def</span> <span class="nf">AddElement</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
     2536        <span class="n">ElList</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
     2537        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2elemGUI</span><span class="o">.</span><span class="n">PickElements</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">ElList</span><span class="p">)</span>
     2538        <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2539            <span class="k">for</span> <span class="n">El</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">Elem</span><span class="p">:</span>
     2540                <span class="n">El</span> <span class="o">=</span> <span class="n">El</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
     2541                <span class="n">Info</span> <span class="o">=</span> <span class="n">G2elem</span><span class="o">.</span><span class="n">GetAtomInfo</span><span class="p">(</span><span class="n">El</span><span class="p">)</span>
     2542                <span class="n">Info</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s">&#39;Num&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">})</span>
     2543                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">][</span><span class="n">El</span><span class="p">]</span> <span class="o">=</span> <span class="n">Info</span>
     2544                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">El2EstVol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">])</span>
     2545                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2546                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])</span>
     2547                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Scatt density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2548                    <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
     2549                <span class="n">contrst</span><span class="p">,</span><span class="n">absorb</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">],</span><span class="n">wave</span><span class="p">)</span>         
     2550                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAnom density&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">contrst</span>
     2551                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">absorb</span>
     2552        <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2553       
     2554       
     2555    <span class="k">def</span> <span class="nf">OnDeleteElement</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2556        <span class="n">TextList</span> <span class="o">=</span> <span class="p">[]</span>
     2557        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]:</span>
     2558            <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="s">&#39;vacuum&#39;</span><span class="p">:</span>
     2559                <span class="n">TextList</span> <span class="o">+=</span> <span class="p">[</span><span class="n">name</span><span class="p">,]</span>
     2560        <span class="k">if</span> <span class="ow">not</span> <span class="n">TextList</span><span class="p">:</span>
     2561            <span class="k">return</span>
     2562        <span class="n">dlg</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">SingleChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span> <span class="s">&#39;Which substance?&#39;</span><span class="p">,</span> <span class="s">&#39;Select substance&#39;</span><span class="p">,</span> <span class="n">TextList</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">CHOICEDLG_STYLE</span><span class="p">)</span>
     2563        <span class="k">try</span><span class="p">:</span>
     2564            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2565                <span class="n">name</span> <span class="o">=</span> <span class="n">TextList</span><span class="p">[</span><span class="n">dlg</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">()]</span>
     2566            <span class="k">else</span><span class="p">:</span>
     2567                <span class="k">return</span>
     2568        <span class="k">finally</span><span class="p">:</span>
     2569            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2570        <span class="n">ElList</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
     2571        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">ElList</span><span class="p">):</span>
     2572            <span class="n">DE</span> <span class="o">=</span> <span class="n">G2elemGUI</span><span class="o">.</span><span class="n">DeleteElement</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">ElList</span><span class="p">)</span>
     2573            <span class="k">if</span> <span class="n">DE</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2574                <span class="n">El</span> <span class="o">=</span> <span class="n">DE</span><span class="o">.</span><span class="n">GetDeleteElement</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
     2575                <span class="k">del</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">][</span><span class="n">El</span><span class="p">])</span>
     2576                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">El2EstVol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">])</span>
     2577                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2578                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])</span>
     2579                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Scatt density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2580                    <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
     2581                <span class="n">contrst</span><span class="p">,</span><span class="n">absorb</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">],</span><span class="n">wave</span><span class="p">)</span>         
     2582                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAnom density&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">contrst</span>
     2583                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">absorb</span>
     2584        <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2585               
     2586    <span class="k">def</span> <span class="nf">SubstSizer</span><span class="p">():</span>
     2587       
     2588        <span class="k">def</span> <span class="nf">OnValueChange</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2589            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     2590            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()])</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
     2591                <span class="n">name</span><span class="p">,</span><span class="n">El</span><span class="p">,</span><span class="n">keyId</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2592                <span class="k">try</span><span class="p">:</span>
     2593                    <span class="n">value</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()))</span>
     2594                <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2595                    <span class="n">value</span> <span class="o">=</span> <span class="mi">0</span>
     2596                    <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
     2597                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">][</span><span class="n">El</span><span class="p">][</span><span class="n">keyId</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     2598                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">El2EstVol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">])</span>
     2599                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2600                    <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])</span>
     2601            <span class="k">else</span><span class="p">:</span>
     2602                <span class="n">name</span><span class="p">,</span><span class="n">keyId</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2603                <span class="k">try</span><span class="p">:</span>
     2604                    <span class="n">value</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()))</span>
     2605                <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2606                    <span class="n">value</span> <span class="o">=</span> <span class="mf">1.0</span>
     2607                <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="n">keyId</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     2608                <span class="k">if</span> <span class="n">keyId</span> <span class="ow">in</span> <span class="s">&#39;Volume&#39;</span><span class="p">:</span>
     2609                    <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2610                        <span class="n">G2mth</span><span class="o">.</span><span class="n">Vol2Den</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">value</span><span class="p">)</span>
     2611                <span class="k">elif</span> <span class="n">keyId</span> <span class="ow">in</span> <span class="s">&#39;Density&#39;</span><span class="p">:</span>
     2612                    <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2613                        <span class="n">G2mth</span><span class="o">.</span><span class="n">Den2Vol</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">value</span><span class="p">)</span>
     2614            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Scatt density&#39;</span><span class="p">]</span> <span class="o">=</span> \
     2615                <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
     2616            <span class="n">contrst</span><span class="p">,</span><span class="n">absorb</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">XScattDen</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Elements&#39;</span><span class="p">],</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;Volume&#39;</span><span class="p">],</span><span class="n">wave</span><span class="p">)</span>         
     2617            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAnom density&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">contrst</span>
     2618            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">][</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">absorb</span>
     2619            <span class="n">UpdateSubstanceGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2620       
     2621        <span class="n">Indx</span> <span class="o">=</span> <span class="p">{}</span>
     2622        <span class="n">substSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
     2623        <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Substance list: wavelength: </span><span class="si">%.5f</span><span class="s">A&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">wave</span><span class="p">)),</span>
     2624            <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2625        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]:</span>
     2626            <span class="n">G2gd</span><span class="o">.</span><span class="n">HorizontalLine</span><span class="p">(</span><span class="n">substSizer</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">)</span>   
     2627            <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Data for &#39;</span><span class="o">+</span><span class="n">name</span><span class="o">+</span><span class="s">&#39;:&#39;</span><span class="p">),</span>
     2628                <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2629            <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s">&#39;vacuum&#39;</span><span class="p">:</span>
     2630                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;        Not applicable&#39;</span><span class="p">),</span>
     2631                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2632            <span class="k">else</span><span class="p">:</span>   
     2633                <span class="n">elSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     2634                <span class="n">Substance</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">name</span><span class="p">]</span>
     2635                <span class="n">Elems</span> <span class="o">=</span> <span class="n">Substance</span><span class="p">[</span><span class="s">&#39;Elements&#39;</span><span class="p">]</span>
     2636                <span class="k">for</span> <span class="n">El</span> <span class="ow">in</span> <span class="n">Elems</span><span class="p">:</span>    <span class="c">#do elements as pull downs for isotopes for neutrons</span>
     2637                    <span class="n">elSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; &#39;</span><span class="o">+</span><span class="n">El</span><span class="o">+</span><span class="s">&#39;: &#39;</span><span class="p">),</span>
     2638                        <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2639                    <span class="n">num</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&#39;</span><span class="si">%.2f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Elems</span><span class="p">[</span><span class="n">El</span><span class="p">][</span><span class="s">&#39;Num&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     2640                    <span class="n">Indx</span><span class="p">[</span><span class="n">num</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span><span class="p">,</span><span class="n">El</span><span class="p">,</span><span class="s">&#39;Num&#39;</span><span class="p">]</span>
     2641                    <span class="n">num</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>       
     2642                    <span class="n">num</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>
     2643                    <span class="n">elSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">num</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2644                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">elSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     2645                <span class="n">vdsSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     2646                <span class="n">vdsSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Volume: &#39;</span><span class="p">),</span>
     2647                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2648                <span class="n">vol</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&#39;</span><span class="si">%.3f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Substance</span><span class="p">[</span><span class="s">&#39;Volume&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     2649                <span class="n">Indx</span><span class="p">[</span><span class="n">vol</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span><span class="p">,</span><span class="s">&#39;Volume&#39;</span><span class="p">]</span>
     2650                <span class="n">vol</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>       
     2651                <span class="n">vol</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>
     2652                <span class="n">vdsSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">vol</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>               
     2653                <span class="n">vdsSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Density: &#39;</span><span class="p">),</span>
     2654                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2655                <span class="n">den</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&#39;</span><span class="si">%.3f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Substance</span><span class="p">[</span><span class="s">&#39;Density&#39;</span><span class="p">]),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     2656                <span class="n">Indx</span><span class="p">[</span><span class="n">den</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">name</span><span class="p">,</span><span class="s">&#39;Density&#39;</span><span class="p">]</span>
     2657                <span class="n">den</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>       
     2658                <span class="n">den</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnValueChange</span><span class="p">)</span>
     2659                <span class="n">vdsSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">den</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2660                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">vdsSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     2661                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span>
     2662                    <span class="n">label</span><span class="o">=</span><span class="s">&#39; Scattering density  : </span><span class="si">%.2f</span><span class="s"> *10</span><span class="si">%s</span><span class="s">cm</span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Substance</span><span class="p">[</span><span class="s">&#39;Scatt density&#39;</span><span class="p">],</span><span class="n">Pwr10</span><span class="p">,</span><span class="n">Pwrm2</span><span class="p">)),</span>
     2663                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>               
     2664                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span>       <span class="c">#allow neutrons here into NAnom density &amp; NAbsorption</span>
     2665                    <span class="n">label</span><span class="o">=</span><span class="s">&#39; Anomalous density : </span><span class="si">%.2f</span><span class="s"> *10</span><span class="si">%s</span><span class="s">cm</span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Substance</span><span class="p">[</span><span class="s">&#39;XAnom density&#39;</span><span class="p">],</span><span class="n">Pwr10</span><span class="p">,</span><span class="n">Pwrm2</span><span class="p">)),</span>
     2666                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>               
     2667                <span class="n">substSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span>
     2668                    <span class="n">label</span><span class="o">=</span><span class="s">&#39; X-ray absorption   : </span><span class="si">%.2f</span><span class="s"> cm</span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Substance</span><span class="p">[</span><span class="s">&#39;XAbsorption&#39;</span><span class="p">],</span><span class="n">Pwrm1</span><span class="p">)),</span>
     2669                    <span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>               
     2670        <span class="k">return</span> <span class="n">substSizer</span>
     2671           
     2672    <span class="n">Inst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Instrument Parameters&#39;</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
     2673    <span class="n">wave</span> <span class="o">=</span> <span class="n">G2mth</span><span class="o">.</span><span class="n">getWave</span><span class="p">(</span><span class="n">Inst</span><span class="p">)</span>
     2674    <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">:</span>
     2675        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">DestroyChildren</span><span class="p">()</span>
     2676    <span class="n">G2gd</span><span class="o">.</span><span class="n">SetDataMenuBar</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SubstanceMenu</span><span class="p">)</span>
     2677    <span class="k">if</span> <span class="ow">not</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">GetStatusBar</span><span class="p">():</span>
     2678        <span class="n">Status</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">CreateStatusBar</span><span class="p">()</span>
     2679    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span> <span class="o">=</span> <span class="n">wxscroll</span><span class="o">.</span><span class="n">ScrolledPanel</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     2680    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SetLabel</span><span class="p">(</span><span class="s">&#39;Substances&#39;</span><span class="p">)</span>
     2681    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnLoadSubstance</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_LOADSUBSTANCE</span><span class="p">)</span>   
     2682    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnAddSubstance</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_ADDSUBSTANCE</span><span class="p">)</span>
     2683    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnCopySubstance</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_COPYSUBSTANCE</span><span class="p">)</span>
     2684    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnDeleteSubstance</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_DELETESUBSTANCE</span><span class="p">)</span>   
     2685    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnAddElement</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_ELEMENTADD</span><span class="p">)</span>
     2686    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_MENU</span><span class="p">,</span> <span class="n">OnDeleteElement</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="n">G2gd</span><span class="o">.</span><span class="n">wxID_ELEMENTDELETE</span><span class="p">)</span>
     2687    <span class="n">mainSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
     2688    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">SubstSizer</span><span class="p">(),</span><span class="mi">0</span><span class="p">)</span>
     2689
     2690    <span class="n">mainSizer</span><span class="o">.</span><span class="n">Layout</span><span class="p">()</span>   
     2691    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetSizer</span><span class="p">(</span><span class="n">mainSizer</span><span class="p">)</span>
     2692    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetAutoLayout</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
     2693    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetupScrolling</span><span class="p">()</span>
     2694    <span class="n">Size</span> <span class="o">=</span> <span class="n">mainSizer</span><span class="o">.</span><span class="n">Fit</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     2695    <span class="n">Size</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">25</span>
     2696    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="o">.</span><span class="n">SetSize</span><span class="p">(</span><span class="n">Size</span><span class="p">)</span>
     2697    <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">setSizePosLeft</span><span class="p">(</span><span class="n">Size</span><span class="p">)</span>   
     2698       
     2699<span class="c">################################################################################</span>
     2700<span class="c">#####  SASD Models </span>
     2701<span class="c">################################################################################           </span>
     2702       </div>
     2703<div class="viewcode-block" id="UpdateModelsGrid"><a class="viewcode-back" href="../GSASIIGUI.html#GSASIIpwdGUI.UpdateModelsGrid">[docs]</a><span class="k">def</span> <span class="nf">UpdateModelsGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
     2704    <span class="sd">&#39;&#39;&#39;respond to selection of SASD Models data tree item.</span>
     2705<span class="sd">    &#39;&#39;&#39;</span>
     2706    <span class="c">#patches</span>
     2707    <span class="k">if</span> <span class="s">&#39;Current&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
     2708        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Current&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;Size dist.&#39;</span>
     2709    <span class="k">if</span> <span class="s">&#39;logBins&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">]:</span>
     2710        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;logBins&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">True</span>
     2711    <span class="k">if</span> <span class="s">&#39;MinMaxDiam&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">]:</span>
     2712        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MinDiam&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">50.</span>
     2713        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxDiam&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">10000.</span>
     2714        <span class="k">del</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MinMaxDiam&#39;</span><span class="p">]</span>
     2715    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">][</span><span class="s">&#39;Sky&#39;</span><span class="p">],</span><span class="nb">float</span><span class="p">):</span>
     2716        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">][</span><span class="s">&#39;Sky&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">3</span>
     2717    <span class="k">if</span> <span class="s">&#39;Power&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;IPG&#39;</span><span class="p">]:</span>
     2718        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;IPG&#39;</span><span class="p">][</span><span class="s">&#39;Power&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
     2719    <span class="k">if</span> <span class="s">&#39;Matrix&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">]:</span>
     2720        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">][</span><span class="s">&#39;Matrix&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Name&#39;</span><span class="p">:</span><span class="s">&#39;vacuum&#39;</span><span class="p">,</span><span class="s">&#39;VolFrac&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">]}</span>
     2721    <span class="c">#end patches</span>
     2722   
     2723    <span class="k">def</span> <span class="nf">RefreshPlots</span><span class="p">(</span><span class="n">newPlot</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
     2724        <span class="n">PlotText</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">nb</span><span class="o">.</span><span class="n">GetPageText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">nb</span><span class="o">.</span><span class="n">GetSelection</span><span class="p">())</span>
     2725        <span class="k">if</span> <span class="s">&#39;Powder&#39;</span> <span class="ow">in</span> <span class="n">PlotText</span><span class="p">:</span>
     2726            <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotPatterns</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">plotType</span><span class="o">=</span><span class="s">&#39;SASD&#39;</span><span class="p">,</span><span class="n">newPlot</span><span class="o">=</span><span class="n">newPlot</span><span class="p">)</span>
     2727        <span class="k">elif</span> <span class="s">&#39;Size&#39;</span> <span class="ow">in</span> <span class="n">PlotText</span><span class="p">:</span>
     2728            <span class="n">G2plt</span><span class="o">.</span><span class="n">PlotSASDSizeDist</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     2729               
     2730    <span class="k">def</span> <span class="nf">OnAddModel</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2731        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Current&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Particle fit&#39;</span><span class="p">:</span>
     2732            <span class="n">material</span> <span class="o">=</span> <span class="s">&#39;vacuum&#39;</span>
     2733            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">][</span><span class="s">&#39;Levels&#39;</span><span class="p">]):</span>
     2734                <span class="n">material</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">][</span><span class="s">&#39;Levels&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;Material&#39;</span><span class="p">]</span>
     2735            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">][</span><span class="s">&#39;Levels&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span>
     2736                <span class="s">&#39;Controls&#39;</span><span class="p">:{</span><span class="s">&#39;FormFact&#39;</span><span class="p">:</span><span class="s">&#39;Sphere&#39;</span><span class="p">,</span><span class="s">&#39;DistType&#39;</span><span class="p">:</span><span class="s">&#39;LogNormal&#39;</span><span class="p">,</span><span class="s">&#39;Material&#39;</span><span class="p">:</span><span class="n">material</span><span class="p">,</span>
     2737                    <span class="s">&#39;FFargs&#39;</span><span class="p">:{},</span><span class="s">&#39;NumPoints&#39;</span><span class="p">:</span><span class="mi">50</span><span class="p">,</span><span class="s">&#39;Cutoff&#39;</span><span class="p">:</span><span class="mf">0.01</span><span class="p">,</span>
     2738                    <span class="s">&#39;SlitSmear&#39;</span><span class="p">:[</span><span class="mf">0.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;StrFact&#39;</span><span class="p">:</span><span class="s">&#39;Dilute&#39;</span><span class="p">},</span>    <span class="c">#last 2 not used - future?</span>
     2739                <span class="s">&#39;LogNormal&#39;</span><span class="p">:{</span><span class="s">&#39;Volume&#39;</span><span class="p">:[</span><span class="mf">0.05</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Mean&#39;</span><span class="p">:[</span><span class="mf">1000.</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;StdDev&#39;</span><span class="p">:[</span><span class="mf">0.5</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;MinSize&#39;</span><span class="p">:[</span><span class="mf">10.</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2740                <span class="s">&#39;Gaussian&#39;</span><span class="p">:{</span><span class="s">&#39;Volume&#39;</span><span class="p">:[</span><span class="mf">0.05</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Mean&#39;</span><span class="p">:[</span><span class="mf">1000.</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;StdDev&#39;</span><span class="p">:[</span><span class="mf">300.</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2741                <span class="s">&#39;LSW&#39;</span><span class="p">:{</span><span class="s">&#39;Volume&#39;</span><span class="p">:[</span><span class="mf">0.05</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Mean&#39;</span><span class="p">:[</span><span class="mf">1000.0</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2742                <span class="s">&#39;Schulz-Zimm&#39;</span><span class="p">:{</span><span class="s">&#39;Volume&#39;</span><span class="p">:[</span><span class="mf">0.05</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Mean&#39;</span><span class="p">:[</span><span class="mf">1000.</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;StdDev&#39;</span><span class="p">:[</span><span class="mf">300.</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2743                <span class="s">&#39;Unified&#39;</span><span class="p">:{</span><span class="s">&#39;G&#39;</span><span class="p">:[</span><span class="mf">1.e3</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Rg&#39;</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;B&#39;</span><span class="p">:[</span><span class="mf">1.e-5</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;P&#39;</span><span class="p">:[</span><span class="mi">4</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Cutoff&#39;</span><span class="p">:[</span><span class="mf">1e-5</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2744                <span class="s">&#39;Porod&#39;</span><span class="p">:{</span><span class="s">&#39;B&#39;</span><span class="p">:[</span><span class="mf">1.e-4</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;P&#39;</span><span class="p">:[</span><span class="mi">4</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Cutoff&#39;</span><span class="p">:[</span><span class="mf">1e-5</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>
     2745                <span class="s">&#39;Monodisperse&#39;</span><span class="p">:{</span><span class="s">&#39;Volume&#39;</span><span class="p">:[</span><span class="mf">0.05</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Radius&#39;</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>   <span class="c">#OK for spheres</span>
     2746                <span class="s">&#39;Bragg&#39;</span><span class="p">:{</span><span class="s">&#39;PkInt&#39;</span><span class="p">:[</span><span class="mi">100</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;PkPos&#39;</span><span class="p">:[</span><span class="mf">0.2</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span>
     2747                    <span class="s">&#39;PkSig&#39;</span><span class="p">:[</span><span class="mi">10</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;PkGam&#39;</span><span class="p">:[</span><span class="mi">10</span><span class="p">,</span><span class="bp">False</span><span class="p">],},</span>        <span class="c">#reasonable 31A peak</span>
     2748                <span class="p">})</span>
     2749            <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2750            <span class="n">RefreshPlots</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
     2751                   
     2752        <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2753       
     2754    <span class="k">def</span> <span class="nf">OnCopyModel</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2755        <span class="n">hst</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">)</span>
     2756        <span class="n">histList</span> <span class="o">=</span> <span class="n">GetHistsLikeSelected</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     2757        <span class="k">if</span> <span class="ow">not</span> <span class="n">histList</span><span class="p">:</span>
     2758            <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No match&#39;</span><span class="p">,</span><span class="s">&#39;No histograms match &#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">)</span>
     2759            <span class="k">return</span>
     2760        <span class="n">copyList</span> <span class="o">=</span> <span class="p">[]</span>
     2761        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">G2MultiChoiceDialog</span><span class="p">(</span>
     2762            <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span>
     2763            <span class="s">&#39;Copy models from</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">hst</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span><span class="o">+</span><span class="s">&#39; to...&#39;</span><span class="p">,</span>
     2764            <span class="s">&#39;Copy models&#39;</span><span class="p">,</span> <span class="n">histList</span><span class="p">)</span>
     2765        <span class="k">try</span><span class="p">:</span>
     2766            <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2767                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
     2768                    <span class="n">copyList</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">histList</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
     2769        <span class="k">finally</span><span class="p">:</span>
     2770            <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>       
     2771        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">copyList</span><span class="p">:</span>
     2772            <span class="n">Id</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">root</span><span class="p">,</span><span class="n">item</span><span class="p">)</span>
     2773            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Id</span><span class="p">,</span><span class="s">&#39;Models&#39;</span><span class="p">),</span>
     2774                <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
     2775               
     2776    <span class="k">def</span> <span class="nf">OnFitModelAll</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2777        <span class="n">choices</span> <span class="o">=</span> <span class="n">GetPatternTreeDataNames</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,[</span><span class="s">&#39;SASD&#39;</span><span class="p">,])</span>
     2778        <span class="n">sel</span> <span class="o">=</span> <span class="p">[]</span>
     2779        <span class="n">dlg</span> <span class="o">=</span> <span class="n">G2MultiChoiceDialog</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="p">,</span> <span class="s">&#39;Sequential SASD refinement&#39;</span><span class="p">,</span>
     2780             <span class="s">&#39;Select dataset to include&#39;</span><span class="p">,</span><span class="n">choices</span><span class="p">)</span>
     2781        <span class="n">dlg</span><span class="o">.</span><span class="n">SetSelections</span><span class="p">(</span><span class="n">sel</span><span class="p">)</span>
     2782        <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span>
     2783        <span class="k">if</span> <span class="n">dlg</span><span class="o">.</span><span class="n">ShowModal</span><span class="p">()</span> <span class="o">==</span> <span class="n">wx</span><span class="o">.</span><span class="n">ID_OK</span><span class="p">:</span>
     2784            <span class="k">for</span> <span class="n">sel</span> <span class="ow">in</span> <span class="n">dlg</span><span class="o">.</span><span class="n">GetSelections</span><span class="p">():</span>
     2785                <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">choices</span><span class="p">[</span><span class="n">sel</span><span class="p">])</span>
     2786        <span class="n">dlg</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span>
     2787        <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span> <span class="k">print</span> <span class="n">name</span>
     2788       
     2789    <span class="k">def</span> <span class="nf">OnFitModel</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2790        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Current&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Size dist.&#39;</span><span class="p">:</span>
     2791            <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">Sample</span><span class="p">[</span><span class="s">&#39;Contrast&#39;</span><span class="p">]):</span>
     2792                <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;No contrast; your sample is a vacuum!&#39;</span><span class="p">,</span>
     2793                    <span class="s">&#39;You need to define a scattering substance!</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span>    \
     2794                    <span class="s">&#39; Do Substances and then Sample parameters&#39;</span><span class="p">)</span>
     2795                <span class="k">return</span>
     2796            <span class="n">G2sasd</span><span class="o">.</span><span class="n">SizeDistribution</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2797            <span class="n">RefreshPlots</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
     2798           
     2799        <span class="k">elif</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Current&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Particle fit&#39;</span><span class="p">:</span>
     2800            <span class="n">SaveState</span><span class="p">()</span>
     2801            <span class="k">if</span> <span class="ow">not</span> <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFit</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
     2802                <span class="n">G2frame</span><span class="o">.</span><span class="n">ErrorDialog</span><span class="p">(</span><span class="s">&#39;Failed refinement&#39;</span><span class="p">,</span>
     2803                    <span class="s">&#39;You need to rethink your selection of parameters</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span>    \
     2804                    <span class="s">&#39; Model restored to previous version&#39;</span><span class="p">)</span>
     2805            <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2806            <span class="n">RefreshPlots</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
     2807            <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2808           
     2809    <span class="k">def</span> <span class="nf">OnUnDo</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2810        <span class="n">DoUnDo</span><span class="p">()</span>
     2811        <span class="n">data</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span>
     2812            <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span><span class="p">,</span><span class="s">&#39;Models&#39;</span><span class="p">))</span>
     2813        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SasdUndo</span><span class="o">.</span><span class="n">Enable</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
     2814        <span class="n">UpdateModelsGrid</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2815        <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2816        <span class="n">RefreshPlots</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
     2817
     2818    <span class="k">def</span> <span class="nf">DoUnDo</span><span class="p">():</span>
     2819        <span class="k">print</span> <span class="s">&#39;Undo last refinement&#39;</span>
     2820        <span class="nb">file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">undosasd</span><span class="p">,</span><span class="s">&#39;rb&#39;</span><span class="p">)</span>
     2821        <span class="n">PatternId</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span>
     2822        <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">SetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">PatternId</span><span class="p">,</span> <span class="s">&#39;Models&#39;</span><span class="p">),</span><span class="n">cPickle</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="nb">file</span><span class="p">))</span>
     2823        <span class="k">print</span> <span class="s">&#39; Models recovered&#39;</span>
     2824        <span class="nb">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
     2825       
     2826    <span class="k">def</span> <span class="nf">SaveState</span><span class="p">():</span>
     2827        <span class="n">G2frame</span><span class="o">.</span><span class="n">undosasd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dirname</span><span class="p">,</span><span class="s">&#39;GSASIIsasd.save&#39;</span><span class="p">)</span>
     2828        <span class="nb">file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">undosasd</span><span class="p">,</span><span class="s">&#39;wb&#39;</span><span class="p">)</span>
     2829        <span class="n">PatternId</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">PatternId</span>
     2830        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Models&#39;</span><span class="p">]:</span>
     2831            <span class="n">cPickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">PatternTree</span><span class="o">.</span><span class="n">GetItemPyData</span><span class="p">(</span><span class="n">G2gd</span><span class="o">.</span><span class="n">GetPatternTreeItemId</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">PatternId</span><span class="p">,</span><span class="n">item</span><span class="p">)),</span><span class="nb">file</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
     2832        <span class="nb">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
     2833        <span class="n">G2frame</span><span class="o">.</span><span class="n">dataFrame</span><span class="o">.</span><span class="n">SasdUndo</span><span class="o">.</span><span class="n">Enable</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
     2834       
     2835    <span class="k">def</span> <span class="nf">OnSelectFit</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2836        <span class="n">data</span><span class="p">[</span><span class="s">&#39;Current&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">fitSel</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     2837        <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2838       
     2839    <span class="k">def</span> <span class="nf">OnValueChange</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2840        <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     2841        <span class="n">itemKey</span><span class="p">,</span><span class="n">ind</span><span class="p">,</span><span class="n">fmt</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2842        <span class="k">try</span><span class="p">:</span>
     2843            <span class="n">value</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span>
     2844        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2845            <span class="n">value</span> <span class="o">=</span> <span class="mf">0.0</span>
     2846        <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">fmt</span><span class="o">%</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
     2847        <span class="n">data</span><span class="p">[</span><span class="n">itemKey</span><span class="p">][</span><span class="n">ind</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     2848        <span class="k">if</span> <span class="n">itemKey</span> <span class="o">==</span> <span class="s">&#39;Back&#39;</span><span class="p">:</span>
     2849            <span class="n">Profile</span><span class="p">[</span><span class="mi">4</span><span class="p">][:]</span> <span class="o">=</span> <span class="n">value</span>
     2850        <span class="n">RefreshPlots</span><span class="p">()</span>
     2851       
     2852    <span class="k">def</span> <span class="nf">OnCheckBox</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2853        <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     2854        <span class="n">item</span><span class="p">,</span><span class="n">ind</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2855        <span class="n">item</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     2856       
     2857    <span class="k">def</span> <span class="nf">OnIntVal</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2858        <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     2859        <span class="n">item</span><span class="p">,</span><span class="n">ind</span><span class="p">,</span><span class="n">minVal</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2860        <span class="k">try</span><span class="p">:</span>
     2861            <span class="n">value</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span>
     2862            <span class="k">if</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="n">minVal</span><span class="p">:</span>
     2863                <span class="k">raise</span> <span class="ne">ValueError</span>
     2864        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2865            <span class="n">value</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span>
     2866        <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
     2867        <span class="n">item</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     2868
     2869    <span class="k">def</span> <span class="nf">SizeSizer</span><span class="p">():</span>
     2870       
     2871        <span class="k">def</span> <span class="nf">OnShape</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2872            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">partsh</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     2873            <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2874           
     2875        <span class="k">def</span> <span class="nf">OnMethod</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2876            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Method&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     2877            <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     2878           
     2879        <span class="k">def</span> <span class="nf">OnPartVal</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2880            <span class="k">try</span><span class="p">:</span>
     2881                <span class="n">val</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="nb">float</span><span class="p">(</span><span class="n">partprm</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()))</span>
     2882            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2883                <span class="n">val</span> <span class="o">=</span> <span class="mi">1</span>
     2884            <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span>
     2885            <span class="n">partprm</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%.3f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">val</span><span class="p">))</span>
     2886           
     2887        <span class="n">sizeSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span>
     2888        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Size distribution parameters: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2889        <span class="n">binSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     2890        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; No. size bins: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2891        <span class="n">bins</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;50&#39;</span><span class="p">,</span><span class="s">&#39;100&#39;</span><span class="p">,</span><span class="s">&#39;150&#39;</span><span class="p">,</span><span class="s">&#39;200&#39;</span><span class="p">]</span>
     2892        <span class="n">nbins</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Nbins&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">bins</span><span class="p">,</span>
     2893            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2894        <span class="n">Indx</span><span class="p">[</span><span class="n">nbins</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">],</span><span class="s">&#39;Nbins&#39;</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
     2895        <span class="n">nbins</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>       
     2896        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">nbins</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2897        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Min diam.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2898        <span class="n">minDias</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;10&#39;</span><span class="p">,</span><span class="s">&#39;25&#39;</span><span class="p">,</span><span class="s">&#39;50&#39;</span><span class="p">,</span><span class="s">&#39;100&#39;</span><span class="p">,</span><span class="s">&#39;150&#39;</span><span class="p">,</span><span class="s">&#39;200&#39;</span><span class="p">]</span>
     2899        <span class="n">mindiam</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MinDiam&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">minDias</span><span class="p">,</span>
     2900            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2901        <span class="n">mindiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_LEAVE_WINDOW</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2902        <span class="n">mindiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>       
     2903        <span class="n">mindiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2904        <span class="n">Indx</span><span class="p">[</span><span class="n">mindiam</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">],</span><span class="s">&#39;MinDiam&#39;</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
     2905        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">mindiam</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2906        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Max diam.: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2907        <span class="n">maxDias</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="mi">1000</span><span class="o">*</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">)]</span>
     2908        <span class="n">maxdiam</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxDiam&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">maxDias</span><span class="p">,</span>
     2909            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2910        <span class="n">maxdiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_LEAVE_WINDOW</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2911        <span class="n">maxdiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>       
     2912        <span class="n">maxdiam</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2913        <span class="n">Indx</span><span class="p">[</span><span class="n">maxdiam</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">],</span><span class="s">&#39;MaxDiam&#39;</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
     2914        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">maxdiam</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2915        <span class="n">logbins</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">CheckBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;Log bins?&#39;</span><span class="p">)</span>
     2916        <span class="n">Indx</span><span class="p">[</span><span class="n">logbins</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">],</span><span class="s">&#39;logBins&#39;</span><span class="p">]</span>
     2917        <span class="n">logbins</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;logBins&#39;</span><span class="p">])</span>
     2918        <span class="n">logbins</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CHECKBOX</span><span class="p">,</span> <span class="n">OnCheckBox</span><span class="p">)</span>
     2919        <span class="n">binSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">logbins</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2920        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">binSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     2921        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
     2922        <span class="n">partSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
     2923        <span class="n">partSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;Particle description: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2924        <span class="n">shapes</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Spheroid&#39;</span><span class="p">:</span><span class="s">&#39; Aspect ratio: &#39;</span><span class="p">,</span><span class="s">&#39;Cylinder&#39;</span><span class="p">:</span><span class="s">&#39; Diameter &#39;</span><span class="p">,</span><span class="s">&#39;Cylinder AR&#39;</span><span class="p">:</span><span class="s">&#39; Aspect ratio: &#39;</span><span class="p">,</span>
     2925            <span class="s">&#39;Unified sphere&#39;</span><span class="p">:</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Unified rod&#39;</span><span class="p">:</span><span class="s">&#39; Diameter: &#39;</span><span class="p">,</span><span class="s">&#39;Unified rod AR&#39;</span><span class="p">:</span><span class="s">&#39; Aspect ratio: &#39;</span><span class="p">,</span>
     2926            <span class="s">&#39;Unified disk&#39;</span><span class="p">:</span><span class="s">&#39; Thickness: &#39;</span><span class="p">}</span>
     2927        <span class="n">partsh</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">shapes</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span>
     2928            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2929        <span class="n">partsh</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnShape</span><span class="p">)</span>       
     2930        <span class="n">partSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">partsh</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2931        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Unified sphere&#39;</span><span class="p">,]:</span>
     2932            <span class="n">partSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="n">shapes</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]]),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2933            <span class="n">partprm</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="s">&#39;</span><span class="si">%.3f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Shape&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]),</span>
     2934                <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">TE_PROCESS_ENTER</span><span class="p">)</span>
     2935            <span class="n">partprm</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_TEXT_ENTER</span><span class="p">,</span><span class="n">OnPartVal</span><span class="p">)</span>       
     2936            <span class="n">partprm</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_KILL_FOCUS</span><span class="p">,</span><span class="n">OnPartVal</span><span class="p">)</span>
     2937            <span class="n">partSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">partprm</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2938        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">partSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     2939        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">),</span><span class="mi">0</span><span class="p">)</span>
     2940        <span class="n">fitSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span>
     2941        <span class="n">methods</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">,</span><span class="s">&#39;IPG&#39;</span><span class="p">,]</span>
     2942        <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;Fitting method: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2943        <span class="n">method</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Method&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">methods</span><span class="p">,</span>
     2944            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2945        <span class="n">method</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnMethod</span><span class="p">)</span>
     2946        <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">method</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2947        <span class="n">iters</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;10&#39;</span><span class="p">,</span><span class="s">&#39;25&#39;</span><span class="p">,</span><span class="s">&#39;50&#39;</span><span class="p">,</span><span class="s">&#39;100&#39;</span><span class="p">,</span><span class="s">&#39;150&#39;</span><span class="p">,</span><span class="s">&#39;200&#39;</span><span class="p">]</span>       
     2948        <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; No. iterations: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2949        <span class="n">Method</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Method&#39;</span><span class="p">]</span>
     2950        <span class="nb">iter</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="n">Method</span><span class="p">][</span><span class="s">&#39;Niter&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">iters</span><span class="p">,</span>
     2951            <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2952        <span class="n">Indx</span><span class="p">[</span><span class="nb">iter</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="n">Method</span><span class="p">],</span><span class="s">&#39;Niter&#39;</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
     2953        <span class="nb">iter</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2954        <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="nb">iter</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2955        <span class="k">if</span> <span class="s">&#39;MaxEnt&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Method&#39;</span><span class="p">]:</span>
     2956            <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Log floor factor: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2957            <span class="n">floors</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="o">-</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">9</span><span class="p">)]</span>
     2958            <span class="n">floor</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">][</span><span class="s">&#39;Sky&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">floors</span><span class="p">,</span>
     2959                <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2960            <span class="n">Indx</span><span class="p">[</span><span class="n">floor</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;MaxEnt&#39;</span><span class="p">],</span><span class="s">&#39;Sky&#39;</span><span class="p">,</span><span class="o">-</span><span class="mi">10</span><span class="p">]</span>
     2961            <span class="n">floor</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2962            <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">floor</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2963        <span class="k">elif</span> <span class="s">&#39;IPG&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;Method&#39;</span><span class="p">]:</span>
     2964            <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Q power weight (-1 for sigma): &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2965            <span class="n">choices</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;-1&#39;</span><span class="p">,</span><span class="s">&#39;0&#39;</span><span class="p">,</span><span class="s">&#39;1&#39;</span><span class="p">,</span><span class="s">&#39;2&#39;</span><span class="p">,</span><span class="s">&#39;3&#39;</span><span class="p">,</span><span class="s">&#39;4&#39;</span><span class="p">]</span>
     2966            <span class="n">power</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;IPG&#39;</span><span class="p">][</span><span class="s">&#39;Power&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">choices</span><span class="p">,</span>
     2967                <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     2968            <span class="n">Indx</span><span class="p">[</span><span class="n">power</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s">&#39;Size&#39;</span><span class="p">][</span><span class="s">&#39;IPG&#39;</span><span class="p">],</span><span class="s">&#39;Power&#39;</span><span class="p">,</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span>
     2969            <span class="n">power</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnIntVal</span><span class="p">)</span>
     2970            <span class="n">fitSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">power</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     2971        <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">fitSizer</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
     2972
     2973        <span class="k">return</span> <span class="n">sizeSizer</span>
     2974       
     2975    <span class="k">def</span> <span class="nf">PartSizer</span><span class="p">():</span>
     2976       
     2977        <span class="n">FormFactors</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;Sphere&#39;</span><span class="p">:{},</span><span class="s">&#39;Spheroid&#39;</span><span class="p">:{</span><span class="s">&#39;Aspect ratio&#39;</span><span class="p">:[</span><span class="mf">1.0</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span>
     2978            <span class="s">&#39;Cylinder&#39;</span><span class="p">:{</span><span class="s">&#39;Length&#39;</span><span class="p">:[</span><span class="mf">100.</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span><span class="s">&#39;Cylinder diam&#39;</span><span class="p">:{</span><span class="s">&#39;Diameter&#39;</span><span class="p">:[</span><span class="mf">100.</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span>
     2979            <span class="s">&#39;Cylinder AR&#39;</span><span class="p">:{</span><span class="s">&#39;Aspect ratio&#39;</span><span class="p">:[</span><span class="mf">1.0</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span><span class="s">&#39;Unified sphere&#39;</span><span class="p">:{},</span>
     2980            <span class="s">&#39;Unified rod&#39;</span><span class="p">:{</span><span class="s">&#39;Length&#39;</span><span class="p">:[</span><span class="mf">100.</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span><span class="s">&#39;Unified rod AR&#39;</span><span class="p">:{</span><span class="s">&#39;Aspect ratio&#39;</span><span class="p">:[</span><span class="mf">1.0</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span>
     2981            <span class="s">&#39;Unified disk&#39;</span><span class="p">:{</span><span class="s">&#39;Thickness&#39;</span><span class="p">:[</span><span class="mf">100.</span><span class="p">,</span><span class="bp">False</span><span class="p">]},</span>
     2982            <span class="s">&#39;Unified tube&#39;</span><span class="p">:{</span><span class="s">&#39;Length&#39;</span><span class="p">:[</span><span class="mf">100.</span><span class="p">,</span><span class="bp">False</span><span class="p">],</span><span class="s">&#39;Thickness&#39;</span><span class="p">:[</span><span class="mf">10.</span><span class="p">,</span><span class="bp">False</span><span class="p">]},}</span>
     2983               
     2984        <span class="n">ffDistChoices</span> <span class="o">=</span>  <span class="p">[</span><span class="s">&#39;Sphere&#39;</span><span class="p">,</span><span class="s">&#39;Spheroid&#39;</span><span class="p">,</span><span class="s">&#39;Cylinder&#39;</span><span class="p">,</span><span class="s">&#39;Cylinder diam&#39;</span><span class="p">,</span>
     2985            <span class="s">&#39;Cylinder AR&#39;</span><span class="p">,</span><span class="s">&#39;Unified sphere&#39;</span><span class="p">,</span><span class="s">&#39;Unified rod&#39;</span><span class="p">,</span><span class="s">&#39;Unified rod AR&#39;</span><span class="p">,</span>
     2986            <span class="s">&#39;Unified disk&#39;</span><span class="p">,</span><span class="s">&#39;Unified tube&#39;</span><span class="p">,]</span>
     2987               
     2988        <span class="n">ffMonoChoices</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Sphere&#39;</span><span class="p">,</span><span class="s">&#39;Spheroid&#39;</span><span class="p">,</span><span class="s">&#39;Cylinder&#39;</span><span class="p">,</span><span class="s">&#39;Cylinder AR&#39;</span><span class="p">,</span>
     2989            <span class="p">]</span>
     2990                 
     2991        <span class="k">def</span> <span class="nf">OnValue</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     2992            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     2993            <span class="n">item</span><span class="p">,</span><span class="n">key</span><span class="p">,</span><span class="nb">id</span><span class="p">,</span><span class="n">sldrObj</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     2994            <span class="k">try</span><span class="p">:</span>
     2995                <span class="n">value</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span>
     2996                <span class="k">if</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="mf">0.</span><span class="p">:</span>
     2997                    <span class="k">raise</span> <span class="ne">ValueError</span>
     2998            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     2999                <span class="n">value</span> <span class="o">=</span> <span class="n">item</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="nb">id</span><span class="p">]</span>
     3000            <span class="n">item</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="nb">id</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     3001            <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%.3g</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
     3002            <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;P&#39;</span><span class="p">:</span>
     3003                <span class="n">sldrObj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mf">1000.</span><span class="o">*</span><span class="n">value</span><span class="p">)</span>
     3004            <span class="k">else</span><span class="p">:</span>
     3005                <span class="n">sldrObj</span><span class="o">.</span><span class="n">SetRange</span><span class="p">(</span><span class="mf">1000.</span><span class="o">*</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="o">-</span><span class="mi">2</span><span class="p">),</span><span class="mf">1000.</span><span class="o">*</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="o">+</span><span class="mi">2</span><span class="p">))</span>
     3006                <span class="n">sldrObj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mf">1000.</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
     3007            <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3008            <span class="n">RefreshPlots</span><span class="p">()</span>
     3009           
     3010        <span class="k">def</span> <span class="nf">OnSelect</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     3011            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     3012            <span class="n">item</span><span class="p">,</span><span class="n">key</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     3013            <span class="n">item</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     3014            <span class="k">if</span> <span class="s">&#39;Refine&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetLabel</span><span class="p">():</span>
     3015                <span class="k">if</span> <span class="s">&#39;FormFact&#39;</span> <span class="ow">in</span> <span class="n">key</span> <span class="p">:</span>
     3016                    <span class="n">item</span><span class="p">[</span><span class="s">&#39;FFargs&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">FormFactors</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()]</span>
     3017                <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3018                <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3019                <span class="n">RefreshPlots</span><span class="p">()</span>
     3020               
     3021        <span class="k">def</span> <span class="nf">OnDelLevel</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     3022            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     3023            <span class="n">item</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     3024            <span class="k">del</span> <span class="n">data</span><span class="p">[</span><span class="s">&#39;Particle&#39;</span><span class="p">][</span><span class="s">&#39;Levels&#39;</span><span class="p">][</span><span class="n">item</span><span class="p">]</span>
     3025            <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">UpdateModelsGrid</span><span class="p">,</span><span class="n">G2frame</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3026            <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3027            <span class="n">RefreshPlots</span><span class="p">()</span>
     3028           
     3029        <span class="k">def</span> <span class="nf">OnParmSlider</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     3030            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     3031            <span class="n">item</span><span class="p">,</span><span class="n">key</span><span class="p">,</span><span class="nb">id</span><span class="p">,</span><span class="n">pvObj</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     3032            <span class="n">slide</span> <span class="o">=</span> <span class="n">Obj</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span>
     3033            <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;P&#39;</span><span class="p">:</span>
     3034                <span class="n">value</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">slide</span><span class="o">/</span><span class="mf">1000.</span><span class="p">)</span>
     3035            <span class="k">else</span><span class="p">:</span>
     3036                <span class="n">value</span> <span class="o">=</span> <span class="mf">10.</span><span class="o">**</span><span class="nb">float</span><span class="p">(</span><span class="n">slide</span><span class="o">/</span><span class="mf">1000.</span><span class="p">)</span>
     3037            <span class="n">item</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="nb">id</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
     3038            <span class="n">pvObj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%.3g</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="nb">id</span><span class="p">]))</span>
     3039            <span class="n">G2sasd</span><span class="o">.</span><span class="n">ModelFxn</span><span class="p">(</span><span class="n">Profile</span><span class="p">,</span><span class="n">ProfDict</span><span class="p">,</span><span class="n">Limits</span><span class="p">,</span><span class="n">Substances</span><span class="p">,</span><span class="n">Sample</span><span class="p">,</span><span class="n">data</span><span class="p">)</span>
     3040            <span class="n">RefreshPlots</span><span class="p">()</span>
     3041           
     3042        <span class="k">def</span> <span class="nf">OnCenterSlider</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     3043            <span class="n">Obj</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span>
     3044            <span class="n">Obj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
     3045            <span class="n">sldrObj</span><span class="p">,</span><span class="n">value</span> <span class="o">=</span> <span class="n">Indx</span><span class="p">[</span><span class="n">Obj</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span>
     3046            <span class="n">sldrObj</span><span class="o">.</span><span class="n">SetRange</span><span class="p">(</span><span class="mi">1000</span><span class="o">*</span><span class="p">(</span><span class="n">value</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="mi">1000</span><span class="o">*</span><span class="p">(</span><span class="n">value</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span>
     3047            <span class="n">sldrObj</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="mi">1000</span><span class="o">*</span><span class="n">value</span><span class="p">)</span>
     3048           
     3049        <span class="k">def</span> <span class="nf">SizeSizer</span><span class="p">():</span>
     3050            <span class="n">sizeSizer</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">FlexGridSizer</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
     3051            <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Distribution: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3052            <span class="n">Distchoice</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;LogNormal&#39;</span><span class="p">,</span><span class="s">&#39;Gaussian&#39;</span><span class="p">,</span><span class="s">&#39;LSW&#39;</span><span class="p">,</span><span class="s">&#39;Schulz-Zimm&#39;</span><span class="p">,</span><span class="s">&#39;Bragg&#39;</span><span class="p">,</span><span class="s">&#39;Unified&#39;</span><span class="p">,</span><span class="s">&#39;Porod&#39;</span><span class="p">,</span><span class="s">&#39;Monodisperse&#39;</span><span class="p">,]</span>
     3053            <span class="n">distChoice</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;DistType&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">Distchoice</span><span class="p">,</span>
     3054                <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     3055            <span class="n">Indx</span><span class="p">[</span><span class="n">distChoice</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">],</span><span class="s">&#39;DistType&#39;</span><span class="p">]</span>
     3056            <span class="n">distChoice</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnSelect</span><span class="p">)</span>
     3057            <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">distChoice</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3058            <span class="k">if</span> <span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;DistType&#39;</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Bragg&#39;</span><span class="p">,</span><span class="s">&#39;Unified&#39;</span><span class="p">,</span><span class="s">&#39;Porod&#39;</span><span class="p">,]:</span>
     3059                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Form Factor: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3060                <span class="k">if</span> <span class="s">&#39;Mono&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;DistType&#39;</span><span class="p">]:</span>
     3061                    <span class="n">ffChoice</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;FormFact&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">ffDistChoices</span><span class="p">,</span>
     3062                        <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     3063                <span class="k">else</span><span class="p">:</span>
     3064                    <span class="n">ffChoice</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;FormFact&#39;</span><span class="p">],</span><span class="n">choices</span><span class="o">=</span><span class="n">ffMonoChoices</span><span class="p">,</span>
     3065                        <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     3066                <span class="n">Indx</span><span class="p">[</span><span class="n">ffChoice</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">],</span><span class="s">&#39;FormFact&#39;</span><span class="p">]</span>
     3067                <span class="n">ffChoice</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnSelect</span><span class="p">)</span>
     3068                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">ffChoice</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3069                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Material: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3070                <span class="n">matSel</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;Material&#39;</span><span class="p">],</span>
     3071                    <span class="n">choices</span><span class="o">=</span><span class="n">Substances</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span><span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     3072                <span class="n">Indx</span><span class="p">[</span><span class="n">matSel</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">],</span><span class="s">&#39;Material&#39;</span><span class="p">]</span>
     3073                <span class="n">matSel</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnSelect</span><span class="p">)</span>       
     3074                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">matSel</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span> <span class="c">#do neutron test here?</span>
     3075                <span class="n">rho</span> <span class="o">=</span> <span class="n">Substances</span><span class="p">[</span><span class="s">&#39;Substances&#39;</span><span class="p">][</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;Material&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;XAnom density&#39;</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
     3076                <span class="n">contrast</span> <span class="o">=</span> <span class="n">rho</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="n">rhoMat</span><span class="o">**</span><span class="mi">2</span>
     3077                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Resonant X-ray contrast: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3078                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39;  </span><span class="si">%.2f</span><span class="s"> 10</span><span class="si">%s</span><span class="s">cm</span><span class="si">%s</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">contrast</span><span class="p">,</span><span class="n">Pwr20</span><span class="p">,</span><span class="n">Pwrm4</span><span class="p">)),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3079                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Num. radii: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3080                <span class="n">radii</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;25&#39;</span><span class="p">,</span><span class="s">&#39;50&#39;</span><span class="p">,</span><span class="s">&#39;75&#39;</span><span class="p">,</span><span class="s">&#39;100&#39;</span><span class="p">,</span><span class="s">&#39;200&#39;</span><span class="p">]</span>
     3081                <span class="n">nRadii</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">value</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;NumPoints&#39;</span><span class="p">]),</span><span class="n">choices</span><span class="o">=</span><span class="n">radii</span><span class="p">,</span>
     3082                    <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_DROPDOWN</span><span class="p">)</span>
     3083                <span class="n">Indx</span><span class="p">[</span><span class="n">nRadii</span><span class="o">.</span><span class="n">GetId</span><span class="p">()]</span> <span class="o">=</span> <span class="p">[</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">],</span><span class="s">&#39;NumPoints&#39;</span><span class="p">]</span>
     3084                <span class="n">nRadii</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">,</span><span class="n">OnSelect</span><span class="p">)</span>
     3085                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">nRadii</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3086                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; R dist. cutoff: &#39;</span><span class="p">),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3087                <span class="n">rCutoff</span> <span class="o">=</span> <span class="n">G2gd</span><span class="o">.</span><span class="n">ValidatedTxtCtrl</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">],</span><span class="s">&#39;Cutoff&#39;</span><span class="p">,</span>
     3088                    <span class="nb">min</span><span class="o">=</span><span class="mf">0.001</span><span class="p">,</span><span class="nb">max</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span><span class="n">typeHint</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span>
     3089                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">rCutoff</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3090            <span class="k">elif</span> <span class="n">level</span><span class="p">[</span><span class="s">&#39;Controls&#39;</span><span class="p">][</span><span class="s">&#39;DistType&#39;</span><span class="p">]</span>  <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Unified&#39;</span><span class="p">,]:</span>
     3091                <span class="n">Parms</span> <span class="o">=</span> <span class="n">level</span><span class="p">[</span><span class="s">&#39;Unified&#39;</span><span class="p">]</span>
     3092                <span class="n">Best</span> <span class="o">=</span> <span class="n">G2sasd</span><span class="o">.</span><span class="n">Bestimate</span><span class="p">(</span><span class="n">Parms</span><span class="p">[</span><span class="s">&#39;G&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Parms</span><span class="p">[</span><span class="s">&#39;Rg&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Parms</span><span class="p">[</span><span class="s">&#39;P&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
     3093                <span class="n">sizeSizer</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">dataDisplay</span><span class="p">,</span><span class="n">label</span><span class="o">=</span><span class="s">&#39; Estimated Dist B: </span><span class="si">%12.4g</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Best</span><span class="p">)),</span><span class="mi">0</span><span class="p">,</span><span class="n">WACV</span><span class="p">)</span>
     3094            <span class="k