Skip to content

Commit

Permalink
deploy: fec654c
Browse files Browse the repository at this point in the history
  • Loading branch information
Huite committed Aug 8, 2024
1 parent 7b0d04d commit 6bb1f4a
Show file tree
Hide file tree
Showing 81 changed files with 359 additions and 351 deletions.
Binary file modified .doctrees/api.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.Ugrid2d.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.Ugrid2d.sel_points.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.UgridDataArrayAccessor.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.UgridDataArrayAccessor.sel_points.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.UgridDatasetAccessor.doctree
Binary file not shown.
Binary file modified .doctrees/api/xugrid.UgridDatasetAccessor.sel_points.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/examples-dev/sg_execution_times.doctree
Binary file not shown.
Binary file modified .doctrees/examples-dev/voronoi.doctree
Binary file not shown.
Binary file modified .doctrees/examples/connectivity.doctree
Binary file not shown.
Binary file modified .doctrees/examples/overlap_regridder.doctree
Binary file not shown.
Binary file modified .doctrees/examples/partitioning.doctree
Binary file not shown.
Binary file modified .doctrees/examples/plotting.doctree
Binary file not shown.
Binary file modified .doctrees/examples/quick_overview.doctree
Binary file not shown.
Binary file modified .doctrees/examples/regridder_overview.doctree
Binary file not shown.
Binary file modified .doctrees/examples/selection.doctree
Binary file not shown.
Binary file modified .doctrees/examples/sg_execution_times.doctree
Binary file not shown.
Binary file modified .doctrees/examples/vector_conversion.doctree
Binary file not shown.
Binary file modified .doctrees/sample_data/adh_san_diego.doctree
Binary file not shown.
Binary file modified .doctrees/sample_data/disk.doctree
Binary file not shown.
Binary file modified .doctrees/sample_data/elevation_nl.doctree
Binary file not shown.
Binary file modified .doctrees/sample_data/sg_execution_times.doctree
Binary file not shown.
Binary file modified .doctrees/sg_execution_times.doctree
Binary file not shown.
Binary file modified _downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip
Binary file not shown.
Binary file modified _downloads/2dbba5ebb6d2057d196983a008981162/voronoi.zip
Binary file not shown.
Binary file not shown.
Binary file modified _downloads/3e8af3e56da80727f8440a5b5f94f5cb/disk.zip
Binary file not shown.
Binary file modified _downloads/3eb350a8b54f214b88c5181e546a155e/adh_san_diego.zip
Binary file not shown.
Binary file modified _downloads/422003fc9b51482872f8f3701ce47abe/provinces_nl.zip
Binary file not shown.
Binary file modified _downloads/43d7b47db560c8c70c383a84a444ed83/connectivity.zip
Binary file not shown.
Binary file not shown.
Binary file modified _downloads/97eabe2c66fc9328b1e51f27fdee52f6/partitioning.zip
Binary file not shown.
Binary file modified _downloads/9be12df0ec6c323839ed0cb99cc89228/elevation_nl.zip
Binary file not shown.
Binary file modified _downloads/a50ba9731493d1c74010dcadb8694b20/selection.zip
Binary file not shown.
Binary file modified _downloads/cc393383c363f7c590c6ef714836f52a/xoxo.zip
Binary file not shown.
Binary file modified _downloads/d2379110fee2f2fbaf724f0142daaa8d/plotting.zip
Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions _modules/xugrid/core/dataarray_accessor.html
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
<h1>Source code for xugrid.core.dataarray_accessor</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Union</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">scipy.sparse</span>
<span class="kn">import</span> <span class="nn">xarray</span> <span class="k">as</span> <span class="nn">xr</span>

Expand Down Expand Up @@ -597,7 +598,7 @@ <h1>Source code for xugrid.core.dataarray_accessor</h1><div class="highlight"><p

<div class="viewcode-block" id="UgridDataArrayAccessor.sel_points">
<a class="viewcode-back" href="../../../api/xugrid.UgridDataArrayAccessor.sel_points.html#xugrid.UgridDataArrayAccessor.sel_points">[docs]</a>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span><span class="bp">self</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">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span><span class="bp">self</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">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="n">fill_value</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Select points in the unstructured grid.</span>

Expand All @@ -608,21 +609,23 @@ <h1>Source code for xugrid.core.dataarray_accessor</h1><div class="highlight"><p
<span class="sd"> ----------</span>
<span class="sd"> x: ndarray of floats with shape ``(n_points,)``</span>
<span class="sd"> y: ndarray of floats with shape ``(n_points,)``</span>

<span class="sd"> out_of_bounds: str, default &quot;warn&quot;</span>
<span class="sd"> out_of_bounds: str, default: &quot;warn&quot;</span>
<span class="sd"> What to do when points are located outside of any feature:</span>

<span class="sd"> * raise: raise a ValueError.</span>
<span class="sd"> * ignore: return NaN for the out of bounds points.</span>
<span class="sd"> * ignore: return ``fill_value`` for the out of bounds points.</span>
<span class="sd"> * warn: give a warning and return NaN for the out of bounds points.</span>
<span class="sd"> * drop: drop the out of bounds points. They may be identified</span>
<span class="sd"> via the ``index`` coordinate of the returned selection.</span>
<span class="sd"> fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan</span>
<span class="sd"> Value to assign to out-of-bounds points if out_of_bounds is warn</span>
<span class="sd"> or ignore. Forwarded to xarray&#39;s ``.where()`` method.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> points: Union[xr.DataArray, xr.Dataset]</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">sel_points</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</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">out_of_bounds</span><span class="p">)</span></div>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid</span><span class="o">.</span><span class="n">sel_points</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">obj</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">out_of_bounds</span><span class="p">,</span> <span class="n">fill_value</span><span class="p">)</span></div>


<div class="viewcode-block" id="UgridDataArrayAccessor.rasterize">
Expand Down
10 changes: 6 additions & 4 deletions _modules/xugrid/core/dataset_accessor.html
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ <h1>Source code for xugrid.core.dataset_accessor</h1><div class="highlight"><pre

<div class="viewcode-block" id="UgridDatasetAccessor.sel_points">
<a class="viewcode-back" href="../../../api/xugrid.UgridDatasetAccessor.sel_points.html#xugrid.UgridDatasetAccessor.sel_points">[docs]</a>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span><span class="bp">self</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">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span><span class="bp">self</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">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="n">fill_value</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Select points in the unstructured grid.</span>

Expand All @@ -662,15 +662,17 @@ <h1>Source code for xugrid.core.dataset_accessor</h1><div class="highlight"><pre
<span class="sd"> ----------</span>
<span class="sd"> x: ndarray of floats with shape ``(n_points,)``</span>
<span class="sd"> y: ndarray of floats with shape ``(n_points,)``</span>

<span class="sd"> out_of_bounds: str, default ``&quot;warn&quot;``</span>
<span class="sd"> What to do when points are located outside of any feature:</span>

<span class="sd"> * raise: raise a ValueError.</span>
<span class="sd"> * ignore: return NaN for the out of bounds points.</span>
<span class="sd"> * ignore: return ``fill_value`` for the out of bounds points.</span>
<span class="sd"> * warn: give a warning and return NaN for the out of bounds points.</span>
<span class="sd"> * drop: drop the out of bounds points. They may be identified</span>
<span class="sd"> via the ``index`` coordinate of the returned selection.</span>
<span class="sd"> fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan</span>
<span class="sd"> Value to assign to out-of-bounds points if out_of_bounds is warn</span>
<span class="sd"> or ignore. Forwarded to xarray&#39;s ``.where()`` method.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
Expand All @@ -679,7 +681,7 @@ <h1>Source code for xugrid.core.dataset_accessor</h1><div class="highlight"><pre
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">obj</span>
<span class="k">for</span> <span class="n">grid</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">grids</span><span class="p">:</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">grid</span><span class="o">.</span><span class="n">sel_points</span><span class="p">(</span><span class="n">result</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">out_of_bounds</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">grid</span><span class="o">.</span><span class="n">sel_points</span><span class="p">(</span><span class="n">result</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">out_of_bounds</span><span class="p">,</span> <span class="n">fill_value</span><span class="p">)</span>
<span class="k">return</span> <span class="n">result</span></div>


Expand Down
29 changes: 13 additions & 16 deletions _modules/xugrid/ugrid/ugrid2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,9 @@ <h1>Source code for xugrid.ugrid.ugrid2d</h1><div class="highlight"><pre>

<div class="viewcode-block" id="Ugrid2d.sel_points">
<a class="viewcode-back" href="../../../api/xugrid.Ugrid2d.sel_points.html#xugrid.Ugrid2d.sel_points">[docs]</a>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="n">FloatArray</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">FloatArray</span><span class="p">,</span> <span class="n">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">sel_points</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">,</span> <span class="n">x</span><span class="p">:</span> <span class="n">FloatArray</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">FloatArray</span><span class="p">,</span> <span class="n">out_of_bounds</span><span class="o">=</span><span class="s2">&quot;warn&quot;</span><span class="p">,</span> <span class="n">fill_value</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Select points in the unstructured grid.</span>

Expand All @@ -1750,10 +1752,13 @@ <h1>Source code for xugrid.ugrid.ugrid2d</h1><div class="highlight"><pre>
<span class="sd"> What to do when points are located outside of any feature:</span>

<span class="sd"> * raise: raise a ValueError.</span>
<span class="sd"> * ignore: return NaN for the out of bounds points.</span>
<span class="sd"> * ignore: return ``fill_value`` for the out of bounds points.</span>
<span class="sd"> * warn: give a warning and return NaN for the out of bounds points.</span>
<span class="sd"> * drop: drop the out of bounds points. They may be identified</span>
<span class="sd"> via the ``index`` coordinate of the returned selection.</span>
<span class="sd"> fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan</span>
<span class="sd"> Value to assign to out-of-bounds points if out_of_bounds is warn</span>
<span class="sd"> or ignore. Forwarded to xarray&#39;s ``.where()`` method.</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
Expand All @@ -1778,8 +1783,8 @@ <h1>Source code for xugrid.ugrid.ugrid2d</h1><div class="highlight"><pre>
<span class="n">xy</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">column_stack</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">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_points</span><span class="p">(</span><span class="n">xy</span><span class="p">)</span>

<span class="n">multiplier</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">keep</span> <span class="o">=</span> <span class="nb">slice</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="c1"># keep all by default</span>
<span class="n">condition</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">valid</span> <span class="o">=</span> <span class="n">index</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">valid</span><span class="o">.</span><span class="n">all</span><span class="p">():</span>
<span class="k">if</span> <span class="n">out_of_bounds</span> <span class="o">==</span> <span class="s2">&quot;raise&quot;</span><span class="p">:</span>
Expand All @@ -1790,33 +1795,25 @@ <h1>Source code for xugrid.ugrid.ugrid2d</h1><div class="highlight"><pre>
<span class="s2">&quot;Not all points are located inside of the grid. &quot;</span>
<span class="s2">&quot;Out of bounds points are marked by NaN.&quot;</span>
<span class="p">)</span>

<span class="c1"># Mask the out_of_bounds points with NaN (they will be indexed</span>
<span class="c1"># with -1). Multiply valid values by 1.0, multiply outside</span>
<span class="c1"># values by NaN. Note that multiplying a dask array with a</span>
<span class="c1"># numpy array will result a dask array, so this doesn&#39;t break</span>
<span class="c1"># lazy evaluation.</span>
<span class="n">multiplier</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">DataArray</span><span class="p">(</span>
<span class="n">data</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">valid</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">),</span> <span class="n">dims</span><span class="o">=</span><span class="p">(</span><span class="n">dim</span><span class="p">,)</span>
<span class="p">)</span>

<span class="n">condition</span> <span class="o">=</span> <span class="n">xr</span><span class="o">.</span><span class="n">DataArray</span><span class="p">(</span><span class="n">valid</span><span class="p">,</span> <span class="n">dims</span><span class="o">=</span><span class="p">(</span><span class="n">dim</span><span class="p">,))</span>
<span class="k">elif</span> <span class="n">out_of_bounds</span> <span class="o">==</span> <span class="s2">&quot;drop&quot;</span><span class="p">:</span>
<span class="n">index</span> <span class="o">=</span> <span class="n">index</span><span class="p">[</span><span class="n">valid</span><span class="p">]</span>
<span class="n">keep</span> <span class="o">=</span> <span class="n">valid</span>

<span class="k">else</span><span class="p">:</span>
<span class="c1"># This code shouldn&#39;t be reachable due to check up top.</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;invalid out_of_bounds options&quot;</span><span class="p">)</span>

<span class="c1"># Create the selection DataArray or Dataset</span>
<span class="n">coords</span> <span class="o">=</span> <span class="p">{</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">_index&quot;</span><span class="p">:</span> <span class="p">(</span><span class="n">dim</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">xy</span><span class="p">))[</span><span class="n">keep</span><span class="p">]),</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">_x&quot;</span><span class="p">:</span> <span class="p">(</span><span class="n">dim</span><span class="p">,</span> <span class="n">xy</span><span class="p">[</span><span class="n">keep</span><span class="p">,</span> <span class="mi">0</span><span class="p">]),</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">_y&quot;</span><span class="p">:</span> <span class="p">(</span><span class="n">dim</span><span class="p">,</span> <span class="n">xy</span><span class="p">[</span><span class="n">keep</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span>
<span class="p">}</span>
<span class="n">selection</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="n">isel</span><span class="p">({</span><span class="n">dim</span><span class="p">:</span> <span class="n">index</span><span class="p">})</span><span class="o">.</span><span class="n">assign_coords</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
<span class="k">if</span> <span class="n">multiplier</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">selection</span> <span class="o">=</span> <span class="n">selection</span> <span class="o">*</span> <span class="n">multiplier</span>

<span class="c1"># Set values to fill_value for out-of-bounds</span>
<span class="k">if</span> <span class="n">condition</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">selection</span> <span class="o">=</span> <span class="n">selection</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">other</span><span class="o">=</span><span class="n">fill_value</span><span class="p">)</span>
<span class="k">return</span> <span class="n">selection</span></div>


Expand Down
4 changes: 2 additions & 2 deletions _sources/examples-dev/sg_execution_times.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Computation times
=================
**00:01.180** total execution time for 1 file **from examples-dev**:
**00:01.150** total execution time for 1 file **from examples-dev**:

.. container::

Expand All @@ -33,5 +33,5 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_examples-dev_voronoi.py` (``voronoi.py``)
- 00:01.180
- 00:01.150
- 0.0
2 changes: 1 addition & 1 deletion _sources/examples-dev/voronoi.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ The figure shows:
.. rst-class:: sphx-glr-timing

**Total running time of the script:** (0 minutes 1.180 seconds)
**Total running time of the script:** (0 minutes 1.150 seconds)


.. _sphx_glr_download_examples-dev_voronoi.py:
Expand Down
Loading

0 comments on commit 6bb1f4a

Please sign in to comment.