diff --git a/.doctrees/api/xugrid.OverlapRegridder.doctree b/.doctrees/api/xugrid.OverlapRegridder.doctree index fc4b2032b..65f691893 100644 Binary files a/.doctrees/api/xugrid.OverlapRegridder.doctree and b/.doctrees/api/xugrid.OverlapRegridder.doctree differ diff --git a/.doctrees/changelog.doctree b/.doctrees/changelog.doctree index 0511b4cee..efadfa090 100644 Binary files a/.doctrees/changelog.doctree and b/.doctrees/changelog.doctree differ diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index b6ef220c2..458f11e75 100644 Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ diff --git a/.doctrees/examples-dev/sg_execution_times.doctree b/.doctrees/examples-dev/sg_execution_times.doctree index 1f7c904cb..30a21d9c9 100644 Binary files a/.doctrees/examples-dev/sg_execution_times.doctree and b/.doctrees/examples-dev/sg_execution_times.doctree differ diff --git a/.doctrees/examples-dev/voronoi.doctree b/.doctrees/examples-dev/voronoi.doctree index 820a810a9..6643c0c73 100644 Binary files a/.doctrees/examples-dev/voronoi.doctree and b/.doctrees/examples-dev/voronoi.doctree differ diff --git a/.doctrees/examples/connectivity.doctree b/.doctrees/examples/connectivity.doctree index 96475083c..044e3e026 100644 Binary files a/.doctrees/examples/connectivity.doctree and b/.doctrees/examples/connectivity.doctree differ diff --git a/.doctrees/examples/overlap_regridder.doctree b/.doctrees/examples/overlap_regridder.doctree index d65f6f80c..9ec0f4d70 100644 Binary files a/.doctrees/examples/overlap_regridder.doctree and b/.doctrees/examples/overlap_regridder.doctree differ diff --git a/.doctrees/examples/partitioning.doctree b/.doctrees/examples/partitioning.doctree index 92b204787..76dfd2481 100644 Binary files a/.doctrees/examples/partitioning.doctree and b/.doctrees/examples/partitioning.doctree differ diff --git a/.doctrees/examples/plotting.doctree b/.doctrees/examples/plotting.doctree index 131a79065..ae3167e6c 100644 Binary files a/.doctrees/examples/plotting.doctree and b/.doctrees/examples/plotting.doctree differ diff --git a/.doctrees/examples/quick_overview.doctree b/.doctrees/examples/quick_overview.doctree index 0a4ea777c..52efad864 100644 Binary files a/.doctrees/examples/quick_overview.doctree and b/.doctrees/examples/quick_overview.doctree differ diff --git a/.doctrees/examples/regridder_overview.doctree b/.doctrees/examples/regridder_overview.doctree index 07734613b..c98a1d5d4 100644 Binary files a/.doctrees/examples/regridder_overview.doctree and b/.doctrees/examples/regridder_overview.doctree differ diff --git a/.doctrees/examples/selection.doctree b/.doctrees/examples/selection.doctree index 53243925e..f6bfb40a9 100644 Binary files a/.doctrees/examples/selection.doctree and b/.doctrees/examples/selection.doctree differ diff --git a/.doctrees/examples/sg_execution_times.doctree b/.doctrees/examples/sg_execution_times.doctree index ce8173f9b..2e0b2589c 100644 Binary files a/.doctrees/examples/sg_execution_times.doctree and b/.doctrees/examples/sg_execution_times.doctree differ diff --git a/.doctrees/examples/vector_conversion.doctree b/.doctrees/examples/vector_conversion.doctree index 9a1dfdf8b..4fe3a5525 100644 Binary files a/.doctrees/examples/vector_conversion.doctree and b/.doctrees/examples/vector_conversion.doctree differ diff --git a/.doctrees/sample_data/adh_san_diego.doctree b/.doctrees/sample_data/adh_san_diego.doctree index 79b947ace..985bbc890 100644 Binary files a/.doctrees/sample_data/adh_san_diego.doctree and b/.doctrees/sample_data/adh_san_diego.doctree differ diff --git a/.doctrees/sample_data/disk.doctree b/.doctrees/sample_data/disk.doctree index 5e64cf914..d41e1bd4f 100644 Binary files a/.doctrees/sample_data/disk.doctree and b/.doctrees/sample_data/disk.doctree differ diff --git a/.doctrees/sample_data/elevation_nl.doctree b/.doctrees/sample_data/elevation_nl.doctree index 090368cb3..e38562737 100644 Binary files a/.doctrees/sample_data/elevation_nl.doctree and b/.doctrees/sample_data/elevation_nl.doctree differ diff --git a/.doctrees/sample_data/provinces_nl.doctree b/.doctrees/sample_data/provinces_nl.doctree index 13a4f5068..5104bc118 100644 Binary files a/.doctrees/sample_data/provinces_nl.doctree and b/.doctrees/sample_data/provinces_nl.doctree differ diff --git a/.doctrees/sample_data/sg_execution_times.doctree b/.doctrees/sample_data/sg_execution_times.doctree index f163d4340..bca87e956 100644 Binary files a/.doctrees/sample_data/sg_execution_times.doctree and b/.doctrees/sample_data/sg_execution_times.doctree differ diff --git a/.doctrees/sg_execution_times.doctree b/.doctrees/sg_execution_times.doctree index 2b4fe9db5..b72ef06f7 100644 Binary files a/.doctrees/sg_execution_times.doctree and b/.doctrees/sg_execution_times.doctree differ diff --git a/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip b/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip index 6ec8373cf..0119ce4a4 100644 Binary files a/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip and b/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip differ diff --git a/_downloads/2113e51a6a17a0230a513258e99cc8d1/overlap_regridder.ipynb b/_downloads/2113e51a6a17a0230a513258e99cc8d1/overlap_regridder.ipynb index 6551ec2e5..588f87794 100644 --- a/_downloads/2113e51a6a17a0230a513258e99cc8d1/overlap_regridder.ipynb +++ b/_downloads/2113e51a6a17a0230a513258e99cc8d1/overlap_regridder.ipynb @@ -87,7 +87,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Custom reductions\n\nIt's also possible to define your own reduction methods. Such a method is\ninserted during the ``.regrid`` call and compiled by `Numba`_ for performance.\n\nA valid reduction method must be compileable by Numba, and takes exactly three\narguments: ``values``, ``indices``, ``weights``.\n\n* ``values``: is the array containing the (float) source values.\n* ``weights``: contains the (float) overlap between the target face and the\n source faces. The size of ``weights`` is equal to the size of ``indices``.\n* ``work``: used as a temporary workspace. Contains one float value for each\n index in indices.\n\nXugrid regridder reduction functions are implemented in such a way. For a\nexample, an area weighted sum could be implemented as follows:\n\n" + "## Custom reductions\n\nIt's also possible to define your own reduction methods. Such a method is\ninserted during the ``.regrid`` call and compiled by `Numba`_ for performance.\n\nA valid reduction method must be compileable by Numba, and takes exactly three\narguments: ``values``, ``indices``, ``weights``.\n\n* ``values``: is the array containing the (float) source values.\n* ``weights``: contains the (float) overlap between the target face and the\n source faces. The size of ``weights`` is equal to the size of ``values``.\n* ``work``: used as a temporary workspace of floats. The size of ``work`` is\n equal to the size of ``values``.\n\nXugrid regridder reduction functions are implemented in such a way. For a\nexample, an area weighted sum could be implemented as follows:\n\n" ] }, { @@ -98,14 +98,14 @@ }, "outputs": [], "source": [ - "def mean(values, weights, workspace):\n total = 0.0\n weight_sum = 0.0\n for value, weight in zip(values, weights):\n if ~np.isnan(value):\n total = +value * weight\n weight_sum += weight\n if weight_sum == 0.0:\n return np.nan\n return total / weight_sum" + "def mean(values, weights, workspace):\n total = 0.0\n weight_sum = 0.0\n for value, weight in zip(values, weights):\n if ~np.isnan(value):\n total += value * weight\n weight_sum += weight\n if weight_sum == 0.0:\n return np.nan\n return total / weight_sum" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "
* Each reduction must return a single float.\n * Custom reductions methods must be able to deal with NaN values as these\n are commonly encountered in datasets as a \"no data value\".\n * If Python features are used that are unsupported by Numba, you will get\n somewhat obscure errors. In such a case, test your function with\n synthetic values for ``values, weights, workspace``.\n * The ``workspace`` array is provided to avoid dynamic memory allocations.\n It is a an array of floats with the same size as ``values`` or\n ``weights``. You may freely allocate new arrays within the reduction\n function but it will impact performance.\n * While we could have implemented a weighted mean as:\n ``np.nansum(values * weights) / np.nansum(weights)``, the function above\n is efficiently compiled by Numba and does not allocate.
* Each reduction must return a single float.\n * Always check for ``np.isnan(value)``: Custom reductions methods must be\n able to deal with NaN values as these are commonly encountered in datasets\n as a \"no data value\".\n * If Python features are used that are unsupported by Numba, you will get\n somewhat obscure errors. In such a case, ``numba.njit`` and test your\n function separately with synthetic values for ``values, weights,\n workspace``.\n * The ``workspace`` array is provided to avoid dynamic memory allocations.\n It is a an array of floats with the same size as ``values`` or\n ``weights``. You may freely allocate new arrays within the reduction\n function but it will impact performance. (Methods such as mode or median\n require a workspace.)\n * While we could have implemented a weighted mean as:\n ``np.nansum(values * weights) / np.nansum(weights)``, the function above\n is efficiently compiled by Numba and does not allocate temporary arrays.
if len(indices) > 0:
out[extra_index, target_index] = f(
- values, weights, workspace[extra_index, 1, :]
+ values, weights, workspace[extra_index, 1, :n_value]
)
return out
@@ -858,6 +858,7 @@ Source code for xugrid.regrid.regridder
Any percentile method can be created via:
``method = OverlapRegridder.create_percentile_methode(percentile)``
+ See the examples.
Parameters
----------
@@ -865,6 +866,13 @@ Source code for xugrid.regrid.regridder
target: Ugrid2d, UgridDataArray
method: str, function, optional
Default value is ``"mean"``.
+
+ Examples
+ --------
+ Setup a custom percentile method and apply it:
+
+ >>> p33_3 = OverlapRegridder.create_percentile_method(33.3)
+ >>> regridder = OverlapRegridder(source, target, method=p33_3)
"""
_JIT_FUNCTIONS = {
diff --git a/_sources/changelog.rst.txt b/_sources/changelog.rst.txt
index a23722067..76d87ef02 100644
--- a/_sources/changelog.rst.txt
+++ b/_sources/changelog.rst.txt
@@ -6,6 +6,31 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_, and this project adheres to
`Semantic Versioning`_.
+Unreleased
+----------
+
+Fixed
+~~~~~
+
+- The reduction methods for the overlap regridders now behave consistently when
+ all values are NaN or when all weights (overlaps) are zero, and all methods
+ give the same answer irrespective of the order in which the values are
+ encountered.
+
+Added
+~~~~~
+
+- Percentiles (5, 10, 25, 50, 75, 90, 95) have been added to the
+ :class:`xugrid.OverlapRegridder` as standard available reduction methods
+ (available as ``"p5", "p10"``, etc.). Custom percentile values (e.g. 2.5, 42) can be
+ setup using :meth:`xugrid.OverlapRegridder.create_percentile_method`.
+
+Changed
+~~~~~~~
+
+- Custom reduction functions provide to the overlap regridders no longer require
+ an ``indices`` argument.
+
[0.11.0] 2024-08-05
-------------------
diff --git a/_sources/examples-dev/sg_execution_times.rst.txt b/_sources/examples-dev/sg_execution_times.rst.txt
index e642045f0..0a37efefd 100644
--- a/_sources/examples-dev/sg_execution_times.rst.txt
+++ b/_sources/examples-dev/sg_execution_times.rst.txt
@@ -6,7 +6,7 @@
Computation times
=================
-**00:01.160** total execution time for 1 file **from examples-dev**:
+**00:01.146** total execution time for 1 file **from examples-dev**:
.. container::
@@ -33,5 +33,5 @@ Computation times
- Time
- Mem (MB)
* - :ref:`sphx_glr_examples-dev_voronoi.py` (``voronoi.py``)
- - 00:01.160
+ - 00:01.146
- 0.0
diff --git a/_sources/examples-dev/voronoi.rst.txt b/_sources/examples-dev/voronoi.rst.txt
index 12782ee2f..768e0c672 100644
--- a/_sources/examples-dev/voronoi.rst.txt
+++ b/_sources/examples-dev/voronoi.rst.txt
@@ -630,7 +630,7 @@ The figure shows:
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** (0 minutes 1.160 seconds)
+ **Total running time of the script:** (0 minutes 1.146 seconds)
.. _sphx_glr_download_examples-dev_voronoi.py:
diff --git a/_sources/examples/connectivity.rst.txt b/_sources/examples/connectivity.rst.txt
index 6d8bbaa72..3fba5cb25 100644
--- a/_sources/examples/connectivity.rst.txt
+++ b/_sources/examples/connectivity.rst.txt
@@ -129,7 +129,7 @@ By default, the border value for binary erosion is set to ``False`` (equal to
.. code-block:: none
-
+
@@ -165,7 +165,7 @@ start by setting a single value in the center of the grid to ``True``.
.. code-block:: none
-
+
@@ -200,7 +200,7 @@ alternative border value:
.. code-block:: none
-
+
@@ -238,7 +238,7 @@ analyse connected parts of the mesh.
.. code-block:: none
-
+
@@ -272,7 +272,7 @@ Tesselation.
.. code-block:: none
-
+
@@ -316,7 +316,7 @@ the original.
.. code-block:: none
-
+
@@ -355,7 +355,7 @@ We can break down one of the Voronoi tesselations from above into triangles:
.. code-block:: none
-
+
@@ -409,7 +409,7 @@ the upper and lower parts:
.. code-block:: none
-
+
@@ -439,7 +439,7 @@ We can now use Laplace interpolation to fill the gaps in the grid.
.. code-block:: none
-
+
@@ -477,7 +477,7 @@ interpolation.
.. code-block:: none
-
+
@@ -518,7 +518,7 @@ To illustrate, let's take a look at the connectivity matrix of the Xoxo grid.
.. code-block:: none
-
+
@@ -554,14 +554,14 @@ locality:
.. code-block:: none
-
+
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** (0 minutes 1.388 seconds)
+ **Total running time of the script:** (0 minutes 1.403 seconds)
.. _sphx_glr_download_examples_connectivity.py:
diff --git a/_sources/examples/overlap_regridder.rst.txt b/_sources/examples/overlap_regridder.rst.txt
index 3f47aa4fe..5f8596322 100644
--- a/_sources/examples/overlap_regridder.rst.txt
+++ b/_sources/examples/overlap_regridder.rst.txt
@@ -112,7 +112,7 @@ some bathymetry) of the Netherlands, and a coarser target grid.
.. code-block:: none
-
+
@@ -202,7 +202,7 @@ conservative methods, such as conductance:
.. code-block:: none
-
+
@@ -219,9 +219,9 @@ arguments: ``values``, ``indices``, ``weights``.
* ``values``: is the array containing the (float) source values.
* ``weights``: contains the (float) overlap between the target face and the
- source faces. The size of ``weights`` is equal to the size of ``indices``.
-* ``work``: used as a temporary workspace. Contains one float value for each
- index in indices.
+ source faces. The size of ``weights`` is equal to the size of ``values``.
+* ``work``: used as a temporary workspace of floats. The size of ``work`` is
+ equal to the size of ``values``.
Xugrid regridder reduction functions are implemented in such a way. For a
example, an area weighted sum could be implemented as follows:
@@ -237,7 +237,7 @@ example, an area weighted sum could be implemented as follows:
weight_sum = 0.0
for value, weight in zip(values, weights):
if ~np.isnan(value):
- total = +value * weight
+ total += value * weight
weight_sum += weight
if weight_sum == 0.0:
return np.nan
@@ -251,26 +251,30 @@ example, an area weighted sum could be implemented as follows:
-.. GENERATED FROM PYTHON SOURCE LINES 137-153
+.. GENERATED FROM PYTHON SOURCE LINES 137-157
.. note::
* Each reduction must return a single float.
- * Custom reductions methods must be able to deal with NaN values as these
- are commonly encountered in datasets as a "no data value".
+ * Always check for ``np.isnan(value)``: Custom reductions methods must be
+ able to deal with NaN values as these are commonly encountered in datasets
+ as a "no data value".
* If Python features are used that are unsupported by Numba, you will get
- somewhat obscure errors. In such a case, test your function with
- synthetic values for ``values, weights, workspace``.
+ somewhat obscure errors. In such a case, ``numba.njit`` and test your
+ function separately with synthetic values for ``values, weights,
+ workspace``.
* The ``workspace`` array is provided to avoid dynamic memory allocations.
It is a an array of floats with the same size as ``values`` or
``weights``. You may freely allocate new arrays within the reduction
- function but it will impact performance.
+ function but it will impact performance. (Methods such as mode or median
+ require a workspace.)
* While we could have implemented a weighted mean as:
``np.nansum(values * weights) / np.nansum(weights)``, the function above
- is efficiently compiled by Numba and does not allocate.
+ is efficiently compiled by Numba and does not allocate temporary arrays.
-To use our custom method, we provide at initialization of the OverlapRegridder:
+To use our custom method, we provide it at initialization of the
+OverlapRegridder:
-.. GENERATED FROM PYTHON SOURCE LINES 153-158
+.. GENERATED FROM PYTHON SOURCE LINES 157-162
.. code-block:: Python
@@ -293,16 +297,16 @@ To use our custom method, we provide at initialization of the OverlapRegridder:
.. code-block:: none
-
+
-.. GENERATED FROM PYTHON SOURCE LINES 159-161
+.. GENERATED FROM PYTHON SOURCE LINES 163-165
Not every reduction uses the ``weights`` and ``workspace`` arguments. For
-example, a regular sum:
+example, a regular sum could only look at the values:
-.. GENERATED FROM PYTHON SOURCE LINES 161-167
+.. GENERATED FROM PYTHON SOURCE LINES 165-171
.. code-block:: Python
@@ -319,9 +323,7 @@ example, a regular sum:
-.. GENERATED FROM PYTHON SOURCE LINES 168-175
-
-Always ensure that the function can deal with NaN values!
+.. GENERATED FROM PYTHON SOURCE LINES 172-177
Custom percentiles
------------------
@@ -329,7 +331,7 @@ Custom percentiles
Xugrid provides a number of predefined percentiles (5, 10, 25, 50, 75, 90,
95). In case you need a different percentile value, you can use this utility:
-.. GENERATED FROM PYTHON SOURCE LINES 175-178
+.. GENERATED FROM PYTHON SOURCE LINES 177-180
.. code-block:: Python
@@ -343,11 +345,11 @@ Xugrid provides a number of predefined percentiles (5, 10, 25, 50, 75, 90,
-.. GENERATED FROM PYTHON SOURCE LINES 179-180
+.. GENERATED FROM PYTHON SOURCE LINES 181-182
Then, provide it as the regridder method as above:
-.. GENERATED FROM PYTHON SOURCE LINES 180-185
+.. GENERATED FROM PYTHON SOURCE LINES 182-187
.. code-block:: Python
@@ -370,18 +372,18 @@ Then, provide it as the regridder method as above:
.. code-block:: none
-
+
-.. GENERATED FROM PYTHON SOURCE LINES 186-187
+.. GENERATED FROM PYTHON SOURCE LINES 188-189
.. _Numba: https://numba.pydata.org/
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** (0 minutes 4.007 seconds)
+ **Total running time of the script:** (0 minutes 4.019 seconds)
.. _sphx_glr_download_examples_overlap_regridder.py:
diff --git a/_sources/examples/partitioning.rst.txt b/_sources/examples/partitioning.rst.txt
index 38be65a50..6d938d179 100644
--- a/_sources/examples/partitioning.rst.txt
+++ b/_sources/examples/partitioning.rst.txt
@@ -76,7 +76,7 @@ into several parts.
.. code-block:: none
-
+
@@ -145,7 +145,7 @@ We can easily plot this data to visualize the partitions:
.. code-block:: none
-
+
@@ -213,7 +213,7 @@ merge these partitions back into one whole for post-processing:
.. code-block:: none
-
+
@@ -275,7 +275,7 @@ data:
.. code-block:: none
-
+
@@ -667,7 +667,7 @@ Note that partioning and merging does not preserve order!
<xarray.DataArray 'elevation' (mesh2d_nFaces: 5248)> Size: 5kB
array([False, False, False, ..., False, False, False])
Coordinates:
- * mesh2d_nFaces (mesh2d_nFaces) int64 42kB 0 1 2 3 4 ... 5244 5245 5246 5247
+ * mesh2d_nFaces (mesh2d_nFaces) int64 42kB 0 1 2 3 4 ... 5244 5245 5246 5247
<xarray.Dataset> Size: 19kB Dimensions: (mesh2d_nNodes: 217, mesh2d_nFaces: 384, mesh2d_nEdges: 600) Coordinates: - * mesh2d_nEdges (mesh2d_nEdges) int64 5kB 0 1 2 3 4 5 ... 595 596 597 598 599 - * mesh2d_nNodes (mesh2d_nNodes) int64 2kB 0 1 2 3 4 5 ... 212 213 214 215 216 * mesh2d_nFaces (mesh2d_nFaces) int64 3kB 0 1 2 3 4 5 ... 379 380 381 382 383 + * mesh2d_nNodes (mesh2d_nNodes) int64 2kB 0 1 2 3 4 5 ... 212 213 214 215 216 + * mesh2d_nEdges (mesh2d_nEdges) int64 5kB 0 1 2 3 4 5 ... 595 596 597 598 599 Data variables: node_z (mesh2d_nNodes) float64 2kB 1.933 2.091 1.875 ... 5.688 7.491 face_z (mesh2d_nFaces) float64 3kB 1.737 1.918 2.269 ... 5.408 6.424 - edge_z (mesh2d_nEdges) float64 5kB 1.989 1.875 1.8 ... 4.909 6.544
PandasIndex(RangeIndex(start=0, stop=384, step=1, name='mesh2d_nFaces'))
PandasIndex(RangeIndex(start=0, stop=217, step=1, name='mesh2d_nNodes'))
PandasIndex(RangeIndex(start=0, stop=600, step=1, name='mesh2d_nEdges'))
<xarray.DataArray (mesh2d_nFaces: 2)> Size: 16B array([1., 2.]) Coordinates: - * mesh2d_nFaces (mesh2d_nFaces) int64 16B 0 1+ * mesh2d_nFaces (mesh2d_nFaces) int64 16B 0 1
<xarray.DataArray (mesh2d_nFaces: 2)> Size: 16B array([11., 12.]) Coordinates: - * mesh2d_nFaces (mesh2d_nFaces) int64 16B 0 1+ * mesh2d_nFaces (mesh2d_nFaces) int64 16B 0 1
<xarray.Dataset> Size: 19kB Dimensions: (mesh2d_nNodes: 217, mesh2d_nFaces: 384, mesh2d_nEdges: 600) Coordinates: - * mesh2d_nEdges (mesh2d_nEdges) int64 5kB 0 1 2 3 4 5 ... 595 596 597 598 599 - * mesh2d_nNodes (mesh2d_nNodes) int64 2kB 0 1 2 3 4 5 ... 212 213 214 215 216 * mesh2d_nFaces (mesh2d_nFaces) int64 3kB 0 1 2 3 4 5 ... 379 380 381 382 383 + * mesh2d_nNodes (mesh2d_nNodes) int64 2kB 0 1 2 3 4 5 ... 212 213 214 215 216 + * mesh2d_nEdges (mesh2d_nEdges) int64 5kB 0 1 2 3 4 5 ... 595 596 597 598 599 Data variables: node_z (mesh2d_nNodes) float64 2kB 1.933 2.091 1.875 ... 5.688 7.491 face_z (mesh2d_nFaces) float64 3kB 1.737 1.918 2.269 ... 5.408 6.424 - edge_z (mesh2d_nEdges) float64 5kB 1.989 1.875 1.8 ... 4.909 6.544
PandasIndex(RangeIndex(start=0, stop=384, step=1, name='mesh2d_nFaces'))
PandasIndex(RangeIndex(start=0, stop=217, step=1, name='mesh2d_nNodes'))
PandasIndex(RangeIndex(start=0, stop=600, step=1, name='mesh2d_nEdges'))
<xarray.Dataset> Size: 0B Dimensions: () Data variables: - *empty*+ *empty*
[5248 values with dtype=float64]
[5248 values with dtype=float64]
array([1, 2, 3, 4, 5])
array([ 0, 1, 2, ..., 5245, 5246, 5247])
PandasIndex(Index([1, 2, 3, 4, 5], dtype='int64', name='layer'))
PandasIndex(RangeIndex(start=0, stop=5248, step=1, name='mesh2d_nFaces'))
PandasIndex(Index([1, 2, 3, 4, 5], dtype='int64', name='layer'))
PandasIndex(RangeIndex(start=0, stop=98, step=1, name='mesh2d_nFaces'))
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.])
PandasIndex(Index([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0], dtype='float64', name='id'))
Any percentile method can be created via:
-method = OverlapRegridder.create_percentile_methode(percentile)
method = OverlapRegridder.create_percentile_methode(percentile)
+See the examples.
Examples
+Setup a custom percentile method and apply it:
+>>> p33_3 = OverlapRegridder.create_percentile_method(33.3)
+>>> regridder = OverlapRegridder(source, target, method=p33_3)
+
The reduction methods for the overlap regridders now behave consistently when +all values are NaN or when all weights (overlaps) are zero, and all methods +give the same answer irrespective of the order in which the values are +encountered.
Percentiles (5, 10, 25, 50, 75, 90, 95) have been added to the
+xugrid.OverlapRegridder
as standard available reduction methods
+(available as "p5", "p10"
, etc.). Custom percentile values (e.g. 2.5, 42) can be
+setup using xugrid.OverlapRegridder.create_percentile_method()
.
Custom reduction functions provide to the overlap regridders no longer require
+an indices
argument.
xugrid.merge_partitions()
now automatically merges chunks (if defined
in the partition datasets). This removes the commonly seen
PerformanceWarning: Slicing with an out-of-order index is generating ...
@@ -683,8 +711,8 @@
Fixed#<
linestring locations, but wrong line indexes.
Included edge_node_connectivity
in xugrid.Ugrid2d.from_meshkernel()
,
so the ordering of edges is consistent with meshkernel
.
xugrid.UgridDataArrayAccessor.laplace_interpolate()
now uses rtol
and atol
keywords instead of tol
, to match changes in
@@ -706,10 +734,10 @@
Fixed indexing bug in the "mode"
method in
xugrid.CentroidLocatorRegridder
, xugrid.OverlapRegridder
,
@@ -717,8 +745,8 @@
xugrid.earcut_triangulate_polygons()
and
xugrid.Ugrid2d.earcut_triangulate_polygons()
have been added to break
@@ -730,10 +758,10 @@
xugrid.Ugrid2d.equals()
and xugrid.Ugrid1d.equals()
test if
dataset is equal instead of testing type.
xugrid.Ugrid2d.from_structured_multicoord()
has been added
to generate UGRID topologies from rotated or approximated curvilinear grids.
xugrid.Ugrid2d.from_structured()
now takes x
and y
arguments instead
of x_bounds
and y_bounds
arguments.
xugrid.UgridDataArrayAccessor.reindex_like()
will now take the tolerance
argument into account before sorting. In the past, near ties could be resolved
differently between otherwise similar grid topologies due to roundoff.
xugrid.UgridDataArrayAccessor.laplace_interpolate()
now also supports
interpolation of node associated data, and Ugrid1d topologies.
xugrid.UgridDataArrayAccessor.laplace_interpolate()
no longer uses scipy’s
ILU decomposition as a preconditioner. A simpler and more effective preconditioner
@@ -809,10 +837,10 @@
Initialize Meshkernel with a spherical projection if the coordinate reference system (crs) is geographic.
Support for Meshkernel 3 (#171). Initialize Meshkernel with defaults, setting it to cartesian projection.
xugrid.Ugrid2d.to_nonperiodic()
,
xugrid.UgridDataArrayAccessor.to_nonperiodic()
and
@@ -853,15 +881,15 @@
UGRID 2D topologies are no longer automatically forced in counterclockwise orientation during initialization.
Using an index which only reorders but does not change the size in
xugrid.Ugrid1d.topology_subset()
or
@@ -873,10 +901,10 @@
xugrid.Ugrid2d.intersect_line()
,
xugrid.Ugrid2d.intersect_linestring()
@@ -887,8 +915,8 @@
Selection operations along a line, or at point locations, will now prefix the name of the grid in the x and y coordinates. This avoids name collisions when @@ -898,8 +926,8 @@
xugrid.UgridDatasetAccessor.sel()
would return only a single grid
topology even when the selection subject contains more than one grid. It now
@@ -907,20 +935,20 @@
Bug in xugrid.snap_to_grid()
, which caused an IndexError
.
See #122.
Added xugrid.burn_vector_geometries()
to burn vector geometries in the
form of geopandas GeoDataFrames into a Ugrid2d topology.
xugrid.CentroidLocatorRegridder
, xugrid.OverlapRegridder
,
and xugrid.BarycentricInterpolator
will now also regrid structured
@@ -963,8 +991,8 @@
Initializing a Ugrid2d topology with an invalid edge_node_connectivity will no longer raise an error.
Computing indexer to avoid dask array of unknown shape upon plotting. See #117.
Fillvalue was not properly replaced in cast. See #113.
xugrid.Ugrid2d.label_partitions()
, xugrid.Ugrid2d.partition()
,
xugrid.Ugrid2d.merge_partitions()
have been added to partition and merge
@@ -1023,8 +1051,8 @@
xugrid.Ugrid1d.contract_vertices()
has been added.
Regridding structured grids now throws error if computed weights < 0.0 or > 1.0, before these weights were clipped to 0.0 and 1.0 respectively.
xugrid.BarycentricInterpolator
,
xugrid.CentroidLocatorRegridder
, xugrid.OverlapRegridder
,
@@ -1056,10 +1084,10 @@
xugrid.Ugrid2d.tesselate_centroidal_voronoi()
and
xugrid.Ugrid2d.tesselate_circumcenter_voronoi()
will only include
@@ -1071,8 +1099,8 @@
geopandas
was missing in the environment.xugrid.Ugrid2d.sel_points()
and
xugrid.UgridDataArrayAccessor.sel_points()
now return a result with an
@@ -1085,8 +1113,8 @@
xugrid.Ugrid2d.tesselate_circumcenter_voronoi()
has been added to
provide orthogonal voronoi cells for triangular grids.
pygeos
has been replaced by shapely >= 2.0
.
xugrid.snap_to_grid()
will now return a UgridDataset and a geopandas
@@ -1126,18 +1154,18 @@
xugrid.Ugrid2d.tesselate_circumcenter_voronoi()
has been added to
provide orthogonal voronoi cells for triangular grids.
xugrid.open_dataarray()
will now return xugrid.UgridDataArray
instead of only an xarray DataArray without topology.
Several regridding methods have been added for face associated data:
xugrid.BarycentricInterpolator
have been added to interpolate
@@ -1164,10 +1192,10 @@
xugrid.Ugrid1d.topology_subset()
,
xugrid.Ugrid2d.topology_subset()
, and therefore also
@@ -1189,8 +1217,8 @@
Forwarding to the internal xarray object is now setup at class definition of
UgridDataArray
and UgridDataset
rather than at runtime.
@@ -1216,8 +1244,8 @@
xugrid.Ugrid1d
and xugrid.Ugrid2d
can now be initialized
with an attrs
argument to setup non-default UGRID attributes such as
@@ -1237,28 +1265,28 @@
Move matplotlib import into a function body so matplotlib remains an optional dependency.
Warn instead of error when the UGRID attributes indicate a set of coordinate that are not present in the dataset.
Use pyproject.toml for setuptools instead of setup.cfg.
xugrid.Ugrid1d.edge_bounds
has been added to get the bounds
for every edge contained in the grid.
xugrid.UgridDataArray.from_structured()
will no longer result in
a flipped grid when the structured coordintes are not ascending.
The setitem method of xugrid.UgridDataset
has been updated to check
the dimensions of grids rather than the dimensions of objects to decide
@@ -1301,25 +1329,25 @@
list
and dict
type annotations have been replaced with List
and Dict
from the typing module to support older versions of Python (<3.9).
The inplace
argument has been removed from xugrid.Ugrid1d.to_crs()
and xugrid.Ugrid2d.to_crs()
; A copy is returned when the CRS is already
as requested.
xugrid.UgridDataArrayAccessor.set_crs()
has been added to set the CRS.
xugrid.UgridDataArrayAccessor.to_crs()
has been added to reproject the
@@ -1338,18 +1366,18 @@
A start_index
of 1 in connectivity arrays is handled and will no longer
result in indexing errors.
levels
argument is now respected in line and pcolormesh plotting methods.
UGRID variables are now extracted via xugrid.UgridRolesAccessor
to
allow for multiple UGRID topologies in a single dataset.
xugrid.UgridRolesAccessor
has been added to extract UGRID variables
from xarray Datasets.