Skip to content

Commit

Permalink
deploy: 9819864
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Oct 1, 2024
1 parent 0244a18 commit a127041
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 12 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.
109 changes: 104 additions & 5 deletions _preview/1/_sources/notebooks/tutorials/polygon_area.ipynb

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions _preview/1/notebooks/foundations/coordinates.html
Original file line number Diff line number Diff line change
Expand Up @@ -1170,9 +1170,7 @@ <h3>United States Map<a class="headerlink" href="#united-states-map" title="Link
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/50m_cultural/ne_50m_admin_0_boundary_lines_land.zip
warnings.warn(f&#39;Downloading: {url}&#39;, DownloadWarning)
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/50m_cultural/ne_50m_admin_1_states_provinces_lakes.zip
/home/runner/miniconda3/envs/cookbook-dev/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/50m_cultural/ne_50m_admin_1_states_provinces_lakes.zip
warnings.warn(f&#39;Downloading: {url}&#39;, DownloadWarning)
</pre></div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions _preview/1/notebooks/notebook-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ <h5>of further and further<a class="headerlink" href="#of-further-and-further" t
<section id="header-levels">
<h6>header levels<a class="headerlink" href="#header-levels" title="Link to this heading"><i class="fas fa-link"></i></a></h6>
<p>as well <span class="math notranslate nohighlight">\(m = a * t / h\)</span> text! Similarly, you have access to other <span class="math notranslate nohighlight">\(\LaTeX\)</span> equation <a class="reference external" href="https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Typesetting%20Equations.html"><strong>functionality</strong></a> via MathJax (demo below from link),</p>
<div class="amsmath math notranslate nohighlight" id="equation-24439fdc-cf07-4efb-b1f3-8248771ddb1e">
<span class="eqno">()<a class="headerlink" href="#equation-24439fdc-cf07-4efb-b1f3-8248771ddb1e" title="Permalink to this equation"><i class="fas fa-link"></i></a></span>\[\begin{align}
<div class="amsmath math notranslate nohighlight" id="equation-697927ad-b1d7-4e0f-b4eb-6e45562e7f96">
<span class="eqno">()<a class="headerlink" href="#equation-697927ad-b1d7-4e0f-b4eb-6e45562e7f96" title="Permalink to this equation"><i class="fas fa-link"></i></a></span>\[\begin{align}
\dot{x} &amp; = \sigma(y-x) \\
\dot{y} &amp; = \rho x - y - xz \\
\dot{z} &amp; = -\beta z + xy
Expand Down
80 changes: 79 additions & 1 deletion _preview/1/notebooks/tutorials/polygon_area.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ <h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">
<li><p>Determine clockwise/counterclockwise ordering of points on spherical polygon</p></li>
<li><p>Area and Permieter of quadrilateral patch on a unit sphere</p></li>
<li><p>Determine if a given point is within a spherical polygon</p></li>
<li><p>Mean center of spherical polygon (TODO)</p></li>
<li><p>Center of spherical polygon</p></li>
</ol>
</section>
<section id="prerequisites">
Expand Down Expand Up @@ -903,6 +903,83 @@ <h2>Determine if a given point is within a spherical polygon<a class="headerlink
</div>
</div>
</section>
<section id="center-of-spherical-polygon">
<h2>Center of spherical polygon<a class="headerlink" href="#center-of-spherical-polygon" title="Link to this heading"><i class="fas fa-link"></i></a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">polygon_centroid</span><span class="p">(</span><span class="n">polygon_pts</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="n">longitudes</span> <span class="o">=</span> <span class="p">[</span><span class="n">location_df</span><span class="o">.</span><span class="n">loc</span><span class="p">[[</span><span class="n">x</span><span class="p">]][</span><span class="s2">&quot;longitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">polygon_pts</span><span class="p">]</span>
<span class="n">latitudes</span> <span class="o">=</span> <span class="p">[</span><span class="n">location_df</span><span class="o">.</span><span class="n">loc</span><span class="p">[[</span><span class="n">x</span><span class="p">]][</span><span class="s2">&quot;latitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">polygon_pts</span><span class="p">]</span>
<span class="n">lat_lon_coords</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">longitudes</span><span class="p">,</span> <span class="n">latitudes</span><span class="p">))</span>
<span class="n">polygon</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span><span class="n">lat_lon_coords</span><span class="p">)</span>
<span class="k">return</span> <span class="p">(</span><span class="n">polygon</span><span class="o">.</span><span class="n">centroid</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">polygon</span><span class="o">.</span><span class="n">centroid</span><span class="o">.</span><span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">polygon_centroid</span><span class="p">([</span><span class="s2">&quot;boulder&quot;</span><span class="p">,</span> <span class="s2">&quot;boston&quot;</span><span class="p">,</span> <span class="s2">&quot;houston&quot;</span><span class="p">])</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(37.30896666666666, -90.47586666666665)
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">plot_centroid</span><span class="p">(</span><span class="n">polygon_pts</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">lon_west</span><span class="o">=-</span><span class="mi">180</span><span class="p">,</span> <span class="n">lon_east</span><span class="o">=</span><span class="mi">180</span><span class="p">,</span>
<span class="n">lat_south</span><span class="o">=-</span><span class="mi">90</span><span class="p">,</span> <span class="n">lat_north</span><span class="o">=</span><span class="mi">90</span><span class="p">):</span>
<span class="c1"># Set up world map plot</span>
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span>
<span class="n">projection_map</span> <span class="o">=</span> <span class="n">ccrs</span><span class="o">.</span><span class="n">PlateCarree</span><span class="p">()</span>
<span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">axes</span><span class="p">(</span><span class="n">projection</span><span class="o">=</span><span class="n">projection_map</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">set_extent</span><span class="p">([</span><span class="n">lon_west</span><span class="p">,</span> <span class="n">lon_east</span><span class="p">,</span> <span class="n">lat_south</span><span class="p">,</span> <span class="n">lat_north</span><span class="p">],</span> <span class="n">crs</span><span class="o">=</span><span class="n">projection_map</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">coastlines</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">add_feature</span><span class="p">(</span><span class="n">cfeature</span><span class="o">.</span><span class="n">STATES</span><span class="p">,</span> <span class="n">edgecolor</span><span class="o">=</span><span class="s2">&quot;black&quot;</span><span class="p">)</span>

<span class="c1"># plot polygon points</span>
<span class="n">longitudes</span> <span class="o">=</span> <span class="p">[</span><span class="n">location_df</span><span class="o">.</span><span class="n">loc</span><span class="p">[[</span><span class="n">x</span><span class="p">]][</span><span class="s2">&quot;longitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">polygon_pts</span><span class="p">]</span> <span class="c1"># longitude</span>
<span class="n">latitudes</span> <span class="o">=</span> <span class="p">[</span><span class="n">location_df</span><span class="o">.</span><span class="n">loc</span><span class="p">[[</span><span class="n">x</span><span class="p">]][</span><span class="s2">&quot;latitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">polygon_pts</span><span class="p">]</span> <span class="c1"># latitude</span>
<span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">longitudes</span><span class="p">,</span> <span class="n">latitudes</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="mi">50</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="s2">&quot;blue&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="n">longitudes</span><span class="p">,</span> <span class="n">latitudes</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>

<span class="c1"># plot check point</span>
<span class="n">centeroid</span> <span class="o">=</span> <span class="n">polygon_centroid</span><span class="p">(</span><span class="n">polygon_pts</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">centeroid</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">centeroid</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="s2">&quot;red&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Centeroid = </span><span class="si">{</span><span class="n">centeroid</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">plot_centroid</span><span class="p">([</span><span class="s2">&quot;boulder&quot;</span><span class="p">,</span> <span class="s2">&quot;boston&quot;</span><span class="p">,</span> <span class="s2">&quot;houston&quot;</span><span class="p">],</span>
<span class="o">-</span><span class="mi">130</span><span class="p">,</span> <span class="o">-</span><span class="mi">60</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">60</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../../_images/5386a29f81785d97f253e312ab6d97b712d4b5c546b134d06f7730860504110e.png" src="../../_images/5386a29f81785d97f253e312ab6d97b712d4b5c546b134d06f7730860504110e.png" />
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">plot_centroid</span><span class="p">([</span><span class="s2">&quot;boulder&quot;</span><span class="p">,</span> <span class="s2">&quot;boston&quot;</span><span class="p">,</span> <span class="s2">&quot;cape canaveral&quot;</span><span class="p">,</span> <span class="s2">&quot;houston&quot;</span><span class="p">],</span>
<span class="o">-</span><span class="mi">130</span><span class="p">,</span> <span class="o">-</span><span class="mi">60</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">60</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../../_images/2587b5077de1e429d6e4a32cd38bb210200b891bca7e808f15849705ed157e76.png" src="../../_images/2587b5077de1e429d6e4a32cd38bb210200b891bca7e808f15849705ed157e76.png" />
</div>
</div>
</section>
<hr class="docutils" />
<section id="summary">
<h2>Summary<a class="headerlink" href="#summary" title="Link to this heading"><i class="fas fa-link"></i></a></h2>
Expand Down Expand Up @@ -985,6 +1062,7 @@ <h2>Resources and references<a class="headerlink" href="#resources-and-reference
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#determine-if-a-given-point-is-within-a-spherical-polygon">Determine if a given point is within a spherical polygon</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#center-of-spherical-polygon">Center of spherical polygon</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#summary">Summary</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#whats-next">What’s next?</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _preview/1/searchindex.js

Large diffs are not rendered by default.

0 comments on commit a127041

Please sign in to comment.