diff --git a/.doctrees/api.doctree b/.doctrees/api.doctree index d1ebb53f5..2758322f3 100644 Binary files a/.doctrees/api.doctree and b/.doctrees/api.doctree differ diff --git a/.doctrees/api/xugrid.Ugrid2d.doctree b/.doctrees/api/xugrid.Ugrid2d.doctree index 54cf1709e..a16a2a26f 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.doctree and b/.doctrees/api/xugrid.Ugrid2d.doctree differ diff --git a/.doctrees/api/xugrid.Ugrid2d.sel_points.doctree b/.doctrees/api/xugrid.Ugrid2d.sel_points.doctree index afc3aa04d..73e0e8e0e 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.sel_points.doctree and b/.doctrees/api/xugrid.Ugrid2d.sel_points.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataArrayAccessor.doctree b/.doctrees/api/xugrid.UgridDataArrayAccessor.doctree index 4bd5631e7..9489eadb8 100644 Binary files a/.doctrees/api/xugrid.UgridDataArrayAccessor.doctree and b/.doctrees/api/xugrid.UgridDataArrayAccessor.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataArrayAccessor.sel_points.doctree b/.doctrees/api/xugrid.UgridDataArrayAccessor.sel_points.doctree index 4f060f66a..0b9051317 100644 Binary files a/.doctrees/api/xugrid.UgridDataArrayAccessor.sel_points.doctree and b/.doctrees/api/xugrid.UgridDataArrayAccessor.sel_points.doctree differ diff --git a/.doctrees/api/xugrid.UgridDatasetAccessor.doctree b/.doctrees/api/xugrid.UgridDatasetAccessor.doctree index db97a6d7e..63c2d5829 100644 Binary files a/.doctrees/api/xugrid.UgridDatasetAccessor.doctree and b/.doctrees/api/xugrid.UgridDatasetAccessor.doctree differ diff --git a/.doctrees/api/xugrid.UgridDatasetAccessor.sel_points.doctree b/.doctrees/api/xugrid.UgridDatasetAccessor.sel_points.doctree index 9de1f4e38..8fbf7d252 100644 Binary files a/.doctrees/api/xugrid.UgridDatasetAccessor.sel_points.doctree and b/.doctrees/api/xugrid.UgridDatasetAccessor.sel_points.doctree differ diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index c9cadfc5a..cc939a511 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 ad50d5e6e..35e826048 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 c33571207..1916397e7 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 f2e74f3c6..f91bd7774 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 efd927080..7132c3b45 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 96998fbe3..69f03c66e 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 5128affbe..977e1485f 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 1f5431f4a..3396e810a 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 9d9f29872..a8bd37e1c 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 a6deae3f9..e1760fd55 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 4fdb35030..20b1a21ce 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 dbb905712..649f8a5e5 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 d7ed086f0..612425422 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 73d83140f..1fac11296 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 fe34baeb8..5af3834a6 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/sg_execution_times.doctree b/.doctrees/sample_data/sg_execution_times.doctree index 2dc42b3bd..e9ab8313b 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 77006a03e..2c4c6539d 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 88367d969..b536f8c71 100644 Binary files a/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip and b/_downloads/1da8bbc63e9e34158260eadd1533549c/quick_overview.zip differ diff --git a/_downloads/2dbba5ebb6d2057d196983a008981162/voronoi.zip b/_downloads/2dbba5ebb6d2057d196983a008981162/voronoi.zip index 5672d56e0..11e7da87f 100644 Binary files a/_downloads/2dbba5ebb6d2057d196983a008981162/voronoi.zip and b/_downloads/2dbba5ebb6d2057d196983a008981162/voronoi.zip differ diff --git a/_downloads/37998fdc2548b23faf513b314db93d21/regridder_overview.zip b/_downloads/37998fdc2548b23faf513b314db93d21/regridder_overview.zip index 8a0486685..f1f26f611 100644 Binary files a/_downloads/37998fdc2548b23faf513b314db93d21/regridder_overview.zip and b/_downloads/37998fdc2548b23faf513b314db93d21/regridder_overview.zip differ diff --git a/_downloads/3e8af3e56da80727f8440a5b5f94f5cb/disk.zip b/_downloads/3e8af3e56da80727f8440a5b5f94f5cb/disk.zip index 35aa99794..f39c7d24c 100644 Binary files a/_downloads/3e8af3e56da80727f8440a5b5f94f5cb/disk.zip and b/_downloads/3e8af3e56da80727f8440a5b5f94f5cb/disk.zip differ diff --git a/_downloads/3eb350a8b54f214b88c5181e546a155e/adh_san_diego.zip b/_downloads/3eb350a8b54f214b88c5181e546a155e/adh_san_diego.zip index 30048708f..755a49ef1 100644 Binary files a/_downloads/3eb350a8b54f214b88c5181e546a155e/adh_san_diego.zip and b/_downloads/3eb350a8b54f214b88c5181e546a155e/adh_san_diego.zip differ diff --git a/_downloads/422003fc9b51482872f8f3701ce47abe/provinces_nl.zip b/_downloads/422003fc9b51482872f8f3701ce47abe/provinces_nl.zip index 8cceb6989..5cb06373a 100644 Binary files a/_downloads/422003fc9b51482872f8f3701ce47abe/provinces_nl.zip and b/_downloads/422003fc9b51482872f8f3701ce47abe/provinces_nl.zip differ diff --git a/_downloads/43d7b47db560c8c70c383a84a444ed83/connectivity.zip b/_downloads/43d7b47db560c8c70c383a84a444ed83/connectivity.zip index adadbbf5e..644917d28 100644 Binary files a/_downloads/43d7b47db560c8c70c383a84a444ed83/connectivity.zip and b/_downloads/43d7b47db560c8c70c383a84a444ed83/connectivity.zip differ diff --git a/_downloads/90d50f8fc21b6ec5d818d26f7955df8a/overlap_regridder.zip b/_downloads/90d50f8fc21b6ec5d818d26f7955df8a/overlap_regridder.zip index 10447fa1d..be15a3deb 100644 Binary files a/_downloads/90d50f8fc21b6ec5d818d26f7955df8a/overlap_regridder.zip and b/_downloads/90d50f8fc21b6ec5d818d26f7955df8a/overlap_regridder.zip differ diff --git a/_downloads/97eabe2c66fc9328b1e51f27fdee52f6/partitioning.zip b/_downloads/97eabe2c66fc9328b1e51f27fdee52f6/partitioning.zip index f0dc00aa2..917d9657b 100644 Binary files a/_downloads/97eabe2c66fc9328b1e51f27fdee52f6/partitioning.zip and b/_downloads/97eabe2c66fc9328b1e51f27fdee52f6/partitioning.zip differ diff --git a/_downloads/9be12df0ec6c323839ed0cb99cc89228/elevation_nl.zip b/_downloads/9be12df0ec6c323839ed0cb99cc89228/elevation_nl.zip index d6dba1ca3..2c3fbc667 100644 Binary files a/_downloads/9be12df0ec6c323839ed0cb99cc89228/elevation_nl.zip and b/_downloads/9be12df0ec6c323839ed0cb99cc89228/elevation_nl.zip differ diff --git a/_downloads/a50ba9731493d1c74010dcadb8694b20/selection.zip b/_downloads/a50ba9731493d1c74010dcadb8694b20/selection.zip index ac934d54f..32859a1df 100644 Binary files a/_downloads/a50ba9731493d1c74010dcadb8694b20/selection.zip and b/_downloads/a50ba9731493d1c74010dcadb8694b20/selection.zip differ diff --git a/_downloads/cc393383c363f7c590c6ef714836f52a/xoxo.zip b/_downloads/cc393383c363f7c590c6ef714836f52a/xoxo.zip index 3672e069f..21415dacb 100644 Binary files a/_downloads/cc393383c363f7c590c6ef714836f52a/xoxo.zip and b/_downloads/cc393383c363f7c590c6ef714836f52a/xoxo.zip differ diff --git a/_downloads/d2379110fee2f2fbaf724f0142daaa8d/plotting.zip b/_downloads/d2379110fee2f2fbaf724f0142daaa8d/plotting.zip index ef2bb8d58..8f8eb6ce0 100644 Binary files a/_downloads/d2379110fee2f2fbaf724f0142daaa8d/plotting.zip and b/_downloads/d2379110fee2f2fbaf724f0142daaa8d/plotting.zip differ diff --git a/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip b/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip index 57ef4e8a9..709e9f125 100644 Binary files a/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip and b/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip differ diff --git a/_modules/xugrid/core/dataarray_accessor.html b/_modules/xugrid/core/dataarray_accessor.html index 616c88b53..afb2ffec0 100644 --- a/_modules/xugrid/core/dataarray_accessor.html +++ b/_modules/xugrid/core/dataarray_accessor.html @@ -397,6 +397,7 @@
from typing import Dict, List, Sequence, Tuple, Union
+import numpy as np
import scipy.sparse
import xarray as xr
@@ -597,7 +598,7 @@ Source code for xugrid.core.dataarray_accessor
[docs]
- def sel_points(self, x, y, out_of_bounds="warn"):
+ def sel_points(self, x, y, out_of_bounds="warn", fill_value=np.nan):
"""
Select points in the unstructured grid.
@@ -608,21 +609,23 @@
Source code for xugrid.core.dataarray_accessor
----------
x: ndarray of floats with shape ``(n_points,)``
y: ndarray of floats with shape ``(n_points,)``
-
- out_of_bounds: str, default "warn"
+ out_of_bounds: str, default: "warn"
What to do when points are located outside of any feature:
* raise: raise a ValueError.
- * ignore: return NaN for the out of bounds points.
+ * ignore: return ``fill_value`` for the out of bounds points.
* warn: give a warning and return NaN for the out of bounds points.
* drop: drop the out of bounds points. They may be identified
via the ``index`` coordinate of the returned selection.
+ fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan
+ Value to assign to out-of-bounds points if out_of_bounds is warn
+ or ignore. Forwarded to xarray's ``.where()`` method.
Returns
-------
points: Union[xr.DataArray, xr.Dataset]
"""
- return self.grid.sel_points(self.obj, x, y, out_of_bounds)
+ return self.grid.sel_points(self.obj, x, y, out_of_bounds, fill_value)
diff --git a/_modules/xugrid/core/dataset_accessor.html b/_modules/xugrid/core/dataset_accessor.html
index 91ac74b1a..81c1c0ec7 100644
--- a/_modules/xugrid/core/dataset_accessor.html
+++ b/_modules/xugrid/core/dataset_accessor.html
@@ -651,7 +651,7 @@ Source code for xugrid.core.dataset_accessor
[docs]
- def sel_points(self, x, y, out_of_bounds="warn"):
+ def sel_points(self, x, y, out_of_bounds="warn", fill_value=np.nan):
"""
Select points in the unstructured grid.
@@ -662,15 +662,17 @@ Source code for xugrid.core.dataset_accessor
----------
x: ndarray of floats with shape ``(n_points,)``
y: ndarray of floats with shape ``(n_points,)``
-
out_of_bounds: str, default ``"warn"``
What to do when points are located outside of any feature:
* raise: raise a ValueError.
- * ignore: return NaN for the out of bounds points.
+ * ignore: return ``fill_value`` for the out of bounds points.
* warn: give a warning and return NaN for the out of bounds points.
* drop: drop the out of bounds points. They may be identified
via the ``index`` coordinate of the returned selection.
+ fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan
+ Value to assign to out-of-bounds points if out_of_bounds is warn
+ or ignore. Forwarded to xarray's ``.where()`` method.
Returns
-------
@@ -679,7 +681,7 @@ Source code for xugrid.core.dataset_accessor
"""
result = self.obj
for grid in self.grids:
- result = grid.sel_points(result, x, y, out_of_bounds)
+ result = grid.sel_points(result, x, y, out_of_bounds, fill_value)
return result
diff --git a/_modules/xugrid/ugrid/ugrid2d.html b/_modules/xugrid/ugrid/ugrid2d.html
index a45203b4c..160a625f0 100644
--- a/_modules/xugrid/ugrid/ugrid2d.html
+++ b/_modules/xugrid/ugrid/ugrid2d.html
@@ -1736,7 +1736,9 @@ Source code for xugrid.ugrid.ugrid2d
[docs]
- def sel_points(self, obj, x: FloatArray, y: FloatArray, out_of_bounds="warn"):
+ def sel_points(
+ self, obj, x: FloatArray, y: FloatArray, out_of_bounds="warn", fill_value=np.nan
+ ):
"""
Select points in the unstructured grid.
@@ -1750,10 +1752,13 @@ Source code for xugrid.ugrid.ugrid2d
What to do when points are located outside of any feature:
* raise: raise a ValueError.
- * ignore: return NaN for the out of bounds points.
+ * ignore: return ``fill_value`` for the out of bounds points.
* warn: give a warning and return NaN for the out of bounds points.
* drop: drop the out of bounds points. They may be identified
via the ``index`` coordinate of the returned selection.
+ fill_value: scalar, DataArray, Dataset, or callable, optional, default: np.nan
+ Value to assign to out-of-bounds points if out_of_bounds is warn
+ or ignore. Forwarded to xarray's ``.where()`` method.
Returns
-------
@@ -1778,8 +1783,8 @@ Source code for xugrid.ugrid.ugrid2d
xy = np.column_stack([x, y])
index = self.locate_points(xy)
- multiplier = None
keep = slice(None, None) # keep all by default
+ condition = None
valid = index != -1
if not valid.all():
if out_of_bounds == "raise":
@@ -1790,33 +1795,25 @@ Source code for xugrid.ugrid.ugrid2d
"Not all points are located inside of the grid. "
"Out of bounds points are marked by NaN."
)
-
- # Mask the out_of_bounds points with NaN (they will be indexed
- # with -1). Multiply valid values by 1.0, multiply outside
- # values by NaN. Note that multiplying a dask array with a
- # numpy array will result a dask array, so this doesn't break
- # lazy evaluation.
- multiplier = xr.DataArray(
- data=np.where(valid, 1.0, np.nan), dims=(dim,)
- )
-
+ condition = xr.DataArray(valid, dims=(dim,))
elif out_of_bounds == "drop":
index = index[valid]
keep = valid
-
else:
# This code shouldn't be reachable due to check up top.
raise ValueError("invalid out_of_bounds options")
+ # Create the selection DataArray or Dataset
coords = {
f"{self.name}_index": (dim, np.arange(len(xy))[keep]),
f"{self.name}_x": (dim, xy[keep, 0]),
f"{self.name}_y": (dim, xy[keep, 1]),
}
selection = obj.isel({dim: index}).assign_coords(coords)
- if multiplier is not None:
- selection = selection * multiplier
+ # Set values to fill_value for out-of-bounds
+ if condition is not None:
+ selection = selection.where(condition, other=fill_value)
return selection
diff --git a/_sources/examples-dev/sg_execution_times.rst.txt b/_sources/examples-dev/sg_execution_times.rst.txt
index cc66c2c49..97113b0ec 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.180** total execution time for 1 file **from examples-dev**:
+**00:01.150** 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.180
+ - 00:01.150
- 0.0
diff --git a/_sources/examples-dev/voronoi.rst.txt b/_sources/examples-dev/voronoi.rst.txt
index c8fabab97..97e98dd8f 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.180 seconds)
+ **Total running time of the script:** (0 minutes 1.150 seconds)
.. _sphx_glr_download_examples-dev_voronoi.py:
diff --git a/_sources/examples/connectivity.rst.txt b/_sources/examples/connectivity.rst.txt
index c511e3db3..4bf26c16a 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.420 seconds)
+ **Total running time of the script:** (0 minutes 1.374 seconds)
.. _sphx_glr_download_examples_connectivity.py:
diff --git a/_sources/examples/overlap_regridder.rst.txt b/_sources/examples/overlap_regridder.rst.txt
index 358d2d110..cb035e301 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
-
+
@@ -298,7 +298,7 @@ OverlapRegridder:
.. code-block:: none
-
+
@@ -373,7 +373,7 @@ Then, provide it as the regridder method as above:
.. code-block:: none
-
+
@@ -384,7 +384,7 @@ Then, provide it as the regridder method as above:
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** (0 minutes 4.042 seconds)
+ **Total running time of the script:** (0 minutes 4.160 seconds)
.. _sphx_glr_download_examples_overlap_regridder.py:
diff --git a/_sources/examples/partitioning.rst.txt b/_sources/examples/partitioning.rst.txt
index 2536ee5e7..9f57d41d8 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
-
+
@@ -668,7 +668,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
@@ -1068,9 +1068,9 @@ original topology. ``reindex_like`` looks at the coordinates of both
Coordinates:
mesh2d_face_x (mesh2d_nFaces) float64 42kB 2.388e+04 1.86e+05 ... 3.03e+04
mesh2d_face_y (mesh2d_nFaces) float64 42kB 3.648e+05 ... 3.964e+05
- * 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
@@ -1473,9 +1473,9 @@ reorder the data after merging.
Coordinates:
mesh2d_face_x (mesh2d_nFaces) float64 42kB 2.388e+04 1.86e+05 ... 3.03e+04
mesh2d_face_y (mesh2d_nFaces) float64 42kB 3.648e+05 ... 3.964e+05
- * 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_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=600, step=1, name='mesh2d_nEdges'))
PandasIndex(RangeIndex(start=0, stop=217, step=1, name='mesh2d_nNodes'))
PandasIndex(RangeIndex(start=0, stop=384, step=1, name='mesh2d_nFaces'))
<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_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=600, step=1, name='mesh2d_nEdges'))
PandasIndex(RangeIndex(start=0, stop=217, step=1, name='mesh2d_nNodes'))
PandasIndex(RangeIndex(start=0, stop=384, step=1, name='mesh2d_nFaces'))
<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'))
Ugrid2d.sel
(obj[, x, y])
Find selection in the UGRID x and y coordinates.
Ugrid2d.sel_points
(obj, x, y[, out_of_bounds])
Ugrid2d.sel_points
(obj, x, y[, ...])
Select points in the unstructured grid.
Ugrid2d.intersect_line
(obj, start, end)
sel
(obj[, x, y])
Find selection in the UGRID x and y coordinates.
sel_points
(obj, x, y[, out_of_bounds])
sel_points
(obj, x, y[, out_of_bounds, ...])
Select points in the unstructured grid.
set_crs
([crs, epsg, allow_override])
Select points in the unstructured grid.
What to do when points are located outside of any feature:
raise: raise a ValueError.
ignore: return NaN for the out of bounds points.
ignore: return fill_value
for the out of bounds points.
warn: give a warning and return NaN for the out of bounds points.
drop: drop the out of bounds points. They may be identified
via the index
coordinate of the returned selection.
fill_value (scalar, DataArray, Dataset, or callable, optional, default: np.nan) – Value to assign to out-of-bounds points if out_of_bounds is warn
+or ignore. Forwarded to xarray’s .where()
method.
sel
([x, y])
Return a new object, a subselection in the UGRID x and y coordinates.
sel_points
(x, y[, out_of_bounds])
sel_points
(x, y[, out_of_bounds, fill_value])
Select points in the unstructured grid.
set_crs
([crs, epsg, allow_override])
Select points in the unstructured grid.
Out-of-bounds points are ignored. They may be identified via the
index
coordinate of the returned selection.
x (ndarray of floats with shape (n_points,)
)
y (ndarray of floats with shape (n_points,)
)
out_of_bounds (str, default "warn") –
What to do when points are located outside of any feature:
+out_of_bounds (str, default: "warn") –
What to do when points are located outside of any feature:
raise: raise a ValueError.
ignore: return NaN for the out of bounds points.
ignore: return fill_value
for the out of bounds points.
warn: give a warning and return NaN for the out of bounds points.
drop: drop the out of bounds points. They may be identified
via the index
coordinate of the returned selection.
fill_value (scalar, DataArray, Dataset, or callable, optional, default: np.nan) – Value to assign to out-of-bounds points if out_of_bounds is warn
+or ignore. Forwarded to xarray’s .where()
method.
sel
([x, y])
sel_points
(x, y[, out_of_bounds])
sel_points
(x, y[, out_of_bounds, fill_value])
Select points in the unstructured grid.
set_crs
([crs, epsg, allow_override, topology])
Select points in the unstructured grid.
Out-of-bounds points are ignored. They may be identified via the
index
coordinate of the returned selection.
What to do when points are located outside of any feature:
raise: raise a ValueError.
ignore: return NaN for the out of bounds points.
ignore: return fill_value
for the out of bounds points.
warn: give a warning and return NaN for the out of bounds points.
drop: drop the out of bounds points. They may be identified
via the index
coordinate of the returned selection.
fill_value (scalar, DataArray, Dataset, or callable, optional, default: np.nan) – Value to assign to out-of-bounds points if out_of_bounds is warn
+or ignore. Forwarded to xarray’s .where()
method.
00:01.180 total execution time for 1 file from examples-dev:
+00:01.150 total execution time for 1 file from examples-dev:
<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
The topology is equivalent, but the nodes, edges, and faces are in a @@ -1287,9 +1287,9 @@
Total running time of the script: (0 minutes 3.810 seconds)
<matplotlib.collections.PolyCollection object at 0x7f5671d3e390>
+<matplotlib.collections.PolyCollection object at 0x7f3540279640>
Like Xarray, the axes and the colorbar are labeled automatically using the
@@ -985,7 +985,7 @@
UgridDataArrayds["edge_z"].ugrid.plot()
<matplotlib.collections.LineCollection object at 0x7f5671ec5160>
+<matplotlib.collections.LineCollection object at 0x7f35401e0080>
The method called by default depends on the type of the data:
@@ -1015,7 +1015,7 @@ UgridDataArrayds["node_z"].ugrid.plot(ax=ax2)
<matplotlib.collections.PolyCollection object at 0x7f567cace360>
+<matplotlib.collections.PolyCollection object at 0x7f3541035bb0>
We can also exactly control the type of plot we want. For example, to plot
@@ -1023,7 +1023,7 @@
UgridDataArrayds["face_z"].ugrid.plot.contourf()
<matplotlib.tri._tricontour.TriContourSet object at 0x7f567c881280>
+<matplotlib.tri._tricontour.TriContourSet object at 0x7f354afa9130>
We can also overlay this data with the edges:
@@ -1032,7 +1032,7 @@ UgridDataArrayds["face_z"].ugrid.plot.line(color="black")
<matplotlib.collections.LineCollection object at 0x7f567bc765a0>
+<matplotlib.collections.LineCollection object at 0x7f3540523800>
In general, there has to be data associated with the mesh topology before a
@@ -1083,7 +1083,7 @@
Other types of plotds["node_z"].ugrid.plot.scatter(ax=axes[4, 2])
<matplotlib.collections.PathCollection object at 0x7f567bd6fa40>
+<matplotlib.collections.PathCollection object at 0x7f354ad26f30>
The surface
methods generate 3D surface plots:
@@ -1094,7 +1094,7 @@ Other types of plotds["node_z"].ugrid.plot.surface(ax=ax1)
<mpl_toolkits.mplot3d.art3d.Poly3DCollection object at 0x7f5672d54ce0>
+<mpl_toolkits.mplot3d.art3d.Poly3DCollection object at 0x7f35413959d0>
@@ -1106,7 +1106,7 @@ Additional Argumentsds["face_z"].ugrid.plot(cmap="RdBu", levels=8, yincrease=False)
<matplotlib.collections.PolyCollection object at 0x7f5672fe38f0>
+<matplotlib.collections.PolyCollection object at 0x7f35410e1820>
@@ -1120,7 +1120,7 @@ As a functionxugrid.plot.pcolormesh(grid, da)
<matplotlib.collections.PolyCollection object at 0x7f5672b9aba0>
+<matplotlib.collections.PolyCollection object at 0x7f35412dd400>
@@ -1134,10 +1134,10 @@ Xarray DataArray plotsdepth.isel(node=1000).plot()
[<matplotlib.lines.Line2D object at 0x7f567bd4c5c0>]
+[<matplotlib.lines.Line2D object at 0x7f354ae4f440>]
-Total running time of the script: (0 minutes 12.019 seconds)
+Total running time of the script: (0 minutes 12.328 seconds)