Ignore:
Timestamp:
Dec 16, 2013 10:43:01 AM (9 years ago)
Author:
toby
Message:

update imports to provide error messages

File:
1 edited

Legend:

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

    r1129 r1168  
    5858<span class="sd">&#39;&#39;&#39;</span>
    5959<span class="c">########### SVN repository information ###################</span>
    60 <span class="c"># $Date: 2013-10-15 15:01:21 -0500 (Tue, 15 Oct 2013) $</span>
     60<span class="c"># $Date: 2013-11-26 14:32:25 -0600 (Tue, 26 Nov 2013) $</span>
    6161<span class="c"># $Author: vondreele $</span>
    62 <span class="c"># $Revision: 1107 $</span>
    63 <span class="c"># $URL: https://subversion.xray.aps.anl.gov/pyGSAS/trunk/GSASIIplot.py $</span>
    64 <span class="c"># $Id: GSASIIplot.py 1107 2013-10-15 20:01:21Z vondreele $</span>
     62<span class="c"># $Revision: 1153 $</span>
     63<span class="c"># $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIIplot.py $</span>
     64<span class="c"># $Id: GSASIIplot.py 1153 2013-11-26 20:32:25Z vondreele $</span>
    6565<span class="c">########### SVN repository information ###################</span>
    6666<span class="kn">import</span> <span class="nn">math</span>
     
    7878<span class="kn">import</span> <span class="nn">mpl_toolkits.mplot3d.axes3d</span> <span class="kn">as</span> <span class="nn">mp3d</span>
    7979<span class="kn">import</span> <span class="nn">GSASIIpath</span>
    80 <span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1107 $&quot;</span><span class="p">)</span>
     80<span class="n">GSASIIpath</span><span class="o">.</span><span class="n">SetVersionNumber</span><span class="p">(</span><span class="s">&quot;$Revision: 1153 $&quot;</span><span class="p">)</span>
    8181<span class="kn">import</span> <span class="nn">GSASIIgrid</span> <span class="kn">as</span> <span class="nn">G2gd</span>
    8282<span class="kn">import</span> <span class="nn">GSASIIimage</span> <span class="kn">as</span> <span class="nn">G2img</span>
     
    295295<span class="sd">        to F, F**2, etc. as requested</span>
    296296<span class="sd">    &#39;&#39;&#39;</span>
    297     <span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="kn">import</span> <span class="n">Circle</span>
     297    <span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="kn">import</span> <span class="n">Circle</span><span class="p">,</span><span class="n">CirclePolygon</span>
    298298    <span class="k">global</span> <span class="n">HKL</span><span class="p">,</span><span class="n">HKLF</span>
    299299
     
    368368    <span class="n">HKL</span> <span class="o">=</span> <span class="p">[]</span>
    369369    <span class="n">HKLF</span> <span class="o">=</span> <span class="p">[]</span>
     370    <span class="n">time0</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
    370371    <span class="k">for</span> <span class="n">refl</span> <span class="ow">in</span> <span class="n">HKLref</span><span class="p">:</span>
    371372        <span class="n">H</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">refl</span><span class="p">[:</span><span class="mi">3</span><span class="p">])</span>
     
    419420                        <span class="k">else</span><span class="p">:</span>                   
    420421                            <span class="n">Plot</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">Circle</span><span class="p">(</span><span class="n">xy</span><span class="p">,</span><span class="n">radius</span><span class="o">=</span><span class="n">radius</span><span class="p">,</span><span class="n">ec</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">fc</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">))</span>
     422<span class="c">#    print &#39;plot time: %.3f&#39;%(time.time()-time0)</span>
    421423    <span class="n">HKL</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">HKL</span><span class="p">,</span><span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">int</span><span class="p">)</span>
    422424    <span class="n">HKLF</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">HKLF</span><span class="p">)</span>
     
    21352137        <span class="n">PlotIntegration</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newPlot</span><span class="p">,</span><span class="n">event</span><span class="p">)</span>
    21362138</div>
     2139<div class="viewcode-block" id="OnStartMask"><a class="viewcode-back" href="../GSASIIplot.html#GSASIIplot.OnStartMask">[docs]</a><span class="k">def</span> <span class="nf">OnStartMask</span><span class="p">(</span><span class="n">G2frame</span><span class="p">):</span>
     2140    <span class="sd">&#39;&#39;&#39;Initiate the start of a Frame or Polygon map</span>
     2141
     2142<span class="sd">    :param wx.Frame G2frame: The main GSAS-II tree &quot;window&quot;</span>
     2143<span class="sd">    :param str eventkey: a single letter (&#39;f&#39; or &#39;p&#39;) that</span>
     2144<span class="sd">      determines what type of mask is created.    </span>
     2145<span class="sd">    &#39;&#39;&#39;</span>
     2146    <span class="n">Masks</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>
     2147        <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">Image</span><span class="p">,</span> <span class="s">&#39;Masks&#39;</span><span class="p">))</span>
     2148    <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;f&#39;</span><span class="p">:</span>
     2149        <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Frames&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
     2150    <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;p&#39;</span><span class="p">:</span>
     2151        <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
     2152    <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;s&#39;</span><span class="p">:</span>
     2153        <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Points&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
     2154    <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;a&#39;</span><span class="p">:</span>
     2155        <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
     2156    <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;r&#39;</span><span class="p">:</span>
     2157        <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Rings&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
     2158    <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
     2159    <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
     2160</div>
    21372161<div class="viewcode-block" id="PlotImage"><a class="viewcode-back" href="../GSASIIplot.html#GSASIIplot.PlotImage">[docs]</a><span class="k">def</span> <span class="nf">PlotImage</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">False</span><span class="p">,</span><span class="n">event</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
    21382162    <span class="sd">&#39;&#39;&#39;Plot of 2D detector images as contoured plot. Also plot calibration ellipses,</span>
     
    21412165    <span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="kn">import</span> <span class="n">Ellipse</span><span class="p">,</span><span class="n">Arc</span><span class="p">,</span><span class="n">Circle</span><span class="p">,</span><span class="n">Polygon</span>
    21422166    <span class="kn">import</span> <span class="nn">numpy.ma</span> <span class="kn">as</span> <span class="nn">ma</span>
    2143     <span class="n">Dsp</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">tth</span><span class="p">,</span><span class="n">wave</span><span class="p">:</span> <span class="n">wave</span><span class="o">/</span><span class="p">(</span><span class="mf">2.</span><span class="o">*</span><span class="n">sind</span><span class="p">(</span><span class="n">tth</span><span class="o">/</span><span class="mf">2.</span><span class="p">))</span>
     2167    <span class="n">Dsp</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">tth</span><span class="p">,</span><span class="n">wave</span><span class="p">:</span> <span class="n">wave</span><span class="o">/</span><span class="p">(</span><span class="mf">2.</span><span class="o">*</span><span class="n">npsind</span><span class="p">(</span><span class="n">tth</span><span class="o">/</span><span class="mf">2.</span><span class="p">))</span>
    21442168    <span class="k">global</span> <span class="n">Data</span><span class="p">,</span><span class="n">Masks</span>
    21452169    <span class="n">colors</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;b&#39;</span><span class="p">,</span><span class="s">&#39;g&#39;</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="s">&#39;c&#39;</span><span class="p">,</span><span class="s">&#39;m&#39;</span><span class="p">,</span><span class="s">&#39;k&#39;</span><span class="p">]</span>
    21462170    <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>
    21472171        <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">Image</span><span class="p">,</span> <span class="s">&#39;Image Controls&#39;</span><span class="p">))</span>
     2172<span class="c"># patch</span>
     2173    <span class="k">if</span> <span class="s">&#39;invert_x&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Data</span><span class="p">:</span>
     2174        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_x&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
     2175        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_y&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">True</span>
     2176<span class="c"># end patch</span>
    21482177    <span class="n">Masks</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>
    21492178        <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">Image</span><span class="p">,</span> <span class="s">&#39;Masks&#39;</span><span class="p">))</span>
     
    21832212                <span class="k">if</span> <span class="p">(</span><span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">xpix</span> <span class="o">&lt;=</span> <span class="n">sizexy</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span><span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">ypix</span> <span class="o">&lt;=</span> <span class="n">sizexy</span><span class="p">[</span><span class="mi">1</span><span class="p">]):</span>
    21842213                    <span class="n">Int</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ImageZ</span><span class="p">[</span><span class="n">ypix</span><span class="p">][</span><span class="n">xpix</span><span class="p">]</span>
    2185                 <span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">dsp</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzmDsp</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
     2214                <span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">D</span><span class="p">,</span><span class="n">dsp</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzmDsp</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
    21862215                <span class="n">Q</span> <span class="o">=</span> <span class="mf">2.</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="n">dsp</span>
    2187                 <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">setPoly</span><span class="p">:</span>
    2188                     <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Polygon mask pick - LB next point, RB close polygon&#39;</span><span class="p">])</span>
     2216                <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;p&#39;</span><span class="p">,</span><span class="s">&#39;f&#39;</span><span class="p">]:</span>
     2217                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Polygon/frame mask pick - LB next point, RB close polygon&#39;</span><span class="p">])</span>
    21892218                <span class="k">else</span><span class="p">:</span>
    21902219                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">(</span>\
     
    21972226            <span class="k">return</span>
    21982227        <span class="k">if</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
    2199             <span class="n">Xpos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">xdata</span>
    2200             <span class="k">if</span> <span class="ow">not</span> <span class="n">Xpos</span><span class="p">:</span>            <span class="c">#got point out of frame</span>
    2201                 <span class="k">return</span>
    2202             <span class="n">Ypos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">ydata</span>
    2203             <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;s&#39;</span><span class="p">:</span>
    2204                 <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Points&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="mf">1.</span><span class="p">])</span>
    2205             <span class="k">elif</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;r&#39;</span><span class="p">:</span>
    2206                 <span class="n">tth</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
    2207                 <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Rings&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">tth</span><span class="p">,</span><span class="mf">0.1</span><span class="p">])</span>
    2208             <span class="k">elif</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;a&#39;</span><span class="p">:</span>
    2209                 <span class="n">tth</span><span class="p">,</span><span class="n">azm</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzm</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
    2210                 <span class="n">azm</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>               
    2211                 <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">tth</span><span class="p">,[</span><span class="n">azm</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="n">azm</span><span class="o">+</span><span class="mi">5</span><span class="p">],</span><span class="mf">0.1</span><span class="p">])</span>
    2212             <span class="k">elif</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;p&#39;</span><span class="p">:</span>
    2213                 <span class="n">G2frame</span><span class="o">.</span><span class="n">setPoly</span> <span class="o">=</span> <span class="bp">True</span>
    2214                 <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
    2215                 <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Polygon mask active - LB pick next point, RB close polygon&#39;</span><span class="p">])</span>
    2216             <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
     2228            <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;p&#39;</span><span class="p">,</span><span class="s">&#39;f&#39;</span><span class="p">,</span><span class="s">&#39;s&#39;</span><span class="p">,</span><span class="s">&#39;a&#39;</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">]:</span>
     2229                <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span>
     2230                <span class="n">OnStartMask</span><span class="p">(</span><span class="n">G2frame</span><span class="p">)</span>
     2231               
    22172232        <span class="k">elif</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Image Controls&#39;</span><span class="p">:</span>
    2218             <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;c&#39;</span><span class="p">:</span>
     2233            <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;c&#39;</span><span class="p">,]:</span>
    22192234                <span class="n">Xpos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">xdata</span>
    22202235                <span class="k">if</span> <span class="ow">not</span> <span class="n">Xpos</span><span class="p">:</span>            <span class="c">#got point out of frame</span>
     
    22352250                <span class="k">else</span><span class="p">:</span>
    22362251                    <span class="n">G2frame</span><span class="o">.</span><span class="n">logPlot</span> <span class="o">=</span> <span class="bp">True</span>
    2237         <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
     2252            <span class="k">elif</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;x&#39;</span><span class="p">,]:</span>
     2253                <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_x&#39;</span><span class="p">]:</span>
     2254                    <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_x&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
     2255                <span class="k">else</span><span class="p">:</span>
     2256                    <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_x&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">True</span>
     2257            <span class="k">elif</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;y&#39;</span><span class="p">,]:</span>
     2258                <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_y&#39;</span><span class="p">]:</span>
     2259                    <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_y&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
     2260                <span class="k">else</span><span class="p">:</span>
     2261                    <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_y&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">True</span>
     2262        <span class="n">PlotImage</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>
    22382263           
    22392264    <span class="k">def</span> <span class="nf">OnKeyBox</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     
    22412266            <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="o">=</span> <span class="n">cb</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
    22422267            <span class="n">cb</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&#39; key press&#39;</span><span class="p">)</span>
    2243             <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="s">&#39;l&#39;</span><span class="p">:</span>
     2268            <span class="k">if</span> <span class="n">event</span><span class="o">.</span><span class="n">key</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;l&#39;</span><span class="p">,</span><span class="s">&#39;s&#39;</span><span class="p">,</span><span class="s">&#39;a&#39;</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="s">&#39;p&#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>
    22442269                <span class="n">wx</span><span class="o">.</span><span class="n">CallAfter</span><span class="p">(</span><span class="n">OnImPlotKeyPress</span><span class="p">,</span><span class="n">event</span><span class="p">)</span>
    22452270        <span class="n">Page</span><span class="o">.</span><span class="n">canvas</span><span class="o">.</span><span class="n">SetFocus</span><span class="p">()</span> <span class="c"># redirect the Focus from the button back to the plot</span>
     
    22482273        <span class="k">if</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">PickId</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Image Controls&#39;</span><span class="p">,</span><span class="s">&#39;Masks&#39;</span><span class="p">]:</span>
    22492274            <span class="k">return</span>
    2250         <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">setPoly</span><span class="p">:</span>
    2251             <span class="n">polygon</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
    2252             <span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">mouseevent</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">event</span><span class="o">.</span><span class="n">mouseevent</span><span class="o">.</span><span class="n">ydata</span>
    2253             <span class="k">if</span> <span class="n">xpos</span> <span class="ow">and</span> <span class="n">ypos</span><span class="p">:</span>                       <span class="c">#point inside image</span>
    2254                 <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">polygon</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">mouseevent</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
    2255                     <span class="n">x0</span><span class="p">,</span><span class="n">y0</span> <span class="o">=</span> <span class="n">polygon</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    2256                     <span class="n">polygon</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">x0</span><span class="p">,</span><span class="n">y0</span><span class="p">])</span>
    2257                     <span class="n">G2frame</span><span class="o">.</span><span class="n">setPoly</span> <span class="o">=</span> <span class="bp">False</span>
    2258                     <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Polygon closed - RB drag a vertex to change shape&#39;</span><span class="p">])</span>
    2259                 <span class="k">else</span><span class="p">:</span>
    2260                     <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;New polygon point: </span><span class="si">%.1f</span><span class="s">,</span><span class="si">%.1f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">)])</span>
    2261                     <span class="n">polygon</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">])</span>
    2262                 <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
    2263         <span class="k">else</span><span class="p">:</span>
    2264             <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> <span class="k">return</span>
    2265             <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">artist</span>
    2266             <span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">mouseevent</span>
     2275        <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> <span class="k">return</span>
     2276        <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">artist</span>
     2277        <span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">mouseevent</span>
    22672278       
    22682279    <span class="k">def</span> <span class="nf">OnImRelease</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
     
    22782289        <span class="n">pixLimit</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;pixLimit&#39;</span><span class="p">]</span>
    22792290        <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Image Controls&#39;</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">ImageZ</span><span class="p">):</span>
    2280 <span class="c">#            sizexy = Data[&#39;size&#39;]</span>
    22812291            <span class="n">Xpos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">xdata</span>
    22822292            <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">Xpos</span> <span class="ow">and</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ifGetRing</span><span class="p">):</span>                   <span class="c">#got point out of frame</span>
     
    23072317                <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
    23082318            <span class="k">return</span>
     2319        <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
     2320            <span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span> <span class="o">=</span> <span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">event</span><span class="o">.</span><span class="n">ydata</span><span class="p">]</span>
     2321            <span class="k">if</span> <span class="ow">not</span> <span class="n">Xpos</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">Ypos</span> <span class="ow">or</span> <span class="n">Page</span><span class="o">.</span><span class="n">toolbar</span><span class="o">.</span><span class="n">_active</span><span class="p">:</span>  <span class="c">#got point out of frame or zoom/pan selected</span>
     2322                <span class="k">return</span>
     2323            <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;s&#39;</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
     2324                <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Points&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="mf">1.</span><span class="p">]</span>
     2325                <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>               
     2326            <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;r&#39;</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
     2327                <span class="n">tth</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
     2328                <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Rings&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">tth</span><span class="p">,</span><span class="mf">0.1</span><span class="p">]</span>
     2329                <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>               
     2330            <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span> <span class="s">&#39;a&#39;</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
     2331                <span class="n">tth</span><span class="p">,</span><span class="n">azm</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzm</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
     2332                <span class="n">azm</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>               
     2333                <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">tth</span><span class="p">,[</span><span class="n">azm</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="n">azm</span><span class="o">+</span><span class="mi">5</span><span class="p">],</span><span class="mf">0.1</span><span class="p">]</span>
     2334                <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>               
     2335            <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span><span class="s">&#39;p&#39;</span><span class="p">:</span>
     2336                <span class="n">polygon</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
     2337                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">polygon</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
     2338                    <span class="n">x0</span><span class="p">,</span><span class="n">y0</span> <span class="o">=</span> <span class="n">polygon</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
     2339                    <span class="n">polygon</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">x0</span><span class="p">,</span><span class="n">y0</span><span class="p">])</span>
     2340                    <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
     2341                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Polygon closed - RB drag a vertex to change shape&#39;</span><span class="p">])</span>
     2342                <span class="k">else</span><span class="p">:</span>
     2343                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;New polygon point: </span><span class="si">%.1f</span><span class="s">,</span><span class="si">%.1f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">)])</span>
     2344                    <span class="n">polygon</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">])</span>
     2345            <span class="k">elif</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">==</span><span class="s">&#39;f&#39;</span><span class="p">:</span>
     2346                <span class="n">frame</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Frames&#39;</span><span class="p">]</span>
     2347                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">event</span><span class="o">.</span><span class="n">button</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
     2348                    <span class="n">x0</span><span class="p">,</span><span class="n">y0</span> <span class="o">=</span> <span class="n">frame</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
     2349                    <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">x0</span><span class="p">,</span><span class="n">y0</span><span class="p">])</span>
     2350                    <span class="n">G2frame</span><span class="o">.</span><span class="n">MaskKey</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
     2351                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;Frame closed - RB drag a vertex to change shape&#39;</span><span class="p">])</span>
     2352                <span class="k">else</span><span class="p">:</span>
     2353                    <span class="n">G2frame</span><span class="o">.</span><span class="n">G2plotNB</span><span class="o">.</span><span class="n">status</span><span class="o">.</span><span class="n">SetFields</span><span class="p">([</span><span class="s">&#39;&#39;</span><span class="p">,</span><span class="s">&#39;New frame point: </span><span class="si">%.1f</span><span class="s">,</span><span class="si">%.1f</span><span class="s">&#39;</span><span class="o">%</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">)])</span>
     2354                    <span class="n">frame</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">])</span>
     2355            <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
     2356            <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
    23092357        <span class="k">else</span><span class="p">:</span>
    2310             <span class="n">xpos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">xdata</span>
    2311             <span class="k">if</span> <span class="n">xpos</span><span class="p">:</span>                                        <span class="c">#avoid out of frame mouse position</span>
    2312                 <span class="n">ypos</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">ydata</span>
    2313                 <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ifGetRing</span><span class="p">:</span>                          <span class="c">#delete a calibration ring pick</span>
    2314                     <span class="n">xypos</span> <span class="o">=</span> <span class="p">[</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">]</span>
    2315                     <span class="n">rings</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ring&#39;</span><span class="p">]</span>
    2316                     <span class="k">for</span> <span class="n">ring</span> <span class="ow">in</span> <span class="n">rings</span><span class="p">:</span>
    2317                         <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">ring</span><span class="p">,</span><span class="n">xypos</span><span class="p">,</span><span class="o">.</span><span class="mo">01</span><span class="p">,</span><span class="mi">0</span><span class="p">):</span>
    2318                             <span class="n">rings</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">ring</span><span class="p">)</span>                                                                       
    2319                 <span class="k">else</span><span class="p">:</span>
    2320                     <span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">dsp</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzmDsp</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
    2321                     <span class="n">itemPicked</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="p">)</span>
    2322                     <span class="k">if</span> <span class="s">&#39;Line2D&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Image Controls&#39;</span><span class="p">:</span>
    2323                         <span class="k">if</span> <span class="s">&#39;line1&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
    2324                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">tth</span><span class="p">,</span><span class="mf">0.001</span><span class="p">)</span>
    2325                         <span class="k">elif</span> <span class="s">&#39;line2&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
    2326                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">tth</span>
    2327                         <span class="k">elif</span> <span class="s">&#39;line3&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
    2328                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>
    2329                             <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;fullIntegrate&#39;</span><span class="p">]:</span>
    2330                                 <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="mi">360</span>
    2331                         <span class="k">elif</span> <span class="s">&#39;line4&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;fullIntegrate&#39;</span><span class="p">]:</span>
    2332                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>
    2333                            
    2334                         <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
    2335                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
    2336                            
    2337                         <span class="n">azLim</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">])</span>   
    2338                         <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">azLim</span><span class="o">&gt;</span><span class="mi">360</span><span class="p">):</span>
    2339                             <span class="n">azLim</span> <span class="o">-=</span> <span class="mi">360</span>
    2340                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">azLim</span><span class="p">)</span>
    2341                            
    2342                         <span class="k">if</span>  <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
    2343                             <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    2344                            
    2345                         <span class="n">G2frame</span><span class="o">.</span><span class="n">InnerTth</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%8.2f</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;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>
    2346                         <span class="n">G2frame</span><span class="o">.</span><span class="n">OuterTth</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%8.2f</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;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
    2347                         <span class="n">G2frame</span><span class="o">.</span><span class="n">Lazim</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%6d</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;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>
    2348                         <span class="n">G2frame</span><span class="o">.</span><span class="n">Razim</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%6d</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;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
    2349                     <span class="k">elif</span> <span class="s">&#39;Circle&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
    2350                         <span class="n">spots</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Points&#39;</span><span class="p">]</span>
    2351                         <span class="n">newPos</span> <span class="o">=</span> <span class="n">itemPicked</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">0</span><span class="p">]</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">2</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;,&#39;</span><span class="p">)</span>
    2352                         <span class="n">newPos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">newPos</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">newPos</span><span class="p">[</span><span class="mi">1</span><span class="p">])])</span>
    2353                         <span class="k">for</span> <span class="n">spot</span> <span class="ow">in</span> <span class="n">spots</span><span class="p">:</span>
    2354                             <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">spot</span><span class="p">[:</span><span class="mi">2</span><span class="p">]]),</span><span class="n">newPos</span><span class="p">):</span>
    2355                                 <span class="n">spot</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span>
    2356                         <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
    2357                     <span class="k">elif</span> <span class="s">&#39;Line2D&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
    2358                         <span class="n">Obj</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="o">.</span><span class="n">findobj</span><span class="p">()</span>
    2359                         <span class="n">rings</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Rings&#39;</span><span class="p">]</span>
    2360                         <span class="n">arcs</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">]</span>
    2361                         <span class="n">polygons</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">]</span>
    2362                         <span class="k">for</span> <span class="n">ring</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="p">:</span>
    2363                             <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">ring</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    2364                                 <span class="n">rN</span> <span class="o">=</span> <span class="n">ring</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    2365                                 <span class="k">if</span> <span class="n">ring</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;o&#39;</span><span class="p">:</span>
    2366                                     <span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">-</span><span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">/</span><span class="mf">2.</span>
    2367                                 <span class="k">else</span><span class="p">:</span>
    2368                                     <span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">+</span><span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">/</span><span class="mf">2.</span>
    2369                         <span class="k">for</span> <span class="n">arc</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="p">:</span>
    2370                             <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">arc</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    2371                                 <span class="n">aN</span> <span class="o">=</span> <span class="n">arc</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    2372                                 <span class="k">if</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;o&#39;</span><span class="p">:</span>
    2373                                     <span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">-</span><span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span><span class="o">/</span><span class="mi">2</span>
    2374                                 <span class="k">elif</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;i&#39;</span><span class="p">:</span>
    2375                                     <span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">+</span><span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span><span class="o">/</span><span class="mi">2</span>
    2376                                 <span class="k">elif</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;l&#39;</span><span class="p">:</span>
    2377                                     <span class="n">arcs</span><span class="p">[</span><span class="n">aN</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="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetAzm</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
    2378                                 <span class="k">else</span><span class="p">:</span>
    2379                                     <span class="n">arcs</span><span class="p">[</span><span class="n">aN</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="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetAzm</span><span class="p">(</span><span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
    2380                         <span class="k">for</span> <span class="n">poly</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">polyList</span><span class="p">:</span>
    2381                             <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">poly</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
    2382                                 <span class="n">ind</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="p">)[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;ind&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    2383                                 <span class="n">oldPos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">ydata</span><span class="p">])</span>
    2384                                 <span class="n">pN</span> <span class="o">=</span> <span class="n">poly</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    2385                                 <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">xy</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">polygons</span><span class="p">[</span><span class="n">pN</span><span class="p">]):</span>
    2386                                     <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">xy</span><span class="p">]),</span><span class="n">oldPos</span><span class="p">,</span><span class="n">atol</span><span class="o">=</span><span class="mf">1.0</span><span class="p">):</span>
    2387                                         <span class="n">polygons</span><span class="p">[</span><span class="n">pN</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">xpos</span><span class="p">,</span><span class="n">ypos</span>
    2388                         <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
    2389 <span class="c">#                    else:                  #keep for future debugging</span>
    2390 <span class="c">#                        print str(G2frame.itemPicked),event.xdata,event.ydata,event.button</span>
    2391                 <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
     2358            <span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span> <span class="o">=</span> <span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">event</span><span class="o">.</span><span class="n">ydata</span><span class="p">]</span>
     2359            <span class="k">if</span> <span class="ow">not</span> <span class="n">Xpos</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">Ypos</span> <span class="ow">or</span> <span class="n">Page</span><span class="o">.</span><span class="n">toolbar</span><span class="o">.</span><span class="n">_active</span><span class="p">:</span>  <span class="c">#got point out of frame or zoom/pan selected</span>
     2360                <span class="k">return</span>
     2361            <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ifGetRing</span><span class="p">:</span>                          <span class="c">#delete a calibration ring pick</span>
     2362                <span class="n">xypos</span> <span class="o">=</span> <span class="p">[</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">]</span>
     2363                <span class="n">rings</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ring&#39;</span><span class="p">]</span>
     2364                <span class="k">for</span> <span class="n">ring</span> <span class="ow">in</span> <span class="n">rings</span><span class="p">:</span>
     2365                    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">ring</span><span class="p">,</span><span class="n">xypos</span><span class="p">,</span><span class="o">.</span><span class="mo">01</span><span class="p">,</span><span class="mi">0</span><span class="p">):</span>
     2366                        <span class="n">rings</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">ring</span><span class="p">)</span>
     2367            <span class="k">else</span><span class="p">:</span>
     2368                <span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">dsp</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzmDsp</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)[:</span><span class="mi">3</span><span class="p">]</span>
     2369                <span class="n">itemPicked</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="p">)</span>
     2370                <span class="k">if</span> <span class="s">&#39;Line2D&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Image Controls&#39;</span><span class="p">:</span>
     2371                    <span class="k">if</span> <span class="s">&#39;line1&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
     2372                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">tth</span><span class="p">,</span><span class="mf">0.001</span><span class="p">)</span>
     2373                    <span class="k">elif</span> <span class="s">&#39;line2&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
     2374                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">tth</span>
     2375                    <span class="k">elif</span> <span class="s">&#39;line3&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span><span class="p">:</span>
     2376                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>
     2377                        <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;fullIntegrate&#39;</span><span class="p">]:</span>
     2378                            <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="mi">360</span>
     2379                    <span class="k">elif</span> <span class="s">&#39;line4&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;fullIntegrate&#39;</span><span class="p">]:</span>
     2380                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">azm</span><span class="p">)</span>
     2381                       
     2382                    <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
     2383                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">-=</span> <span class="mi">360</span>
     2384                       
     2385                    <span class="n">azLim</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">])</span>   
     2386                    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">azLim</span><span class="o">&gt;</span><span class="mi">360</span><span class="p">):</span>
     2387                        <span class="n">azLim</span> <span class="o">-=</span> <span class="mi">360</span>
     2388                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;LRazimuth&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">azLim</span><span class="p">)</span>
     2389                       
     2390                    <span class="k">if</span>  <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
     2391                        <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span><span class="n">Data</span><span class="p">[</span><span class="s">&#39;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
     2392                       
     2393                    <span class="n">G2frame</span><span class="o">.</span><span class="n">InnerTth</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%8.2f</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;IOtth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>
     2394                    <span class="n">G2frame</span><span class="o">.</span><span class="n">OuterTth</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%8.2f</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;IOtth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
     2395                    <span class="n">G2frame</span><span class="o">.</span><span class="n">Lazim</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%6d</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;LRazimuth&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span>
     2396                    <span class="n">G2frame</span><span class="o">.</span><span class="n">Razim</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%6d</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;LRazimuth&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
     2397                <span class="k">elif</span> <span class="s">&#39;Circle&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
     2398                    <span class="n">spots</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Points&#39;</span><span class="p">]</span>
     2399                    <span class="n">newPos</span> <span class="o">=</span> <span class="n">itemPicked</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">0</span><span class="p">]</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">2</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;,&#39;</span><span class="p">)</span>
     2400                    <span class="n">newPos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">newPos</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">newPos</span><span class="p">[</span><span class="mi">1</span><span class="p">])])</span>
     2401                    <span class="k">for</span> <span class="n">spot</span> <span class="ow">in</span> <span class="n">spots</span><span class="p">:</span>
     2402                        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">spot</span><span class="p">[:</span><span class="mi">2</span><span class="p">]]),</span><span class="n">newPos</span><span class="p">):</span>
     2403                            <span class="n">spot</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span>
     2404                    <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
     2405                <span class="k">elif</span> <span class="s">&#39;Line2D&#39;</span> <span class="ow">in</span> <span class="n">itemPicked</span> <span class="ow">and</span> <span class="n">PickName</span> <span class="o">==</span> <span class="s">&#39;Masks&#39;</span><span class="p">:</span>
     2406                    <span class="n">Obj</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="o">.</span><span class="n">findobj</span><span class="p">()</span>
     2407                    <span class="n">rings</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Rings&#39;</span><span class="p">]</span>
     2408                    <span class="n">arcs</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">]</span>
     2409                    <span class="n">polygons</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">]</span>
     2410                    <span class="n">frame</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Frames&#39;</span><span class="p">]</span>
     2411                    <span class="k">for</span> <span class="n">ring</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="p">:</span>
     2412                        <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">ring</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
     2413                            <span class="n">rN</span> <span class="o">=</span> <span class="n">ring</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
     2414                            <span class="k">if</span> <span class="n">ring</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;o&#39;</span><span class="p">:</span>
     2415                                <span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">-</span><span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">/</span><span class="mf">2.</span>
     2416                            <span class="k">else</span><span class="p">:</span>
     2417                                <span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">+</span><span class="n">rings</span><span class="p">[</span><span class="n">rN</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">/</span><span class="mf">2.</span>
     2418                    <span class="k">for</span> <span class="n">arc</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="p">:</span>
     2419                        <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">arc</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
     2420                            <span class="n">aN</span> <span class="o">=</span> <span class="n">arc</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
     2421                            <span class="k">if</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;o&#39;</span><span class="p">:</span>
     2422                                <span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">-</span><span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span><span class="o">/</span><span class="mi">2</span>
     2423                            <span class="k">elif</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;i&#39;</span><span class="p">:</span>
     2424                                <span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTth</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span><span class="o">+</span><span class="n">arcs</span><span class="p">[</span><span class="n">aN</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span><span class="o">/</span><span class="mi">2</span>
     2425                            <span class="k">elif</span> <span class="n">arc</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;l&#39;</span><span class="p">:</span>
     2426                                <span class="n">arcs</span><span class="p">[</span><span class="n">aN</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="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetAzm</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
     2427                            <span class="k">else</span><span class="p">:</span>
     2428                                <span class="n">arcs</span><span class="p">[</span><span class="n">aN</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="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetAzm</span><span class="p">(</span><span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
     2429                    <span class="k">for</span> <span class="n">poly</span> <span class="ow">in</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">polyList</span><span class="p">:</span>
     2430                        <span class="k">if</span> <span class="n">Obj</span> <span class="o">==</span> <span class="n">poly</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
     2431                            <span class="n">ind</span> <span class="o">=</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="p">)[</span><span class="mi">1</span><span class="p">][</span><span class="s">&#39;ind&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
     2432                            <span class="n">oldPos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">ydata</span><span class="p">])</span>
     2433                            <span class="n">pN</span> <span class="o">=</span> <span class="n">poly</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
     2434                            <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">xy</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">polygons</span><span class="p">[</span><span class="n">pN</span><span class="p">]):</span>
     2435                                <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">xy</span><span class="p">]),</span><span class="n">oldPos</span><span class="p">,</span><span class="n">atol</span><span class="o">=</span><span class="mf">1.0</span><span class="p">):</span>
     2436                                    <span class="n">polygons</span><span class="p">[</span><span class="n">pN</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span>
     2437                    <span class="k">if</span> <span class="n">frame</span><span class="p">:</span>
     2438                        <span class="n">oldPos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">xdata</span><span class="p">,</span><span class="n">G2frame</span><span class="o">.</span><span class="n">mousePicked</span><span class="o">.</span><span class="n">ydata</span><span class="p">])</span>
     2439                        <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">xy</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">frame</span><span class="p">):</span>
     2440                            <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">xy</span><span class="p">]),</span><span class="n">oldPos</span><span class="p">,</span><span class="n">atol</span><span class="o">=</span><span class="mf">1.0</span><span class="p">):</span>
     2441                                <span class="n">frame</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">Xpos</span><span class="p">,</span><span class="n">Ypos</span>
     2442                    <span class="n">G2imG</span><span class="o">.</span><span class="n">UpdateMasks</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">Masks</span><span class="p">)</span>
     2443<span class="c">#                else:                  #keep for future debugging</span>
     2444<span class="c">#                    print str(G2frame.itemPicked),event.xdata,event.ydata,event.button</span>
     2445            <span class="n">PlotImage</span><span class="p">(</span><span class="n">G2frame</span><span class="p">,</span><span class="n">newImage</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    23922446            <span class="n">G2frame</span><span class="o">.</span><span class="n">itemPicked</span> <span class="o">=</span> <span class="bp">None</span>
    23932447           
     
    24012455            <span class="n">Page</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    24022456            <span class="n">Plot</span> <span class="o">=</span> <span class="n">Page</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span>          <span class="c">#get a fresh plot after clf()</span>
    2403        
    24042457    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
    24052458        <span class="n">Plot</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">addMpl</span><span class="p">(</span><span class="s">&#39;2D Powder Image&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span>
     
    24212474    <span class="k">try</span><span class="p">:</span>
    24222475        <span class="k">if</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">PickId</span><span class="p">)</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Image Controls&#39;</span><span class="p">,]:</span>
    2423             <span class="n">Page</span><span class="o">.</span><span class="n">Choice</span> <span class="o">=</span> <span class="p">(</span><span class="s">&#39; key press&#39;</span><span class="p">,</span><span class="s">&#39;l: log(I) on&#39;</span><span class="p">,)</span>
     2476            <span class="n">Page</span><span class="o">.</span><span class="n">Choice</span> <span class="o">=</span> <span class="p">(</span><span class="s">&#39; key press&#39;</span><span class="p">,</span><span class="s">&#39;l: log(I) on&#39;</span><span class="p">,</span><span class="s">&#39;x: flip x&#39;</span><span class="p">,</span><span class="s">&#39;y: flip y&#39;</span><span class="p">,)</span>
    24242477            <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">logPlot</span><span class="p">:</span>
    24252478                <span class="n">Page</span><span class="o">.</span><span class="n">Choice</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;l: log(I) off&#39;</span>
     2479            <span class="n">Page</span><span class="o">.</span><span class="n">keyPress</span> <span class="o">=</span> <span class="n">OnImPlotKeyPress</span>
     2480        <span class="k">elif</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">PickId</span><span class="p">)</span> <span class="ow">in</span> <span class="p">[</span><span class="s">&#39;Masks&#39;</span><span class="p">,]:</span>
     2481            <span class="n">Page</span><span class="o">.</span><span class="n">Choice</span> <span class="o">=</span> <span class="p">(</span><span class="s">&#39; key press&#39;</span><span class="p">,</span><span class="s">&#39;s: spot mask&#39;</span><span class="p">,</span><span class="s">&#39;a: arc mask&#39;</span><span class="p">,</span><span class="s">&#39;r: ring mask&#39;</span><span class="p">,</span>
     2482                <span class="s">&#39;p: polygon mask&#39;</span><span class="p">,</span><span class="s">&#39;f: frame mask&#39;</span><span class="p">,)</span>
    24262483            <span class="n">Page</span><span class="o">.</span><span class="n">keyPress</span> <span class="o">=</span> <span class="n">OnImPlotKeyPress</span>
    24272484    <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
     
    24712528            <span class="n">Img</span> <span class="o">=</span> <span class="n">Plot</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">aspect</span><span class="o">=</span><span class="s">&#39;equal&#39;</span><span class="p">,</span><span class="n">cmap</span><span class="o">=</span><span class="n">acolor</span><span class="p">,</span>
    24722529                <span class="n">interpolation</span><span class="o">=</span><span class="s">&#39;nearest&#39;</span><span class="p">,</span><span class="n">vmin</span><span class="o">=</span><span class="n">Imin</span><span class="p">,</span><span class="n">vmax</span><span class="o">=</span><span class="n">Imax</span><span class="p">,</span><span class="n">extent</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="n">Xmax</span><span class="p">,</span><span class="n">Ymax</span><span class="p">,</span><span class="mi">0</span><span class="p">])</span>
    2473             <span class="k">if</span> <span class="n">G2frame</span><span class="o">.</span><span class="n">setPoly</span><span class="p">:</span>
    2474                 <span class="n">Img</span><span class="o">.</span><span class="n">set_picker</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
    24752530   
    24762531        <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xcent</span><span class="p">,</span><span class="n">ycent</span><span class="p">,</span><span class="s">&#39;x&#39;</span><span class="p">)</span>
     
    24912546                <span class="n">xyI</span> <span class="o">=</span> <span class="p">[]</span>
    24922547                <span class="k">for</span> <span class="n">azm</span> <span class="ow">in</span> <span class="n">Azm</span><span class="p">:</span>
    2493                     <span class="n">xyI</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">dspI</span><span class="p">,</span><span class="n">azm</span><span class="o">-</span><span class="mf">90.</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
     2548                    <span class="n">xyI</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">dspI</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola?</span>
    24942549                <span class="n">xyI</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xyI</span><span class="p">)</span>
    24952550                <span class="n">arcxI</span><span class="p">,</span><span class="n">arcyI</span> <span class="o">=</span> <span class="n">xyI</span><span class="o">.</span><span class="n">T</span>
     
    24982553                <span class="n">xyO</span> <span class="o">=</span> <span class="p">[]</span>
    24992554                <span class="k">for</span> <span class="n">azm</span> <span class="ow">in</span> <span class="n">Azm</span><span class="p">:</span>
    2500                     <span class="n">xyO</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">dspO</span><span class="p">,</span><span class="n">azm</span><span class="o">-</span><span class="mf">90.</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>
     2555                    <span class="n">xyO</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">dspO</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola?</span>
    25012556                <span class="n">xyO</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xyO</span><span class="p">)</span>
    25022557                <span class="n">arcxO</span><span class="p">,</span><span class="n">arcyO</span> <span class="o">=</span> <span class="n">xyO</span><span class="o">.</span><span class="n">T</span>
     
    25162571                <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xring</span><span class="p">,</span><span class="n">yring</span><span class="p">,</span><span class="s">&#39;r+&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
    25172572            <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;setRings&#39;</span><span class="p">]:</span>
    2518     <span class="c">#            rings = np.concatenate((Data[&#39;rings&#39;]),axis=0)</span>
    25192573                <span class="n">N</span> <span class="o">=</span> <span class="mi">0</span>
    25202574                <span class="k">for</span> <span class="n">ring</span> <span class="ow">in</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;rings&#39;</span><span class="p">]:</span>
     
    25222576                    <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xring</span><span class="p">,</span><span class="n">yring</span><span class="p">,</span><span class="s">&#39;+&#39;</span><span class="p">,</span><span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">N</span><span class="o">%</span><span class="mi">6</span><span class="p">])</span>
    25232577                    <span class="n">N</span> <span class="o">+=</span> <span class="mi">1</span>           
    2524             <span class="k">for</span> <span class="n">ellipse</span> <span class="ow">in</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ellipses&#39;</span><span class="p">]:</span>
     2578            <span class="k">for</span> <span class="n">ellipse</span> <span class="ow">in</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ellipses&#39;</span><span class="p">]:</span>      <span class="c">#what about hyperbola?</span>
    25252579                <span class="n">cent</span><span class="p">,</span><span class="n">phi</span><span class="p">,[</span><span class="n">width</span><span class="p">,</span><span class="n">height</span><span class="p">],</span><span class="n">col</span> <span class="o">=</span> <span class="n">ellipse</span>
    2526                 <span class="n">Plot</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">Ellipse</span><span class="p">([</span><span class="n">cent</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">cent</span><span class="p">[</span><span class="mi">1</span><span class="p">]],</span><span class="mi">2</span><span class="o">*</span><span class="n">width</span><span class="p">,</span><span class="mi">2</span><span class="o">*</span><span class="n">height</span><span class="p">,</span><span class="n">phi</span><span class="p">,</span><span class="n">ec</span><span class="o">=</span><span class="n">col</span><span class="p">,</span><span class="n">fc</span><span class="o">=</span><span class="s">&#39;none&#39;</span><span class="p">))</span>
    2527                 <span class="n">Plot</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">cent</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">cent</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="s">&#39;+&#39;</span><span class="p">,</span><span class="n">color</span><span class="o">=</span><span class="n">col</span><span class="p">,</span><span class="n">ha</span><span class="o">=</span><span class="s">&#39;center&#39;</span><span class="p">,</span><span class="n">va</span><span class="o">=</span><span class="s">&#39;center&#39;</span><span class="p">)</span>
     2580                <span class="k">if</span> <span class="n">width</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>       <span class="c">#ellipses</span>
     2581                    <span class="n">Plot</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">Ellipse</span><span class="p">([</span><span class="n">cent</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">cent</span><span class="p">[</span><span class="mi">1</span><span class="p">]],</span><span class="mi">2</span><span class="o">*</span><span class="n">width</span><span class="p">,</span><span class="mi">2</span><span class="o">*</span><span class="n">height</span><span class="p">,</span><span class="n">phi</span><span class="p">,</span><span class="n">ec</span><span class="o">=</span><span class="n">col</span><span class="p">,</span><span class="n">fc</span><span class="o">=</span><span class="s">&#39;none&#39;</span><span class="p">))</span>
     2582                    <span class="n">Plot</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">cent</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">cent</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="s">&#39;+&#39;</span><span class="p">,</span><span class="n">color</span><span class="o">=</span><span class="n">col</span><span class="p">,</span><span class="n">ha</span><span class="o">=</span><span class="s">&#39;center&#39;</span><span class="p">,</span><span class="n">va</span><span class="o">=</span><span class="s">&#39;center&#39;</span><span class="p">)</span>
    25282583        <span class="k">if</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">PickId</span><span class="p">)</span> <span class="ow">in</span> <span class="s">&#39;Stress/Strain&#39;</span><span class="p">:</span>
    25292584            <span class="k">print</span> <span class="s">&#39;plot stress/strain stuff&#39;</span>
     
    25392594        <span class="n">arcs</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Arcs&#39;</span><span class="p">]</span>
    25402595        <span class="n">polygons</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Polygons&#39;</span><span class="p">]</span>
    2541         <span class="k">for</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">d</span> <span class="ow">in</span> <span class="n">spots</span><span class="p">:</span>
    2542             <span class="n">Plot</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">Circle</span><span class="p">((</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">),</span><span class="n">radius</span><span class="o">=</span><span class="n">d</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span><span class="n">fc</span><span class="o">=</span><span class="s">&#39;none&#39;</span><span class="p">,</span><span class="n">ec</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">))</span>
     2596        <span class="k">if</span> <span class="s">&#39;Frames&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Masks</span><span class="p">:</span>
     2597            <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Frames&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
     2598        <span class="n">frame</span> <span class="o">=</span> <span class="n">Masks</span><span class="p">[</span><span class="s">&#39;Frames&#39;</span><span class="p">]</span>
     2599        <span class="k">for</span> <span class="n">spot</span> <span class="ow">in</span> <span class="n">spots</span><span class="p">:</span>
     2600            <span class="k">if</span> <span class="n">spot</span><span class="p">:</span>
     2601                <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">d</span> <span class="o">=</span> <span class="n">spot</span>
     2602                <span class="n">Plot</span><span class="o">.</span><span class="n">add_artist</span><span class="p">(</span><span class="n">Circle</span><span class="p">((</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">),</span><span class="n">radius</span><span class="o">=</span><span class="n">d</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span><span class="n">fc</span><span class="o">=</span><span class="s">&#39;none&#39;</span><span class="p">,</span><span class="n">ec</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">))</span>
    25432603        <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span> <span class="o">=</span> <span class="p">[]</span>
    2544         <span class="k">for</span> <span class="n">iring</span><span class="p">,(</span><span class="n">tth</span><span class="p">,</span><span class="n">thick</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rings</span><span class="p">):</span>
    2545             <span class="n">wave</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;wavelength&#39;</span><span class="p">]</span>
    2546             <span class="n">x1</span><span class="p">,</span><span class="n">y1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">makeIdealRing</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetEllipse</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">+</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">Data</span><span class="p">))),</span><span class="mi">2</span><span class="p">)</span>
    2547             <span class="n">x2</span><span class="p">,</span><span class="n">y2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">makeIdealRing</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetEllipse</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">-</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">Data</span><span class="p">))),</span><span class="mi">2</span><span class="p">)</span>
    2548             <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span><span class="n">y1</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iring</span><span class="p">,</span><span class="s">&#39;o&#39;</span><span class="p">])</span>           
    2549             <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x2</span><span class="p">,</span><span class="n">y2</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iring</span><span class="p">,</span><span class="s">&#39;i&#39;</span><span class="p">])</span>
     2604        <span class="k">for</span> <span class="n">iring</span><span class="p">,</span><span class="n">ring</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rings</span><span class="p">):</span>
     2605            <span class="k">if</span> <span class="n">ring</span><span class="p">:</span>
     2606                <span class="n">tth</span><span class="p">,</span><span class="n">thick</span> <span class="o">=</span> <span class="n">ring</span>
     2607                <span class="n">wave</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;wavelength&#39;</span><span class="p">]</span>
     2608                <span class="n">xy1</span> <span class="o">=</span> <span class="p">[]</span>
     2609                <span class="n">xy2</span> <span class="o">=</span> <span class="p">[]</span>
     2610                <span class="n">Azm</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">362</span><span class="p">,</span><span class="mi">181</span><span class="p">)</span>
     2611                <span class="k">for</span> <span class="n">azm</span> <span class="ow">in</span> <span class="n">Azm</span><span class="p">:</span>
     2612                    <span class="n">xy1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">+</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola</span>
     2613                    <span class="n">xy2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">-</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola</span>
     2614                <span class="n">x1</span><span class="p">,</span><span class="n">y1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xy1</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
     2615                <span class="n">x2</span><span class="p">,</span><span class="n">y2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xy2</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
     2616                <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span><span class="n">y1</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iring</span><span class="p">,</span><span class="s">&#39;o&#39;</span><span class="p">])</span>           
     2617                <span class="n">G2frame</span><span class="o">.</span><span class="n">ringList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x2</span><span class="p">,</span><span class="n">y2</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iring</span><span class="p">,</span><span class="s">&#39;i&#39;</span><span class="p">])</span>
    25502618        <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span> <span class="o">=</span> <span class="p">[]</span>
    2551         <span class="k">for</span> <span class="n">iarc</span><span class="p">,(</span><span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">thick</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">arcs</span><span class="p">):</span>           
    2552             <span class="n">wave</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;wavelength&#39;</span><span class="p">]</span>
    2553             <span class="n">x1</span><span class="p">,</span><span class="n">y1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">makeIdealRing</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetEllipse</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">+</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">Data</span><span class="p">),</span><span class="n">azm</span><span class="p">)),</span><span class="mi">2</span><span class="p">)</span>
    2554             <span class="n">x2</span><span class="p">,</span><span class="n">y2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">makeIdealRing</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetEllipse</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="mf">0.01</span><span class="p">,</span><span class="n">tth</span><span class="o">-</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">),</span><span class="n">wave</span><span class="p">),</span><span class="n">Data</span><span class="p">),</span><span class="n">azm</span><span class="p">)),</span><span class="mi">2</span><span class="p">)</span>
    2555             <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span><span class="n">y1</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;o&#39;</span><span class="p">])</span>           
    2556             <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x2</span><span class="p">,</span><span class="n">y2</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;i&#39;</span><span class="p">])</span>
    2557             <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">x1</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">x2</span><span class="p">[</span><span class="mi">0</span><span class="p">]],[</span><span class="n">y1</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">y2</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;l&#39;</span><span class="p">])</span>
    2558             <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">x1</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">x2</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]],[</span><span class="n">y1</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">y2</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]],</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;u&#39;</span><span class="p">])</span>
     2619        <span class="k">for</span> <span class="n">iarc</span><span class="p">,</span><span class="n">arc</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">arcs</span><span class="p">):</span>
     2620            <span class="k">if</span> <span class="n">arc</span><span class="p">:</span>
     2621                <span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="n">thick</span> <span class="o">=</span> <span class="n">arc</span>           
     2622                <span class="n">wave</span> <span class="o">=</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;wavelength&#39;</span><span class="p">]</span>
     2623                <span class="n">xy1</span> <span class="o">=</span> <span class="p">[]</span>
     2624                <span class="n">xy2</span> <span class="o">=</span> <span class="p">[]</span>
     2625                <span class="n">aR</span> <span class="o">=</span> <span class="n">azm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">azm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">azm</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">azm</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
     2626                <span class="k">if</span> <span class="n">azm</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">azm</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">180</span><span class="p">:</span>
     2627                    <span class="n">aR</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">/=</span> <span class="mi">2</span>
     2628                <span class="n">Azm</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">aR</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">aR</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="n">aR</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
     2629                <span class="k">for</span> <span class="n">azm</span> <span class="ow">in</span> <span class="n">Azm</span><span class="p">:</span>
     2630                    <span class="n">xy1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">+</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola</span>
     2631                    <span class="n">xy2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">GetDetectorXY</span><span class="p">(</span><span class="n">Dsp</span><span class="p">(</span><span class="n">tth</span><span class="o">-</span><span class="n">thick</span><span class="o">/</span><span class="mf">2.</span><span class="p">,</span><span class="n">wave</span><span class="p">),</span><span class="n">azm</span><span class="p">,</span><span class="n">Data</span><span class="p">))</span>      <span class="c">#what about hyperbola</span>
     2632                <span class="n">x1</span><span class="p">,</span><span class="n">y1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xy1</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
     2633                <span class="n">x2</span><span class="p">,</span><span class="n">y2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">xy2</span><span class="p">)</span><span class="o">.</span><span class="n">T</span>
     2634                <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span><span class="n">y1</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;o&#39;</span><span class="p">])</span>           
     2635                <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x2</span><span class="p">,</span><span class="n">y2</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;i&#39;</span><span class="p">])</span>
     2636                <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">x1</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">x2</span><span class="p">[</span><span class="mi">0</span><span class="p">]],[</span><span class="n">y1</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">y2</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;l&#39;</span><span class="p">])</span>
     2637                <span class="n">G2frame</span><span class="o">.</span><span class="n">arcList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">x1</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">x2</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]],[</span><span class="n">y1</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">y2</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]],</span><span class="s">&#39;r&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">3</span><span class="p">),</span><span class="n">iarc</span><span class="p">,</span><span class="s">&#39;u&#39;</span><span class="p">])</span>
    25592638        <span class="n">G2frame</span><span class="o">.</span><span class="n">polyList</span> <span class="o">=</span> <span class="p">[]</span>
    25602639        <span class="k">for</span> <span class="n">ipoly</span><span class="p">,</span><span class="n">polygon</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">polygons</span><span class="p">):</span>
    2561             <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">polygon</span><span class="p">),</span><span class="mi">2</span><span class="p">)</span>
    2562             <span class="n">G2frame</span><span class="o">.</span><span class="n">polyList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;r+&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">10</span><span class="p">),</span><span class="n">ipoly</span><span class="p">])</span>
    2563             <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">)</span>           
     2640            <span class="k">if</span> <span class="n">polygon</span><span class="p">:</span>
     2641                <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">polygon</span><span class="p">),</span><span class="mi">2</span><span class="p">)</span>
     2642                <span class="n">G2frame</span><span class="o">.</span><span class="n">polyList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;r+&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">10</span><span class="p">),</span><span class="n">ipoly</span><span class="p">])</span>
     2643                <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;r&#39;</span><span class="p">)</span>           
     2644        <span class="n">G2frame</span><span class="o">.</span><span class="n">frameList</span> <span class="o">=</span> <span class="p">[]</span>
     2645        <span class="k">if</span> <span class="n">frame</span><span class="p">:</span>
     2646            <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">frame</span><span class="p">),</span><span class="mi">2</span><span class="p">)</span>
     2647            <span class="n">G2frame</span><span class="o">.</span><span class="n">frameList</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;g+&#39;</span><span class="p">,</span><span class="n">picker</span><span class="o">=</span><span class="mi">10</span><span class="p">),</span><span class="mi">0</span><span class="p">])</span>
     2648            <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="s">&#39;g&#39;</span><span class="p">)</span>           
    25642649        <span class="k">if</span> <span class="n">newImage</span><span class="p">:</span>
    25652650            <span class="n">colorBar</span> <span class="o">=</span> <span class="n">Page</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">Img</span><span class="p">)</span>
    25662651        <span class="n">Plot</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
    25672652        <span class="n">Plot</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
    2568         <span class="n">Plot</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
     2653        <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_x&#39;</span><span class="p">]:</span>
     2654            <span class="n">Plot</span><span class="o">.</span><span class="n">invert_xaxis</span><span class="p">()</span>
     2655        <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;invert_y&#39;</span><span class="p">]:</span>
     2656            <span class="n">Plot</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    25692657        <span class="k">if</span> <span class="ow">not</span> <span class="n">newPlot</span> <span class="ow">and</span> <span class="n">xylim</span><span class="p">:</span>
    25702658            <span class="n">Page</span><span class="o">.</span><span class="n">toolbar</span><span class="o">.</span><span class="n">push_current</span><span class="p">()</span>
     
    26292717        <span class="n">extent</span><span class="o">=</span><span class="p">[</span><span class="n">ysc</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">ysc</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">xsc</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">xsc</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span><span class="n">aspect</span><span class="o">=</span><span class="s">&#39;auto&#39;</span><span class="p">)</span>
    26302718    <span class="n">colorBar</span> <span class="o">=</span> <span class="n">Page</span><span class="o">.</span><span class="n">figure</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">Img</span><span class="p">)</span>
    2631     <span class="k">if</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ellipses&#39;</span><span class="p">]:</span>           
    2632         <span class="k">for</span> <span class="n">ellipse</span> <span class="ow">in</span> <span class="n">Data</span><span class="p">[</span><span class="s">&#39;ellipses&#39;</span><span class="p">]:</span>
    2633             <span class="n">ring</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">G2img</span><span class="o">.</span><span class="n">makeIdealRing</span><span class="p">(</span><span class="n">ellipse</span><span class="p">[:</span><span class="mi">3</span><span class="p">]))</span> <span class="c">#skip color</span>
    2634             <span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hsplit</span><span class="p">(</span><span class="n">ring</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
    2635             <span class="n">tth</span><span class="p">,</span><span class="n">azm</span> <span class="o">=</span> <span class="n">G2img</span><span class="o">.</span><span class="n">GetTthAzm</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">Data</span><span class="p">)</span>
    2636 <span class="c">#            azm = np.where(azm &lt; 0.,azm+360,azm)</span>
    2637             <span class="n">Plot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tth</span><span class="p">,</span><span class="n">azm</span><span class="p">,</span><span class="s">&#39;b,&#39;</span><span class="p">)</span>
     2719<span class="c">#    if Data[&#39;ellipses&#39;]:            </span>
     2720<span class="c">#        for ellipse in Data[&#39;ellipses&#39;]:</span>
     2721<span class="c">#            x,y = np.array(G2img.makeIdealRing(ellipse[:3])) #skip color</span>
     2722<span class="c">#            tth,azm = G2img.GetTthAzm(x,y,Data)</span>
     2723<span class="c">##            azm = np.where(azm &lt; 0.,azm+360,azm)</span>
     2724<span class="c">#            Plot.plot(tth,azm,&#39;b,&#39;)</span>
    26382725    <span class="k">if</span> <span class="ow">not</span> <span class="n">newPlot</span><span class="p">:</span>
    26392726        <span class="n">Page</span><span class="o">.</span><span class="n">toolbar</span><span class="o">.</span><span class="n">push_current</span><span class="p">()</span>
Note: See TracChangeset for help on using the changeset viewer.