Skip to content

Commit

Permalink
deploy: ea9f1ba
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffjennings committed Nov 30, 2023
1 parent f4d8d74 commit 4ca5616
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 18 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
56 changes: 56 additions & 0 deletions _modules/mpol/plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ <h1>Source code for mpol.plot</h1><div class="highlight"><pre>

<span class="kn">from</span> <span class="nn">astropy.visualization.mpl_normalize</span> <span class="kn">import</span> <span class="n">simple_norm</span>

<span class="kn">from</span> <span class="nn">mpol.fourier</span> <span class="kn">import</span> <span class="n">get_vis_residuals</span>
<span class="kn">from</span> <span class="nn">mpol.gridding</span> <span class="kn">import</span> <span class="n">DirtyImager</span>
<span class="kn">from</span> <span class="nn">mpol.utils</span> <span class="kn">import</span> <span class="n">loglinspace</span><span class="p">,</span> <span class="n">torch2npy</span><span class="p">,</span> <span class="n">packed_cube_to_sky_cube</span>

<div class="viewcode-block" id="get_image_cmap_norm"><a class="viewcode-back" href="../../api.html#mpol.plot.get_image_cmap_norm">[docs]</a><span class="k">def</span> <span class="nf">get_image_cmap_norm</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">stretch</span><span class="o">=</span><span class="s1">&#39;power&#39;</span><span class="p">,</span> <span class="n">gamma</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">asinh_a</span><span class="o">=</span><span class="mf">0.02</span><span class="p">,</span> <span class="n">symmetric</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
Expand Down Expand Up @@ -339,6 +341,60 @@ <h1>Source code for mpol.plot</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">norm</span></div>


<div class="viewcode-block" id="get_residual_image"><a class="viewcode-back" href="../../api.html#mpol.plot.get_residual_image">[docs]</a><span class="k">def</span> <span class="nf">get_residual_image</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="n">weights</span><span class="p">,</span> <span class="n">robust</span><span class="o">=</span><span class="mf">0.5</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot; </span>
<span class="sd"> Get a dirty image and colormap normalization for residual visibilities,</span>
<span class="sd"> the difference of observed visibilities and an MPoL model sampled at the </span>
<span class="sd"> observed (u,v) points.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> model : `torch.nn.Module` object</span>
<span class="sd"> Instance of the `mpol.precomposed.SimpleNet` class. Contains model</span>
<span class="sd"> visibilities.</span>
<span class="sd"> u, v : array, unit=[k\lambda]</span>
<span class="sd"> Data u- and v-coordinates</span>
<span class="sd"> V : array, unit=[Jy]</span>
<span class="sd"> Data visibility amplitudes</span>
<span class="sd"> weights : array, unit=[Jy^-2]</span>
<span class="sd"> Data weights</span>
<span class="sd"> robust : float, default=0.5</span>
<span class="sd"> Robust weighting parameter used to create the dirty image of the </span>
<span class="sd"> residual visibilities</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> im_resid : 2D image array</span>
<span class="sd"> The residual image</span>
<span class="sd"> norm_resid : Matplotlib colormap normalization</span>
<span class="sd"> Symmetric, linear colormap for `im_resid`</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">vis_resid</span> <span class="o">=</span> <span class="n">get_vis_residuals</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="n">V</span><span class="p">)</span>

<span class="n">resid_imager</span> <span class="o">=</span> <span class="n">DirtyImager</span><span class="p">(</span>
<span class="n">coords</span><span class="o">=</span><span class="n">model</span><span class="o">.</span><span class="n">coords</span><span class="p">,</span>
<span class="n">uu</span><span class="o">=</span><span class="n">u</span><span class="p">,</span>
<span class="n">vv</span><span class="o">=</span><span class="n">v</span><span class="p">,</span>
<span class="n">weight</span><span class="o">=</span><span class="n">weights</span><span class="p">,</span>
<span class="n">data_re</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">real</span><span class="p">(</span><span class="n">vis_resid</span><span class="p">),</span>
<span class="n">data_im</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">imag</span><span class="p">(</span><span class="n">vis_resid</span><span class="p">),</span>
<span class="p">)</span>
<span class="n">im_resid</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">resid_imager</span><span class="o">.</span><span class="n">get_dirty_image</span><span class="p">(</span><span class="n">weighting</span><span class="o">=</span><span class="s2">&quot;briggs&quot;</span><span class="p">,</span>
<span class="n">robust</span><span class="o">=</span><span class="n">robust</span><span class="p">,</span>
<span class="n">unit</span><span class="o">=</span><span class="s1">&#39;Jy/arcsec^2&#39;</span>
<span class="p">)</span>
<span class="c1"># `get_vis_residuals` has already selected a single channel</span>
<span class="n">im_resid</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">squeeze</span><span class="p">(</span><span class="n">im_resid</span><span class="p">)</span>

<span class="n">norm_resid</span> <span class="o">=</span> <span class="n">get_image_cmap_norm</span><span class="p">(</span><span class="n">im_resid</span><span class="p">,</span>
<span class="n">stretch</span><span class="o">=</span><span class="s1">&#39;power&#39;</span><span class="p">,</span>
<span class="n">gamma</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">symmetric</span><span class="o">=</span><span class="kc">True</span>
<span class="p">)</span>

<span class="k">return</span> <span class="n">im_resid</span><span class="p">,</span> <span class="n">norm_resid</span></div>


<div class="viewcode-block" id="plot_image"><a class="viewcode-back" href="../../api.html#mpol.plot.plot_image">[docs]</a><span class="k">def</span> <span class="nf">plot_image</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">extent</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="s2">&quot;inferno&quot;</span><span class="p">,</span> <span class="n">norm</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">clab</span><span class="o">=</span><span class="sa">r</span><span class="s2">&quot;Jy arcsec$^{-2}$&quot;</span><span class="p">,</span>
<span class="n">xlab</span><span class="o">=</span><span class="sa">r</span><span class="s2">&quot;$\Delta \alpha \cos \delta$ [$</span><span class="si">{}</span><span class="s2">^{\prime\prime}$]&quot;</span><span class="p">,</span>
Expand Down
31 changes: 31 additions & 0 deletions api.html
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ <h2> Contents </h2>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#module-mpol.plot">Plotting</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.get_image_cmap_norm"><code class="docutils literal notranslate"><span class="pre">get_image_cmap_norm()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.get_residual_image"><code class="docutils literal notranslate"><span class="pre">get_residual_image()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.plot_image"><code class="docutils literal notranslate"><span class="pre">plot_image()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.vis_histogram_fig"><code class="docutils literal notranslate"><span class="pre">vis_histogram_fig()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.split_diagnostics_fig"><code class="docutils literal notranslate"><span class="pre">split_diagnostics_fig()</span></code></a></li>
Expand Down Expand Up @@ -2588,6 +2589,35 @@ <h2>Precomposed Modules<a class="headerlink" href="#precomposed-modules" title="
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="mpol.plot.get_residual_image">
<span class="sig-prename descclassname"><span class="pre">mpol.plot.</span></span><span class="sig-name descname"><span class="pre">get_residual_image</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">u</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">v</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">V</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weights</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">robust</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.5</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mpol/plot.html#get_residual_image"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mpol.plot.get_residual_image" title="Permalink to this definition">#</a></dt>
<dd><p>Get a dirty image and colormap normalization for residual visibilities,
the difference of observed visibilities and an MPoL model sampled at the
observed (u,v) points.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<cite>torch.nn.Module</cite> object) – Instance of the <cite>mpol.precomposed.SimpleNet</cite> class. Contains model
visibilities.</p></li>
<li><p><strong>u</strong> (<em>array</em><em>, </em><em>unit=</em><em>[</em><em>klambda</em><em>]</em>) – Data u- and v-coordinates</p></li>
<li><p><strong>v</strong> (<em>array</em><em>, </em><em>unit=</em><em>[</em><em>klambda</em><em>]</em>) – Data u- and v-coordinates</p></li>
<li><p><strong>V</strong> (<em>array</em><em>, </em><em>unit=</em><em>[</em><em>Jy</em><em>]</em>) – Data visibility amplitudes</p></li>
<li><p><strong>weights</strong> (<em>array</em><em>, </em><em>unit=</em><em>[</em><em>Jy^-2</em><em>]</em>) – Data weights</p></li>
<li><p><strong>robust</strong> (<em>float</em><em>, </em><em>default=0.5</em>) – Robust weighting parameter used to create the dirty image of the
residual visibilities</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><ul class="simple">
<li><p><strong>im_resid</strong> (<em>2D image array</em>) – The residual image</p></li>
<li><p><strong>norm_resid</strong> (<em>Matplotlib colormap normalization</em>) – Symmetric, linear colormap for <cite>im_resid</cite></p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="mpol.plot.plot_image">
<span class="sig-prename descclassname"><span class="pre">mpol.plot.</span></span><span class="sig-name descname"><span class="pre">plot_image</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">image</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extent</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'inferno'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">norm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clab</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Jy</span> <span class="pre">arcsec$^{-2}$'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xlab</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'$\\Delta</span> <span class="pre">\\alpha</span> <span class="pre">\\cos</span> <span class="pre">\\delta$</span> <span class="pre">[${}^{\\prime\\prime}$]'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ylab</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'$\\Delta</span> <span class="pre">\\delta$</span> <span class="pre">[${}^{\\prime\\prime}$]'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mpol/plot.html#plot_image"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#mpol.plot.plot_image" title="Permalink to this definition">#</a></dt>
Expand Down Expand Up @@ -2930,6 +2960,7 @@ <h2>Precomposed Modules<a class="headerlink" href="#precomposed-modules" title="
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#module-mpol.plot">Plotting</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.get_image_cmap_norm"><code class="docutils literal notranslate"><span class="pre">get_image_cmap_norm()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.get_residual_image"><code class="docutils literal notranslate"><span class="pre">get_residual_image()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.plot_image"><code class="docutils literal notranslate"><span class="pre">plot_image()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.vis_histogram_fig"><code class="docutils literal notranslate"><span class="pre">vis_histogram_fig()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#mpol.plot.split_diagnostics_fig"><code class="docutils literal notranslate"><span class="pre">split_diagnostics_fig()</span></code></a></li>
Expand Down
2 changes: 1 addition & 1 deletion ci-tutorials/crossvalidation.html
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ <h2>Choosing the K-folds<a class="headerlink" href="#choosing-the-k-folds" title
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>650160 visibilities total
</pre></div>
</div>
<img alt="../_images/fe2c71f1f647185d8b97f7413a520a84145ec3fd11273a5fadfe7927d364b51c.png" src="../_images/fe2c71f1f647185d8b97f7413a520a84145ec3fd11273a5fadfe7927d364b51c.png" />
<img alt="../_images/a02866988ddaf08ba6d9e8d47a850bdde147506a6812ee8369adf3cdf24310f5.png" src="../_images/a02866988ddaf08ba6d9e8d47a850bdde147506a6812ee8369adf3cdf24310f5.png" />
</div>
</div>
<p>As you can see, this training set looks very similar to the full dataset, with the same holes in <span class="math notranslate nohighlight">\(u\)</span>,<span class="math notranslate nohighlight">\(v\)</span> coverage and similar sampling densities.</p>
Expand Down
14 changes: 7 additions & 7 deletions ci-tutorials/fakedata.html
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ <h2>Exporting to a Numpy array and setting flux scale<a class="headerlink" href=
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.image.AxesImage at 0x7f54e1ff2910&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.image.AxesImage at 0x7fe30433f9a0&gt;
</pre></div>
</div>
<img alt="../_images/be79b995a2a50bbef7c7e91994d8e1236259a969198edba72563cf87593c642d.png" src="../_images/be79b995a2a50bbef7c7e91994d8e1236259a969198edba72563cf87593c642d.png" />
Expand All @@ -617,7 +617,7 @@ <h2>Exporting to a Numpy array and setting flux scale<a class="headerlink" href=
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.image.AxesImage at 0x7f54de5b7bb0&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.image.AxesImage at 0x7fe30403f3a0&gt;
</pre></div>
</div>
<img alt="../_images/a44fc2c19d14ce07c780c6b36d662170cba0b55b28bb6fd0f4cf9182abdda2e6.png" src="../_images/a44fc2c19d14ce07c780c6b36d662170cba0b55b28bb6fd0f4cf9182abdda2e6.png" />
Expand Down Expand Up @@ -795,9 +795,9 @@ <h2>Making the mock dataset<a class="headerlink" href="#making-the-mock-dataset"
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(1, 325080)
(1, 325080)
[[-0.76925965-2.62454812j 6.90191985+2.31129412j -0.29382239+1.09366486j
... 0.68623493-0.43081258j 1.00940481-1.60474041j
1.81960181+1.02408881j]]
[[ 0.09960916+0.1026781j 9.94635031+2.15740694j 2.21271329+0.15763872j
... 2.05663663-2.49270641j 1.63740598-1.92776722j
-0.94275719-1.95683933j]]
</pre></div>
</div>
</div>
Expand Down Expand Up @@ -874,7 +874,7 @@ <h2>Verifying the mock dataset<a class="headerlink" href="#verifying-the-mock-da
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/f9008c109f59932f682849a7f95e164d74fd406a14f367463411e13b3d203b76.png" src="../_images/f9008c109f59932f682849a7f95e164d74fd406a14f367463411e13b3d203b76.png" />
<img alt="../_images/6d16ec3fe24070415928c2b71eb713e4de8375acfb26905f0dc8b145382ff6a6.png" src="../_images/6d16ec3fe24070415928c2b71eb713e4de8375acfb26905f0dc8b145382ff6a6.png" />
</div>
</div>
<p>We can even subtract this on a pixel-by-pixel basis and compare to the original image.</p>
Expand Down Expand Up @@ -905,7 +905,7 @@ <h2>Verifying the mock dataset<a class="headerlink" href="#verifying-the-mock-da
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/a2e07acf7de29551ff89e194020a37c2ce67ffa844b238eb4b97fe49734f07e9.png" src="../_images/a2e07acf7de29551ff89e194020a37c2ce67ffa844b238eb4b97fe49734f07e9.png" />
<img alt="../_images/49e2a14e74a4112723f9a755cf22d7aa09e6ea73b54438426d7fbcbbf9d446c4.png" src="../_images/49e2a14e74a4112723f9a755cf22d7aa09e6ea73b54438426d7fbcbbf9d446c4.png" />
</div>
</div>
<p>The subtraction revears some interesting artefacts.</p>
Expand Down
Loading

0 comments on commit 4ca5616

Please sign in to comment.