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/GSASIIstrIO.html

    r1183 r1298  
    5353<span class="c"># -*- coding: utf-8 -*-</span>
    5454<span class="c">########### SVN repository information ###################</span>
    55 <span class="c"># $Date: 2014-01-02 14:18:25 -0600 (Thu, 02 Jan 2014) $</span>
     55<span class="c"># $Date: 2014-04-19 10:28:10 -0500 (Sat, 19 Apr 2014) $</span>
    5656<span class="c"># $Author: toby $</span>
    57 <span class="c"># $Revision: 1181 $</span>
     57<span class="c"># $Revision: 1287 $</span>
    5858<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIIstrIO.py $</span>
    59 <span class="c"># $Id: GSASIIstrIO.py 1181 2014-01-02 20:18:25Z toby $</span>
     59<span class="c"># $Id: GSASIIstrIO.py 1287 2014-04-19 15:28:10Z toby $</span>
    6060<span class="c">########### SVN repository information ###################</span>
    6161<span class="sd">&#39;&#39;&#39;</span>
     
    7777<span class="kn">import</span> <span class="nn">scipy.optimize</span> <span class="kn">as</span> <span class="nn">so</span>
    7878<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    79 <span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1181 $&quot;</span><span class="p">)</span>
     79<span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1287 $&quot;</span><span class="p">)</span>
    8080<span class="kn">import</span> <span class="nn">GSASIIElem</span> <span class="kn">as</span> <span class="nn">G2el</span>
    8181<span class="kn">import</span> <span class="nn">GSASIIgrid</span> <span class="kn">as</span> <span class="nn">G2gd</span>
     
    568568        <span class="k">if</span> <span class="n">datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Sequential results&#39;</span><span class="p">:</span>
    569569            <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> <span class="o">=</span> <span class="n">SeqResult</span>
     570        <span class="c"># reset the Copy Next flag, since it should not be needed twice in a row</span>
     571        <span class="k">if</span> <span class="n">datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;Controls&#39;</span><span class="p">:</span>
     572            <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><span class="s">&#39;Copy2Next&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
    570573        <span class="k">try</span><span class="p">:</span>
    571574            <span class="n">histogram</span> <span class="o">=</span> <span class="n">Histograms</span><span class="p">[</span><span class="n">datum</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
     
    595598    <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="mi">80</span><span class="o">*</span><span class="s">&#39;*&#39;</span><span class="p">,</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span>
    596599</div>
    597 <div class="viewcode-block" id="ShowControls"><a class="viewcode-back" href="../GSASIIstruc.html#GSASIIstrIO.ShowControls">[docs]</a><span class="k">def</span> <span class="nf">ShowControls</span><span class="p">(</span><span class="n">Controls</span><span class="p">,</span><span class="n">pFile</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
     600<div class="viewcode-block" id="ShowControls"><a class="viewcode-back" href="../GSASIIstruc.html#GSASIIstrIO.ShowControls">[docs]</a><span class="k">def</span> <span class="nf">ShowControls</span><span class="p">(</span><span class="n">Controls</span><span class="p">,</span><span class="n">pFile</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span><span class="n">SeqRef</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
    598601    <span class="s">&#39;Print controls information&#39;</span>
    599602    <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Least squares controls:&#39;</span>
     
    604607        <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Minimum delta-M/M for convergence: &#39;</span><span class="p">,</span><span class="s">&#39;</span><span class="si">%.2g</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="s">&#39;min dM/M&#39;</span><span class="p">])</span>
    605608    <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Initial shift factor: &#39;</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">Controls</span><span class="p">[</span><span class="s">&#39;shift factor&#39;</span><span class="p">])</span>
     609    <span class="k">if</span> <span class="n">SeqRef</span><span class="p">:</span>
     610        <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Sequential refinement controls:&#39;</span>
     611        <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Copy of histogram results to next: &#39;</span><span class="p">,</span><span class="n">Controls</span><span class="p">[</span><span class="s">&#39;Copy2Next&#39;</span><span class="p">]</span>
     612        <span class="k">print</span> <span class="o">&gt;&gt;</span><span class="n">pFile</span><span class="p">,</span><span class="s">&#39; Process histograms in reverse order: &#39;</span><span class="p">,</span><span class="n">Controls</span><span class="p">[</span><span class="s">&#39;Reverse Seq&#39;</span><span class="p">]</span>
    606613    </div>
    607614<div class="viewcode-block" id="GetPawleyConstr"><a class="viewcode-back" href="../GSASIIstruc.html#GSASIIstrIO.GetPawleyConstr">[docs]</a><span class="k">def</span> <span class="nf">GetPawleyConstr</span><span class="p">(</span><span class="n">SGLaue</span><span class="p">,</span><span class="n">PawleyRef</span><span class="p">,</span><span class="n">pawleyVary</span><span class="p">):</span>
     
    626633            <span class="k">elif</span> <span class="n">SGLaue</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;3R&#39;</span><span class="p">,</span><span class="s">&#39;3mR&#39;</span><span class="p">]:</span>
    627634                <span class="n">isum</span> <span class="o">=</span> <span class="n">ih</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">ik</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">il</span><span class="o">**</span><span class="mi">2</span>
    628                 <span class="n">jsum</span> <span class="o">=</span> <span class="n">jh</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">jk</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">jl</span><span class="o">**</span><span class="mi">2</span>
     635                <span class="n">jsum</span> <span class="o">=</span> <span class="n">jh</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">jk</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">jl</span><span class="o">**</span><span class="mi">2</span>
    629636                <span class="n">isum2</span> <span class="o">=</span> <span class="n">ih</span><span class="o">*</span><span class="n">ik</span><span class="o">+</span><span class="n">ih</span><span class="o">*</span><span class="n">il</span><span class="o">+</span><span class="n">ik</span><span class="o">*</span><span class="n">il</span>
    630637                <span class="n">jsum2</span> <span class="o">=</span> <span class="n">jh</span><span class="o">*</span><span class="n">jk</span><span class="o">+</span><span class="n">jh</span><span class="o">*</span><span class="n">jl</span><span class="o">+</span><span class="n">jk</span><span class="o">*</span><span class="n">jl</span>
     
    22382245        <span class="n">peakList</span> <span class="o">=</span> <span class="p">[]</span>
    22392246        <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="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]):</span>
    2240             <span class="n">peakNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPkpos:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span> \
    2241                 <span class="s">&#39;:BkPkint:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPksig:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPkgam:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span>
     2247            <span class="n">peakNames</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPkpos;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span> \
     2248                <span class="s">&#39;:BkPkint;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPksig;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="s">&#39;:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">hId</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;:BkPkgam;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span>
    22422249            <span class="n">peakDict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">peakNames</span><span class="p">,</span><span class="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">][::</span><span class="mi">2</span><span class="p">])))</span>
    22432250            <span class="n">peakList</span> <span class="o">+=</span> <span class="nb">zip</span><span class="p">(</span><span class="n">peakNames</span><span class="p">,</span><span class="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">])</span>
     
    24522459        <span class="k">if</span> <span class="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]:</span>
    24532460            <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="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;nPeaks&#39;</span><span class="p">]):</span>
    2454                 <span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkpos:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkint:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span>
    2455                     <span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPksig:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkgam:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span>
     2461                <span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkpos;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkint;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span>
     2462                    <span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPksig;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span><span class="n">pfx</span><span class="o">+</span><span class="s">&#39;BkPkgam;&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)]</span>
    24562463                <span class="k">for</span> <span class="n">j</span><span class="p">,</span><span class="n">name</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">names</span><span class="p">):</span>
    24572464                    <span class="n">DebyePeaks</span><span class="p">[</span><span class="s">&#39;peaksList&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="mi">2</span><span class="o">*</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">parmDict</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
Note: See TracChangeset for help on using the changeset viewer.