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/G2pwd_fxye.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-10-25 14:24:22 -0500 (Fri, 25 Oct 2013) $</span>
     55<span class="c"># $Date: 2013-12-16 10:43:01 -0600 (Mon, 16 Dec 2013) $</span>
    5656<span class="c"># $Author: toby $</span>
    57 <span class="c"># $Revision: 1123 $</span>
     57<span class="c"># $Revision: 1168 $</span>
    5858<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/imports/G2pwd_fxye.py $</span>
    59 <span class="c"># $Id: G2pwd_fxye.py 1123 2013-10-25 19:24:22Z toby $</span>
     59<span class="c"># $Id: G2pwd_fxye.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>
     
    7171<span class="kn">import</span> <span class="nn">GSASIIIO</span> <span class="kn">as</span> <span class="nn">G2IO</span>
    7272<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    73 <span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1123 $&quot;</span><span class="p">)</span>
     73<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>
    7474
    7575<div class="viewcode-block" id="GSAS_ReaderClass"><a class="viewcode-back" href="../imports.html#G2pwd_fxye.GSAS_ReaderClass">[docs]</a><span class="k">class</span> <span class="nc">GSAS_ReaderClass</span><span class="p">(</span><span class="n">G2IO</span><span class="o">.</span><span class="n">ImportPowderData</span><span class="p">):</span>
     
    8686    <span class="c"># Validate the contents -- look for a bank line</span>
    8787<div class="viewcode-block" id="GSAS_ReaderClass.ContentsValidator"><a class="viewcode-back" href="../imports.html#G2pwd_fxye.GSAS_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>
     88        <span class="s">&#39;Validate by checking to see if the file has BANK lines&#39;</span>
    8889        <span class="c">#print &#39;ContentsValidator: &#39;+self.formatName</span>
    8990        <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">filepointer</span><span class="p">):</span>
     
    9192            <span class="k">if</span> <span class="n">i</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span> <span class="c"># first line is always a comment</span>
    9293                <span class="k">continue</span>
    93 <span class="c">#            if i==1 and line[:4].lower() == &#39;inst&#39; and &#39;:&#39; in line:</span>
    9494            <span class="k">if</span> <span class="n">i</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="n">line</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s">&#39;inst&#39;</span><span class="p">:</span>
    9595                <span class="c"># 2nd line is optional instrument parameter file</span>
     
    102102                <span class="k">return</span> <span class="bp">True</span>
    103103            <span class="k">else</span><span class="p">:</span>
    104                 <span class="k">print</span> <span class="s">&#39;ContentsValidator: &#39;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">formatName</span>
    105                 <span class="k">print</span> <span class="s">&#39;Unexpected information in line:&#39;</span><span class="p">,</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span> <span class="c"># debug info</span>
    106                 <span class="k">print</span> <span class="n">line</span>
     104                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Unexpected information in line: &#39;</span><span class="o">+</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>
     105                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">+=</span> <span class="s">&#39;  &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
    107106                <span class="k">return</span> <span class="bp">False</span>
    108107        <span class="k">return</span> <span class="bp">False</span> <span class="c"># no bank records</span>
    109108</div>
    110109<div class="viewcode-block" id="GSAS_ReaderClass.Reader"><a class="viewcode-back" href="../imports.html#G2pwd_fxye.GSAS_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">kwarg</span><span class="p">):</span>
    111        
     110        <span class="sd">&#39;&#39;&#39;Read a GSAS (old formats) file of type FXY, FXYE, ESD or STD types.</span>
     111<span class="sd">        If multiple datasets are requested, use self.repeat and buffer caching.</span>
     112<span class="sd">        &#39;&#39;&#39;</span>
    112113        <span class="k">def</span> <span class="nf">GetFXYEdata</span><span class="p">(</span><span class="n">File</span><span class="p">,</span><span class="n">Pos</span><span class="p">,</span><span class="n">Bank</span><span class="p">):</span>
    113114            <span class="n">File</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">Pos</span><span class="p">)</span>
     
    271272
    272273        <span class="c"># read through the file and find the beginning of each bank</span>
    273         <span class="c"># Save the offset (Pos), BANK line (Banks), comments for each</span>
    274         <span class="c"># bank</span>
     274        <span class="c"># Save the offset (Pos), BANK line (Banks), comments for each bank</span>
     275        <span class="c">#</span>
     276        <span class="c"># This is going to need a fair amount of work to track line numbers</span>
     277        <span class="c"># in the input file. </span>
    275278        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Banks</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">Pos</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">Banks</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
    276279            <span class="k">try</span><span class="p">:</span>
     
    282285                       
    283286                    <span class="k">if</span> <span class="n">i</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span> <span class="c"># first line is always a comment</span>
     287                        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading title&#39;</span>
    284288                        <span class="n">title</span> <span class="o">=</span> <span class="n">S</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    285289                        <span class="n">comments</span> <span class="o">=</span> <span class="p">[[</span><span class="n">title</span><span class="p">,]]</span>
     
    287291                    <span class="k">if</span> <span class="n">i</span><span class="o">==</span><span class="mi">1</span> <span class="ow">and</span> <span class="n">S</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s">&#39;inst&#39;</span> <span class="ow">and</span> <span class="s">&#39;:&#39;</span> <span class="ow">in</span> <span class="n">S</span><span class="p">:</span>
    288292                        <span class="c"># 2nd line is instrument parameter file (optional)</span>
     293                        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading instrument parameter filename&#39;</span>
    289294                        <span class="bp">self</span><span class="o">.</span><span class="n">instparm</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;:&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
    290295                        <span class="k">continue</span>
     
    294299                        <span class="k">continue</span>
    295300                    <span class="k">if</span> <span class="n">S</span><span class="p">[:</span><span class="mi">4</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;BANK&#39;</span><span class="p">:</span>
     301                        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading bank:&#39;</span>
     302                        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">+=</span> <span class="s">&#39;  &#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">S</span><span class="p">)</span>
    296303                        <span class="n">comments</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">title</span><span class="p">,])</span>
    297304                        <span class="n">Banks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">S</span><span class="p">)</span>
    298305                        <span class="n">Pos</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">filepointer</span><span class="o">.</span><span class="n">tell</span><span class="p">())</span>
    299306                    <span class="k">if</span> <span class="n">S</span><span class="p">[:</span><span class="mi">8</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;TIME_MAP&#39;</span><span class="p">:</span>
     307                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">Banks</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
     308                            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading time map before any bank lines&#39;</span>
     309                        <span class="k">else</span><span class="p">:</span>
     310                            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading time map after bank:</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">Banks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
    300311                        <span class="bp">self</span><span class="o">.</span><span class="n">TimeMap</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">clockWd</span> <span class="o">=</span> <span class="n">GetTimeMap</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">filepointer</span><span class="o">.</span><span class="n">tell</span><span class="p">(),</span><span class="n">S</span><span class="p">)</span>
    301312            <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">detail</span><span class="p">:</span>
     313                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">+=</span> <span class="s">&#39;</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">detail</span><span class="p">)</span>
    302314                <span class="k">print</span> <span class="bp">self</span><span class="o">.</span><span class="n">formatName</span><span class="o">+</span><span class="s">&#39; scan error:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span> <span class="c"># for testing</span>
    303315                <span class="kn">import</span> <span class="nn">traceback</span>
     
    309321            <span class="k">print</span> <span class="bp">self</span><span class="o">.</span><span class="n">formatName</span><span class="o">+</span><span class="s">&#39; scan error: no BANK records&#39;</span>
    310322            <span class="n">selblk</span> <span class="o">=</span> <span class="bp">None</span> <span class="c"># no block to choose</span>
     323            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;No BANK records found (strange!)&#39;</span>
    311324            <span class="k">return</span> <span class="bp">False</span>
    312325        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">Banks</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="c"># only one Bank, don&#39;t ask</span>
     
    340353        <span class="k">try</span><span class="p">:</span>
    341354            <span class="k">if</span> <span class="s">&#39;FXYE&#39;</span> <span class="ow">in</span> <span class="n">Bank</span><span class="p">:</span>
     355                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading FXYE data in Bank</span><span class="se">\n</span><span class="s">  &#39;</span><span class="o">+</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
    342356                <span class="bp">self</span><span class="o">.</span><span class="n">powderdata</span> <span class="o">=</span> <span class="n">GetFXYEdata</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">Pos</span><span class="p">[</span><span class="n">selblk</span><span class="p">],</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">])</span>
    343357            <span class="k">elif</span> <span class="s">&#39;FXY&#39;</span> <span class="ow">in</span> <span class="n">Bank</span><span class="p">:</span>
     358                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading FXY data in Bank</span><span class="se">\n</span><span class="s">  &#39;</span><span class="o">+</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
    344359                <span class="bp">self</span><span class="o">.</span><span class="n">powderdata</span> <span class="o">=</span> <span class="n">GetFXYdata</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">Pos</span><span class="p">[</span><span class="n">selblk</span><span class="p">],</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">])</span>
    345360            <span class="k">elif</span> <span class="s">&#39;ESD&#39;</span> <span class="ow">in</span> <span class="n">Bank</span><span class="p">:</span>
     361                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading ESD data in Bank</span><span class="se">\n</span><span class="s">  &#39;</span><span class="o">+</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
    346362                <span class="bp">self</span><span class="o">.</span><span class="n">powderdata</span> <span class="o">=</span> <span class="n">GetESDdata</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">Pos</span><span class="p">[</span><span class="n">selblk</span><span class="p">],</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">])</span>
    347363            <span class="k">elif</span> <span class="s">&#39;STD&#39;</span> <span class="ow">in</span> <span class="n">Bank</span><span class="p">:</span>
     364                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading STD data in Bank</span><span class="se">\n</span><span class="s">  &#39;</span><span class="o">+</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
    348365                <span class="bp">self</span><span class="o">.</span><span class="n">powderdata</span> <span class="o">=</span> <span class="n">GetSTDdata</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">Pos</span><span class="p">[</span><span class="n">selblk</span><span class="p">],</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">])</span>
    349366            <span class="k">else</span><span class="p">:</span>
     367                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading STD data in Bank</span><span class="se">\n</span><span class="s">  &#39;</span><span class="o">+</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
    350368                <span class="bp">self</span><span class="o">.</span><span class="n">powderdata</span> <span class="o">=</span> <span class="n">GetSTDdata</span><span class="p">(</span><span class="n">filepointer</span><span class="p">,</span><span class="n">Pos</span><span class="p">[</span><span class="n">selblk</span><span class="p">],</span><span class="n">Banks</span><span class="p">[</span><span class="n">selblk</span><span class="p">])</span>
    351369        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">detail</span><span class="p">:</span>
     370            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">+=</span> <span class="s">&#39;</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">detail</span><span class="p">)</span>
    352371            <span class="k">print</span> <span class="bp">self</span><span class="o">.</span><span class="n">formatName</span><span class="o">+</span><span class="s">&#39; read error:&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">detail</span><span class="p">)</span> <span class="c"># for testing</span>
    353372            <span class="kn">import</span> <span class="nn">traceback</span>
    354373            <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">(</span><span class="nb">file</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span>
    355374            <span class="k">return</span> <span class="bp">False</span>
     375
     376        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error processing information after read complete&#39;</span>
    356377        <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
    357378            <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span><span class="p">[</span><span class="n">selblk</span><span class="p">]</span>
Note: See TracChangeset for help on using the changeset viewer.