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_GPX.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_GPX.py $</span>
    59 <span class="c"># $Id: G2pwd_GPX.py 1123 2013-10-25 19:24:22Z toby $</span>
     59<span class="c"># $Id: G2pwd_GPX.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>
     
    6565
    6666<span class="sd">&#39;&#39;&#39;</span>
     67<span class="kn">import</span> <span class="nn">sys</span>
    6768<span class="kn">import</span> <span class="nn">cPickle</span>
    6869<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
    6970<span class="kn">import</span> <span class="nn">GSASIIIO</span> <span class="kn">as</span> <span class="nn">G2IO</span>
    7071<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    71 <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>
     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>
    7273
    7374<div class="viewcode-block" id="GSAS2_ReaderClass"><a class="viewcode-back" href="../imports.html#G2pwd_GPX.GSAS2_ReaderClass">[docs]</a><span class="k">class</span> <span class="nc">GSAS2_ReaderClass</span><span class="p">(</span><span class="n">G2IO</span><span class="o">.</span><span class="n">ImportPowderData</span><span class="p">):</span>
     
    8384            <span class="n">longFormatName</span> <span class="o">=</span> <span class="s">&#39;GSAS-II project (.gpx file) import&#39;</span>
    8485            <span class="p">)</span>
     86       
    8587<div class="viewcode-block" id="GSAS2_ReaderClass.ContentsValidator"><a class="viewcode-back" href="../imports.html#G2pwd_GPX.GSAS2_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>
    86         <span class="c"># if the 1st section can&#39;t be read as a cPickle file, it can&#39;t be a GPX!</span>
     88        <span class="s">&quot;Test if the 1st section can be read as a cPickle block, if not it can&#39;t be .GPX!&quot;</span>
    8789        <span class="k">try</span><span class="p">:</span>
    8890            <span class="n">cPickle</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">filepointer</span><span class="p">)</span>
    8991        <span class="k">except</span><span class="p">:</span>
     92            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;This is not a valid .GPX file. Not recognized by cPickle&#39;</span>
    9093            <span class="k">return</span> <span class="bp">False</span>
    91         <span class="k">return</span> <span class="bp">True</span></div>
     94        <span class="k">return</span> <span class="bp">True</span>
     95</div>
    9296<div class="viewcode-block" id="GSAS2_ReaderClass.Reader"><a class="viewcode-back" href="../imports.html#G2pwd_GPX.GSAS2_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>
     97        <span class="sd">&#39;&#39;&#39;Read a dataset from a .GPX file.</span>
     98<span class="sd">        If multiple datasets are requested, use self.repeat and buffer caching.</span>
     99<span class="sd">        &#39;&#39;&#39;</span>
    93100        <span class="n">histnames</span> <span class="o">=</span> <span class="p">[]</span>
    94101        <span class="n">poslist</span> <span class="o">=</span> <span class="p">[]</span>
     
    112119                        <span class="n">poslist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pos</span><span class="p">)</span>
    113120            <span class="k">except</span><span class="p">:</span>
    114                 <span class="k">print</span> <span class="s">&#39;error scanning GPX file&#39;</span><span class="p">,</span><span class="n">filename</span>
     121                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Reading of histogram names failed&#39;</span>
    115122                <span class="k">return</span> <span class="bp">False</span>
    116123            <span class="k">finally</span><span class="p">:</span>
    117124                <span class="n">fl</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    118125        <span class="k">if</span> <span class="ow">not</span> <span class="n">histnames</span><span class="p">:</span>
    119             <span class="k">return</span> <span class="bp">False</span>            <span class="c"># no blocks with coordinates</span>
    120         <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">histnames</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="c"># no choices</span>
     126            <span class="k">return</span> <span class="bp">False</span>            <span class="c"># no blocks with powder data</span>
     127        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">histnames</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="c"># one block, no choices</span>
    121128            <span class="n">selblk</span> <span class="o">=</span> <span class="mi">0</span>
    122129        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">repeat</span> <span class="ow">and</span> <span class="n">selections</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
     
    127134            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">repeatcount</span> <span class="o">&gt;=</span> <span class="nb">len</span><span class="p">(</span><span class="n">selections</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">repeat</span> <span class="o">=</span> <span class="bp">False</span>
    128135        <span class="k">else</span><span class="p">:</span>                       <span class="c"># choose from options                </span>
    129 <span class="c">#            selblk = self.BlockSelector(</span>
    130 <span class="c">#                histnames,</span>
    131 <span class="c">#                ParentFrame=ParentFrame,</span>
    132 <span class="c">#                title= &#39;Select a block from the list below&#39;,</span>
    133 <span class="c">#                )</span>
    134 <span class="c">#            if selblk is None: return False # User pressed cancel</span>
    135136            <span class="n">selections</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">MultipleBlockSelector</span><span class="p">(</span>
    136137                <span class="n">histnames</span><span class="p">,</span>
     
    139140                <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">600</span><span class="p">,</span><span class="mi">100</span><span class="p">),</span>
    140141                <span class="n">header</span><span class="o">=</span><span class="s">&#39;Dataset Selector&#39;</span><span class="p">)</span>
    141             <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selections</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="k">return</span> <span class="bp">False</span>
     142            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selections</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
     143                <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;No histogram selected&#39;</span>
     144                <span class="k">return</span> <span class="bp">False</span>
    142145            <span class="n">selblk</span> <span class="o">=</span> <span class="n">selections</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c"># select first in list</span>
    143146            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selections</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="c"># prepare to loop through again</span>
     
    180183                    <span class="bp">self</span><span class="o">.</span><span class="n">instdict</span><span class="p">[</span><span class="s">&#39;wave&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">4</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="n">pos</span><span class="p">],]</span>
    181184            <span class="k">except</span><span class="p">:</span>
    182                 <span class="k">pass</span>
     185                <span class="bp">self</span><span class="o">.</span><span class="n">warnings</span> <span class="o">+=</span> <span class="s">&quot;Failed to read wavelength&quot;</span>
     186                <span class="bp">self</span><span class="o">.</span><span class="n">warnings</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>
    183187            <span class="c"># pull out temperature</span>
    184188            <span class="k">try</span><span class="p">:</span>
     
    186190                    <span class="bp">self</span><span class="o">.</span><span class="n">Sample</span><span class="p">[</span><span class="s">&#39;Temperature&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">5</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;Temperature&#39;</span><span class="p">]</span>
    187191            <span class="k">except</span><span class="p">:</span>
    188                 <span class="k">pass</span>
     192                <span class="bp">self</span><span class="o">.</span><span class="n">warnings</span> <span class="o">+=</span> <span class="s">&quot;Failed to read temperature&quot;</span>
     193                <span class="bp">self</span><span class="o">.</span><span class="n">warnings</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>
    189194            <span class="bp">self</span><span class="o">.</span><span class="n">repeat_instparm</span> <span class="o">=</span> <span class="bp">False</span> <span class="c"># prevent reuse of iparm when several hists are read</span>
    190195            <span class="k">return</span> <span class="bp">True</span>
    191196        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">detail</span><span class="p">:</span>
    192             <span class="kn">import</span> <span class="nn">sys</span>
     197            <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="s">&#39;Error reading selected histogram</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>
    193198            <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; error:&#39;</span><span class="p">,</span><span class="n">detail</span> <span class="c"># for testing</span>
    194199            <span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="c"># for testing</span>
Note: See TracChangeset for help on using the changeset viewer.