Ignore:
Timestamp:
Jan 5, 2014 9:22:22 AM (8 years ago)
Author:
toby
Message:

fixup number formatting; update produced doc files

File:
1 edited

Legend:

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

    r1168 r1183  
    5353<span class="c"># -*- coding: utf-8 -*-</span>
    5454<span class="c">########### SVN repository information ###################</span>
    55 <span class="c"># $Date: 2013-11-06 15:16:07 -0600 (Wed, 06 Nov 2013) $</span>
    56 <span class="c"># $Author: vondreele $</span>
    57 <span class="c"># $Revision: 1137 $</span>
     55<span class="c"># $Date: 2013-12-16 10:43:01 -0600 (Mon, 16 Dec 2013) $</span>
     56<span class="c"># $Author: toby $</span>
     57<span class="c"># $Revision: 1168 $</span>
    5858<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/imports/G2sfact.py $</span>
    59 <span class="c"># $Id: G2sfact.py 1137 2013-11-06 21:16:07Z vondreele $</span>
     59<span class="c"># $Id: G2sfact.py 1168 2013-12-16 16:43:01Z toby $</span>
    6060<span class="c">########### SVN repository information ###################</span>
    6161<span class="sd">&#39;&#39;&#39;</span>
     
    7070<span class="kn">import</span> <span class="nn">GSASIIIO</span> <span class="kn">as</span> <span class="nn">G2IO</span>
    7171<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    72 <span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1137 $&quot;</span><span class="p">)</span>
    73 
     72<span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1168 $&quot;</span><span class="p">)</span>
     73
     74<div class="viewcode-block" id="ColumnValidator"><a class="viewcode-back" href="../imports.html#G2sfact.ColumnValidator">[docs]</a><span class="k">def</span> <span class="nf">ColumnValidator</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">filepointer</span><span class="p">):</span>
     75    <span class="s">&#39;Validate a file to check that it contains columns of numbers&#39;</span>
     76    <span class="n">l</span> <span class="o">=</span> <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
     77    <span class="n">line</span> <span class="o">=</span> <span class="mi">1</span>
     78    <span class="k">while</span> <span class="s">&#39;#&#39;</span> <span class="ow">in</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>        <span class="c">#get past comments, if any</span>
     79        <span class="n">l</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>       
     80        <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
     81    <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> <span class="c"># scan a few lines</span>
     82        <span class="n">S</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
     83        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">5</span><span class="p">:</span>
     84            <span class="n">parent</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;line &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;: invalid input</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">l</span>
     85            <span class="k">return</span> <span class="bp">False</span>
     86        <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">S</span><span class="p">:</span>
     87            <span class="k">try</span><span class="p">:</span>
     88                <span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
     89            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
     90                <span class="n">parent</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;line &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;: string found where a number is expected</span><span class="se">\n</span><span class="s">&#39;</span><span class="o">+</span><span class="n">l</span>
     91                <span class="k">return</span> <span class="bp">False</span>           
     92        <span class="n">l</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
     93        <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
     94    <span class="k">return</span> <span class="bp">True</span>
     95
     96</div>
    7497<div class="viewcode-block" id="HKLF_ReaderClass"><a class="viewcode-back" href="../imports.html#G2sfact.HKLF_ReaderClass">[docs]</a><span class="k">class</span> <span class="nc">HKLF_ReaderClass</span><span class="p">(</span><span class="n">G2IO</span><span class="o">.</span><span class="n">ImportStructFactor</span><span class="p">):</span>
    7598    <span class="s">&#39;Routines to import F, sig(F) reflections from a HKLF file&#39;</span>
     
    78101            <span class="n">extensionlist</span><span class="o">=</span><span class="p">(</span><span class="s">&#39;.hkl&#39;</span><span class="p">,</span><span class="s">&#39;.HKL&#39;</span><span class="p">),</span>
    79102            <span class="n">strictExtension</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
    80             <span class="n">formatName</span> <span class="o">=</span> <span class="s">&#39;F HKL&#39;</span><span class="p">,</span>
    81             <span class="n">longFormatName</span> <span class="o">=</span> <span class="s">&#39;Simple (hkl Fo sig(Fo)) Structure factor text file&#39;</span>
     103            <span class="n">formatName</span> <span class="o">=</span> <span class="s">&#39;F containing HKL&#39;</span><span class="p">,</span>
     104            <span class="n">longFormatName</span> <span class="o">=</span> <span class="s">&#39;Simple [hkl, Fo, sig(Fo)] Structure factor text file&#39;</span>
    82105            <span class="p">)</span>
    83     <span class="c"># Validate the contents</span>
     106
    84107<div class="viewcode-block" id="HKLF_ReaderClass.ContentsValidator"><a class="viewcode-back" href="../imports.html#G2sfact.HKLF_ReaderClass.ContentsValidator">[docs]</a>    <span class="k">def</span> <span class="nf">ContentsValidator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filepointer</span><span class="p">):</span>
    85         <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
    86         <span class="n">line</span> <span class="o">=</span> <span class="mi">1</span>
    87         <span class="k">while</span> <span class="s">&#39;#&#39;</span> <span class="ow">in</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>        <span class="c">#get past comments, if any</span>
    88             <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>       
    89             <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
    90         <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> <span class="c"># scan a few lines</span>
    91             <span class="n">S</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    92             <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">5</span><span class="p">:</span> <span class="k">return</span> <span class="bp">False</span>
    93             <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">S</span><span class="p">:</span>
    94                 <span class="k">try</span><span class="p">:</span>
    95                     <span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
    96                 <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
    97                     <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;line &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;: string found where a number is expected&#39;</span>
    98                     <span class="k">return</span> <span class="bp">False</span>           
    99             <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
    100             <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
    101         <span class="k">return</span> <span class="bp">True</span>
     108        <span class="s">&#39;Make sure file contains the expected columns on numbers&#39;</span>
     109        <span class="k">return</span> <span class="n">ColumnValidator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filepointer</span><span class="p">)</span>
    102110</div>
    103111<div class="viewcode-block" id="HKLF_ReaderClass.Reader"><a class="viewcode-back" href="../imports.html#G2sfact.HKLF_ReaderClass.Reader">[docs]</a>    <span class="k">def</span> <span class="nf">Reader</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">filename</span><span class="p">,</span><span class="n">filepointer</span><span class="p">,</span> <span class="n">ParentFrame</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">unused</span><span class="p">):</span>
     112        <span class="s">&#39;Read the file&#39;</span>
    104113        <span class="k">try</span><span class="p">:</span>
    105114            <span class="k">for</span> <span class="n">line</span><span class="p">,</span><span class="n">S</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">filepointer</span><span class="p">):</span>
     
    133142            <span class="n">extensionlist</span><span class="o">=</span><span class="p">(</span><span class="s">&#39;.hkl&#39;</span><span class="p">,</span><span class="s">&#39;.HKL&#39;</span><span class="p">),</span>
    134143            <span class="n">strictExtension</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
    135             <span class="n">formatName</span> <span class="o">=</span> <span class="s">&#39;F**2 HKL&#39;</span><span class="p">,</span>
    136             <span class="n">longFormatName</span> <span class="o">=</span> <span class="s">&#39;Simple (hkl Fo**2 sig(Fo**2)) Structure factor text file&#39;</span>
     144            <span class="n">formatName</span> <span class="o">=</span> <span class="s">u&#39;F</span><span class="se">\u00b2</span><span class="s"> containing HKL&#39;</span><span class="p">,</span>
     145            <span class="n">longFormatName</span> <span class="o">=</span> <span class="s">u&#39;Simple [hkl, Fo</span><span class="se">\u00b2</span><span class="s">, sig(Fo</span><span class="se">\u00b2</span><span class="s">)] Structure factor text file&#39;</span>
    137146            <span class="p">)</span>
    138     <span class="c"># Validate the contents</span>
     147
    139148<div class="viewcode-block" id="HKLF2_ReaderClass.ContentsValidator"><a class="viewcode-back" href="../imports.html#G2sfact.HKLF2_ReaderClass.ContentsValidator">[docs]</a>    <span class="k">def</span> <span class="nf">ContentsValidator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filepointer</span><span class="p">):</span>
    140         <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
    141         <span class="n">line</span> <span class="o">=</span> <span class="mi">1</span>
    142         <span class="k">while</span> <span class="s">&#39;#&#39;</span> <span class="ow">in</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>        <span class="c">#get past comments, if any</span>
    143             <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>       
    144             <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
    145         <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> <span class="c"># scan a few lines</span>
    146             <span class="n">S</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
    147             <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">5</span><span class="p">:</span> <span class="k">return</span> <span class="bp">False</span>
    148             <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">S</span><span class="p">:</span>
    149                 <span class="k">try</span><span class="p">:</span>
    150                     <span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
    151                 <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
    152                     <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;line &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">)</span><span class="o">+</span><span class="s">&#39;: string found where a number is expected&#39;</span>
    153                     <span class="k">return</span> <span class="bp">False</span>           
    154             <span class="n">S</span> <span class="o">=</span> <span class="n">filepointer</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
    155             <span class="n">line</span> <span class="o">+=</span> <span class="mi">1</span>
    156         <span class="k">return</span> <span class="bp">True</span>
     149        <span class="s">&#39;Make sure file contains the expected columns on numbers&#39;</span>
     150        <span class="k">return</span> <span class="n">ColumnValidator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filepointer</span><span class="p">)</span>
    157151</div>
    158152<div class="viewcode-block" id="HKLF2_ReaderClass.Reader"><a class="viewcode-back" href="../imports.html#G2sfact.HKLF2_ReaderClass.Reader">[docs]</a>    <span class="k">def</span> <span class="nf">Reader</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">filename</span><span class="p">,</span><span class="n">filepointer</span><span class="p">,</span> <span class="n">ParentFrame</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">unused</span><span class="p">):</span>
     153        <span class="s">&#39;Read the file&#39;</span>
    159154        <span class="k">try</span><span class="p">:</span>
    160155            <span class="k">for</span> <span class="n">line</span><span class="p">,</span><span class="n">S</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">filepointer</span><span class="p">):</span>
Note: See TracChangeset for help on using the changeset viewer.