diff --git a/.doctrees/api.doctree b/.doctrees/api.doctree index 16a7244b9..ca30c0b36 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 5175c5a82..8141398a5 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.doctree and b/.doctrees/api/xugrid.Ugrid2d.doctree differ diff --git a/.doctrees/api/xugrid.Ugrid2d.from_structured_bounds.doctree b/.doctrees/api/xugrid.Ugrid2d.from_structured_bounds.doctree index 56f2583ec..5d3aee9a5 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.from_structured_bounds.doctree and b/.doctrees/api/xugrid.Ugrid2d.from_structured_bounds.doctree differ diff --git a/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals1d.doctree b/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals1d.doctree index 46dd9b089..980b901b5 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals1d.doctree and b/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals1d.doctree differ diff --git a/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals2d.doctree b/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals2d.doctree index 3b508a94f..dfc9a0bec 100644 Binary files a/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals2d.doctree and b/.doctrees/api/xugrid.Ugrid2d.from_structured_intervals2d.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataArray.doctree b/.doctrees/api/xugrid.UgridDataArray.doctree index 285f54fa8..9c305958d 100644 Binary files a/.doctrees/api/xugrid.UgridDataArray.doctree and b/.doctrees/api/xugrid.UgridDataArray.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataArray.from_structured.doctree b/.doctrees/api/xugrid.UgridDataArray.from_structured.doctree deleted file mode 100644 index f60211a9f..000000000 Binary files a/.doctrees/api/xugrid.UgridDataArray.from_structured.doctree and /dev/null differ diff --git a/.doctrees/api/xugrid.UgridDataArray.from_structured2d.doctree b/.doctrees/api/xugrid.UgridDataArray.from_structured2d.doctree new file mode 100644 index 000000000..345e5d676 Binary files /dev/null and b/.doctrees/api/xugrid.UgridDataArray.from_structured2d.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataset.doctree b/.doctrees/api/xugrid.UgridDataset.doctree index a4a06b2e6..ac5f12a33 100644 Binary files a/.doctrees/api/xugrid.UgridDataset.doctree and b/.doctrees/api/xugrid.UgridDataset.doctree differ diff --git a/.doctrees/api/xugrid.UgridDataset.from_structured.doctree b/.doctrees/api/xugrid.UgridDataset.from_structured.doctree deleted file mode 100644 index eb165048b..000000000 Binary files a/.doctrees/api/xugrid.UgridDataset.from_structured.doctree and /dev/null differ diff --git a/.doctrees/api/xugrid.UgridDataset.from_structured2d.doctree b/.doctrees/api/xugrid.UgridDataset.from_structured2d.doctree new file mode 100644 index 000000000..9b12f479e Binary files /dev/null and b/.doctrees/api/xugrid.UgridDataset.from_structured2d.doctree differ diff --git a/.doctrees/changelog.doctree b/.doctrees/changelog.doctree index bc37c8130..99cd2dcd0 100644 Binary files a/.doctrees/changelog.doctree and b/.doctrees/changelog.doctree differ diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index 81aaa92e8..86df6fd2e 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 a0787d9b6..f30de0587 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 7ae13b90e..515438749 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 880359a03..02dc016c8 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 b6b287b51..c33797d2e 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 52f494db7..248efd3e0 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 aa8f9373e..22c80956f 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 e3ecb9751..b43c1a412 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 e1b2be13b..eb812bd44 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 dac9e37bb..726509164 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 054709751..77c0792ea 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 2ccc5cbdc..a649bc581 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 2c8078771..3c993ae8b 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 60e9e37b9..97fd36227 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 401c59504..13825eba3 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 57674f2f8..16615befa 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 8cb96399c..3784e5891 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/sample_data/xoxo.doctree b/.doctrees/sample_data/xoxo.doctree index 676589188..9768b1dd4 100644 Binary files a/.doctrees/sample_data/xoxo.doctree and b/.doctrees/sample_data/xoxo.doctree differ diff --git a/.doctrees/sg_execution_times.doctree b/.doctrees/sg_execution_times.doctree index e6d115068..1679a8126 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 6b088faf6..ccf591ef0 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 64a88b0af..e52cfe806 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 93236ee26..3476ce364 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 d2fc7a488..5211de441 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 9c1f17f3c..10a329b80 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 97eceb908..6d6f1e4e3 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 1d022ad35..1346096f7 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 cc7ee87c1..9c0547959 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 059c6699d..261bfbd54 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 c4da1d00d..db473e8cb 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 b6d783e1d..c5f99654f 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 02b053596..585a83417 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 d9e018b3a..e44f76dae 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 057886479..54f6b9b35 100644 Binary files a/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip and b/_downloads/f25be90ee220882246ef4778e276e863/vector_conversion.zip differ diff --git a/_modules/xugrid/core/wrap.html b/_modules/xugrid/core/wrap.html index 738788e0a..a8be9eea6 100644 --- a/_modules/xugrid/core/wrap.html +++ b/_modules/xugrid/core/wrap.html @@ -383,6 +383,7 @@

Source code for xugrid.core.wrap

 from __future__ import annotations
 
 import types
+import warnings
 from collections import ChainMap
 from functools import wraps
 from itertools import chain
@@ -615,55 +616,129 @@ 

Source code for xugrid.core.wrap

             self.obj, self.grid
         )
 
-
-[docs] +
+[docs] @staticmethod - def from_structured( + def from_structured2d( da: xr.DataArray, x: str | None = None, y: str | None = None, + x_bounds: xr.DataArray = None, + y_bounds: xr.DataArray = None, ) -> "UgridDataArray": """ Create a UgridDataArray from a (structured) xarray DataArray. The spatial dimensions are flattened into a single UGRID face dimension. - By default, this method looks for: - 1. ``"x"`` and ``"y"`` dimensions. - 2. ``"longitude"`` and ``"latitude"`` dimensions. - 3. ``"axis"`` attributes of "X" or "Y" on coordinates. - 4. ``"standard_name"`` attributes of "longitude", "latitude", - "projection_x_coordinate", or "project_y_coordinate" on coordinate - variables. - - Specify the x and y coordinate names explicitly otherwise. + 1. "x" and "y" dimensions + 2. "longitude" and "latitude" dimensions + 3. "axis" attributes of "X" or "Y" on coordinates + 4. "standard_name" attributes of "longitude", "latitude", + "projection_x_coordinate", or "projection_y_coordinate" on coordinate + variables Parameters ---------- - da: xr.DataArray - Last two dimensions must be the y and x dimension (in that order!). - x: str, default: None - Which coordinate to use as the UGRID x-coordinate. - y: str, default: None - Which coordinate to use as the UGRID y-coordinate. + da : xr.DataArray + The structured data array to convert. The last two dimensions must be + the y and x dimensions (in that order). + x : str, optional + Name of the UGRID x-coordinate, or x-dimension if bounds are provided. + Defaults to None. + y : str, optional + Name of the UGRID y-coordinate, or y-dimension if bounds are provided. + Defaults to None. + x_bounds : xr.DataArray, optional + Bounds for x-coordinates. Required for non-monotonic coordinates. + Defaults to None. + y_bounds : xr.DataArray, optional + Bounds for y-coordinates. Required for non-monotonic coordinates. + Defaults to None. Returns ------- - unstructured: UgridDataArray + UgridDataArray + The unstructured grid data array. + + Notes + ----- + When using bounds, they should have one of these shapes: + * x bounds: (M, 2) or (N, M, 4) + * y bounds: (N, 2) or (N, M, 4) + where N is the number of rows (along y) and M is columns (along x). + Cells with NaN bounds coordinates are omitted. + + Examples + -------- + Basic usage with default coordinate detection: + + >>> uda = xugrid.UgridDataArray.from_structured2d(data_array) + + Specifying explicit coordinate names: + + >>> uda = xugrid.UgridDataArray.from_structured2d( + ... data_array, + ... x="longitude", + ... y="latitude" + ... ) + + Using bounds for curvilinear grids: + + >>> uda = xugrid.UgridDataArray.from_structured2d( + ... data_array, + ... x="x_dim", + ... y="y_dim", + ... x_bounds=x_bounds_array, + ... y_bounds=y_bounds_array + ... ) """ if da.ndim < 2: raise ValueError( "DataArray must have at least two spatial dimensions. " f"Found: {da.dims}." ) - grid, stackdims = Ugrid2d.from_structured(da, x, y, return_dims=True) - face_da = da.stack( # noqa: PD013 - {grid.face_dimension: stackdims}, create_index=False - ).drop_vars(stackdims, errors="ignore") + if x_bounds is not None and y_bounds is not None: + if x is None or y is None: + raise ValueError("x and y must be provided for bounds") + yx = (y, x) + grid, index = Ugrid2d.from_structured_bounds( + x_bounds=x_bounds.transpose(y, x, ...).to_numpy(), + y_bounds=y_bounds.transpose(y, x, ...).to_numpy(), + return_index=True, + ) + else: + # Possibly rely on inference of x and y dims. + grid, yx = Ugrid2d.from_structured(da, x, y, return_dims=True) + index = slice(None, None) + + face_da = ( + da.stack( # noqa: PD013 + {grid.face_dimension: (yx)}, create_index=False + ) + .isel({grid.face_dimension: index}) + .drop_vars(yx, errors="ignore") + ) return UgridDataArray(face_da, grid)
+ @staticmethod + def from_structured( + da: xr.DataArray, + x: str | None = None, + y: str | None = None, + x_bounds: xr.DataArray = None, + y_bounds: xr.DataArray = None, + ) -> "UgridDataArray": + warnings.warn( + "UgridDataArray.from_structured is deprecated and will be removed. " + "Use UgridDataArray.from_structured2d instead.", + FutureWarning, + stacklevel=2, + ) + return UgridDataArray.from_structured2d(da, x, y, x_bounds, y_bounds) +
[docs] @staticmethod @@ -817,73 +892,129 @@

Source code for xugrid.core.wrap

         return UgridDataset(ds, [grid])
-
-[docs] +
+[docs] @staticmethod - def from_structured( + def from_structured2d( dataset: xr.Dataset, topology: dict | None = None ) -> "UgridDataset": """ Create a UgridDataset from a (structured) xarray Dataset. The spatial dimensions are flattened into a single UGRID face dimension. - By default, this method looks for: - 1. ``"x"`` and ``"y"`` dimensions. - 2. ``"longitude"`` and ``"latitude"`` dimensions. - 3. ``"axis"`` attributes of "X" or "Y" on coordinates. - 4. ``"standard_name"`` attributes of "longitude", "latitude", - "projection_x_coordinate", or "project_y_coordinate" on coordinate - variables. - - Specify the x and y coordinate names explicitly otherwise, see the - examples. + 1. "x" and "y" dimensions + 2. "longitude" and "latitude" dimensions + 3. "axis" attributes of "X" or "Y" on coordinates + 4. "standard_name" attributes of "longitude", "latitude", + "projection_x_coordinate", or "projection_y_coordinate" on coordinate + variables Parameters ---------- - dataset: xr.Dataset - topology: dict, optional, default is None. - Mapping of topology name to x and y coordinate variables. - If None, defaults to ``{"mesh2d": (None, None)}``. + dataset : xr.Dataset + The structured dataset to convert. + topology : dict, optional + Either: + * A mapping of topology name to (x, y) coordinate names + * A mapping of topology name to a dict containing: + - "x": x-dimension name + - "y": y-dimension name + - "bounds_x": x-bounds variable name + - "bounds_y": y-bounds variable name + Defaults to {"mesh2d": (None, None)}. Returns ------- - unstructured: UgridDataset + UgridDataset + The unstructured grid dataset. + + Notes + ----- + When using bounds, they should have one of these shapes: + * x bounds: (M, 2) or (N, M, 4) + * y bounds: (N, 2) or (N, M, 4) + where N is the number of rows (along y) and M is columns (along x). + Cells with NaN bounds coordinates are omitted. Examples -------- - By default, this method will look for ``"x"`` and ``"y"`` - coordinates and returns a UgriDataset with a Ugrid topology named - mesh2d: - - >>> uds = xugrid.UgridDataset.from_structured(dataset) - - In case of other names, the name of the resulting UGRID topology and - the x and y coordinates must be specified: - - >>> uds = xugrid.UgridDataset.from_structured( - >>> dataset, - >>> topology={"my_mesh2d": ("xc", "yc")}, - >>> ) - - In case of multiple grid topologies in a single dataset, the names must - be specified as well: - - >>> uds = xugrid.UgridDataset.from_structured( - >>> dataset, - >>> topology={"mesh2d_xy": ("x", "y"), "mesh2d_lonlat": {"lon", "lat"}, - >>> ) + Basic usage with default coordinate names: + + >>> uds = xugrid.UgridDataset.from_structured2d(dataset) + + Specifying custom coordinate names: + + >>> uds = xugrid.UgridDataset.from_structured2d( + ... dataset, + ... topology={"my_mesh2d": {"x": "xc", "y": "yc"}} + ... ) + + Multiple grid topologies in a single dataset: + + >>> uds = xugrid.UgridDataset.from_structured2d( + ... dataset, + ... topology={ + ... "mesh2d_xy": {"x": "x", "y": "y"}, + ... "mesh2d_lonlat": {"x": "lon", "y": "lat"} + ... } + ... ) + + Using bounds for non-monotonic coordinates (e.g., curvilinear grids): + + >>> uds = xugrid.UgridDataset.from_structured2d( + ... dataset, + ... topology={ + ... "my_mesh2d": { + ... "x": "M", + ... "y": "N", + ... "bounds_x": "grid_x", + ... "bounds_y": "grid_y" + ... } + ... } + ... ) """ if topology is None: + # By default, set None. This communicates to + # Ugrid2d.from_structured to infer x and y dims. topology = {"mesh2d": (None, None)} grids = [] dss = [] - for name, (x, y) in topology.items(): - grid, stackdims = Ugrid2d.from_structured( - dataset, x=x, y=y, name=name, return_dims=True - ) + for name, args in topology.items(): + x_bounds = None + y_bounds = None + if isinstance(args, dict): + x = args.get("x") + y = args.get("y") + if "x_bounds" in args and "y_bounds" in args: + if x is None or y is None: + raise ValueError("x and y must be provided for bounds") + x_bounds = dataset[args["x_bounds"]] + y_bounds = dataset[args["y_bounds"]] + elif isinstance(args, tuple): + x, y = args + else: + raise TypeError( + "Expected dict or tuple in topology, received: " + f"{type(args).__name__}" + ) + + if x_bounds is not None and y_bounds is not None: + stackdims = (y, x) + grid, index = Ugrid2d.from_structured_bounds( + x_bounds.transpose(*stackdims, ...).to_numpy(), + y_bounds.transpose(*stackdims, ...).to_numpy(), + name=name, + return_index=True, + ) + else: + grid, stackdims = Ugrid2d.from_structured( + dataset, x=x, y=y, name=name, return_dims=True + ) + index = slice(None, None) + # Use subset to check that ALL dims of stackdims are present in the # variable. checkdims = set(stackdims) @@ -895,16 +1026,30 @@

Source code for xugrid.core.wrap

             dss.append(
                 dataset[ugrid_vars]  # noqa: PD013
                 .stack({grid.face_dimension: stackdims})
+                .isel({grid.face_dimension: index})
                 .drop_vars(stackdims + (grid.face_dimension,))
             )
             grids.append(grid)
+
         # Add the original dataset to include all non-UGRID variables.
         dss.append(dataset)
         # Then merge with compat="override". This'll pick the first available
         # variable: i.e. it will prioritize the UGRID form.
         merged = xr.merge(dss, compat="override")
         return UgridDataset(merged, grids)
-
+ + + @staticmethod + def from_structured( + dataset: xr.Dataset, topology: dict | None = None + ) -> "UgridDataset": + warnings.warn( + "UgridDataset.from_structured is deprecated and will be removed. " + "Use UgridDataset.from_structured2d instead.", + FutureWarning, + stacklevel=2, + ) + return UgridDataset.from_structured2d(dataset, topology)
diff --git a/_modules/xugrid/ugrid/ugrid2d.html b/_modules/xugrid/ugrid/ugrid2d.html index 55cc0544b..93df651d2 100644 --- a/_modules/xugrid/ugrid/ugrid2d.html +++ b/_modules/xugrid/ugrid/ugrid2d.html @@ -2626,9 +2626,9 @@

Source code for xugrid.ugrid.ugrid2d

         Parameters
         ----------
         x_intervals: np.ndarray of shape (M + 1,)
-            x-coordinate interval values for N row and M columns.
+            x-coordinate interval values for N rows and M columns.
         y_intervals: np.ndarray of shape (N + 1,)
-            y-coordinate interval values for N row and M columns.
+            y-coordinate interval values for N rows and M columns.
         name: str
         """
         x_intervals = np.asarray(x_intervals)
@@ -2655,9 +2655,9 @@ 

Source code for xugrid.ugrid.ugrid2d

         Parameters
         ----------
         x_intervals: np.ndarray of shape shape (N + 1, M + 1)
-            x-coordinate interval values for N row and M columns.
+            x-coordinate interval values for N rows and M columns.
         y_intervals: np.ndarray of shape shape (N + 1, M + 1)
-            y-coordinate interval values for N row and M columns.
+            y-coordinate interval values for N rows and M columns.
         name: str
         """
         x_intervals = np.asarray(x_intervals)
@@ -2684,30 +2684,63 @@ 

Source code for xugrid.ugrid.ugrid2d

         x_bounds: np.ndarray,
         y_bounds: np.ndarray,
         name: str = "mesh2d",
-    ) -> "Ugrid2d":
+        return_index: bool = False,
+    ) -> Union["Ugrid2d", Tuple["Ugrid2d", Union[BoolArray, slice]]]:
         """
-        Create a Ugrid2d topology from a structured topology based on 1D bounds.
+        Create a Ugrid2d topology from a structured topology based on 2D or 3D
+        bounds.
 
-        The bounds contain the lower and upper cell boundary for each cell.
+        The bounds contain the lower and upper cell boundary for each cell for
+        2D, and the four corner vertices in case of 3D bounds. The order of the
+        corners in bounds_x and bounds_y must be consistent with each other,
+        but may be arbitrary: this method ensures counterclockwise orientation
+        for UGRID. Inactive cells are assumed to be marked with one or more NaN
+        values for their corner coordinates. These coordinates are discarded
+        and the cells are marked in the optionally returned index.
 
         Parameters
         ----------
-        x_bounds: np.ndarray of shape (M, 2)
-            x-coordinate bounds for N row and M columns.
-        y_bounds: np.ndarray of shape (N, 2)
-            y-coordinate bounds for N row and M columns.
+        x_bounds: np.ndarray of shape (M, 2) or (N, M, 4).
+            x-coordinate bounds for N rows and M columns.
+        y_bounds: np.ndarray of shape (N, 2) or (N, M, 4).
+            y-coordinate bounds for N rows and M columns.
         name: str
+        return_index: bool, default is False.
 
         Returns
         -------
         grid: Ugrid2d
+        index: np.ndarray of bool | slice
+            Indicates which cells are part of the Ugrid2d topology.
+            Provided if ``return_index`` is True.
         """
-        nx, _ = x_bounds.shape
-        ny, _ = y_bounds.shape
-        x = conversion.bounds_to_vertices(x_bounds)
-        y = conversion.bounds_to_vertices(y_bounds)
-        node_y, node_x = (a.ravel() for a in np.meshgrid(y, x, indexing="ij"))
-        return Ugrid2d._from_intervals_helper(node_x, node_y, nx, ny, name)
+ x_shape = x_bounds.shape + y_shape = y_bounds.shape + ndim = x_bounds.ndim + if ndim == 2: + nx, _ = x_shape + ny, _ = y_shape + x = conversion.bounds1d_to_vertices(x_bounds) + y = conversion.bounds1d_to_vertices(y_bounds) + node_y, node_x = (a.ravel() for a in np.meshgrid(y, x, indexing="ij")) + grid = Ugrid2d._from_intervals_helper(node_x, node_y, nx, ny, name) + index = slice(None, None) + elif ndim == 3: + if x_shape != y_shape: + raise ValueError( + f"Bounds shapes do not match: {x_shape} versus {y_shape}" + ) + x, y, face_node_connectivity, index = conversion.bounds2d_to_topology2d( + x_bounds, y_bounds + ) + grid = Ugrid2d(x, y, -1, face_node_connectivity, name=name) + else: + raise ValueError(f"Expected 2 or 3 dimensions on bounds, received: {ndim}") + + if return_index: + return grid, index + else: + return grid
@staticmethod diff --git a/_sources/api.rst.txt b/_sources/api.rst.txt index be9e2df9e..c6a7924a5 100644 --- a/_sources/api.rst.txt +++ b/_sources/api.rst.txt @@ -43,7 +43,7 @@ UgridDataArray UgridDataArray UgridDataArray.ugrid - UgridDataArray.from_structured + UgridDataArray.from_structured2d UgridDataArray.from_data UgridDataset @@ -55,7 +55,7 @@ UgridDataset UgridDataset UgridDataset.ugrid UgridDataset.from_geodataframe - UgridDataset.from_structured + UgridDataset.from_structured2d UGRID Accessor -------------- diff --git a/_sources/api/xugrid.UgridDataArray.from_structured.rst.txt b/_sources/api/xugrid.UgridDataArray.from_structured.rst.txt deleted file mode 100644 index cfdb5ca79..000000000 --- a/_sources/api/xugrid.UgridDataArray.from_structured.rst.txt +++ /dev/null @@ -1,6 +0,0 @@ -xugrid.UgridDataArray.from\_structured -====================================== - -.. currentmodule:: xugrid - -.. automethod:: UgridDataArray.from_structured \ No newline at end of file diff --git a/_sources/api/xugrid.UgridDataArray.from_structured2d.rst.txt b/_sources/api/xugrid.UgridDataArray.from_structured2d.rst.txt new file mode 100644 index 000000000..a1b6dd13a --- /dev/null +++ b/_sources/api/xugrid.UgridDataArray.from_structured2d.rst.txt @@ -0,0 +1,6 @@ +xugrid.UgridDataArray.from\_structured2d +======================================== + +.. currentmodule:: xugrid + +.. automethod:: UgridDataArray.from_structured2d \ No newline at end of file diff --git a/_sources/api/xugrid.UgridDataArray.rst.txt b/_sources/api/xugrid.UgridDataArray.rst.txt index 415ccad6d..bd92a81a1 100644 --- a/_sources/api/xugrid.UgridDataArray.rst.txt +++ b/_sources/api/xugrid.UgridDataArray.rst.txt @@ -63,6 +63,7 @@ ~UgridDataArray.from_iris ~UgridDataArray.from_series ~UgridDataArray.from_structured + ~UgridDataArray.from_structured2d ~UgridDataArray.get_axis_num ~UgridDataArray.get_index ~UgridDataArray.groupby diff --git a/_sources/api/xugrid.UgridDataset.from_structured.rst.txt b/_sources/api/xugrid.UgridDataset.from_structured.rst.txt deleted file mode 100644 index d0c6fd972..000000000 --- a/_sources/api/xugrid.UgridDataset.from_structured.rst.txt +++ /dev/null @@ -1,6 +0,0 @@ -xugrid.UgridDataset.from\_structured -==================================== - -.. currentmodule:: xugrid - -.. automethod:: UgridDataset.from_structured \ No newline at end of file diff --git a/_sources/api/xugrid.UgridDataset.from_structured2d.rst.txt b/_sources/api/xugrid.UgridDataset.from_structured2d.rst.txt new file mode 100644 index 000000000..01af5d9a6 --- /dev/null +++ b/_sources/api/xugrid.UgridDataset.from_structured2d.rst.txt @@ -0,0 +1,6 @@ +xugrid.UgridDataset.from\_structured2d +====================================== + +.. currentmodule:: xugrid + +.. automethod:: UgridDataset.from_structured2d \ No newline at end of file diff --git a/_sources/api/xugrid.UgridDataset.rst.txt b/_sources/api/xugrid.UgridDataset.rst.txt index c95af50e1..506fbf1ef 100644 --- a/_sources/api/xugrid.UgridDataset.rst.txt +++ b/_sources/api/xugrid.UgridDataset.rst.txt @@ -67,6 +67,7 @@ ~UgridDataset.from_dict ~UgridDataset.from_geodataframe ~UgridDataset.from_structured + ~UgridDataset.from_structured2d ~UgridDataset.get ~UgridDataset.get_index ~UgridDataset.groupby diff --git a/_sources/changelog.rst.txt b/_sources/changelog.rst.txt index 5199a67d8..43aeb216b 100644 --- a/_sources/changelog.rst.txt +++ b/_sources/changelog.rst.txt @@ -9,6 +9,29 @@ The format is based on `Keep a Changelog`_, and this project adheres to Unreleased ---------- +Changed +~~~~~~~ + +- :meth:`xugrid.UgridDataset.from_structured` and + :meth:`xugrid.UgridDataArray.from_structured` are deprecated and will be + removed in the future; calling them will raise a FutureWarning. They have + been replaced by :meth:`xugrid.UgridDataset.from_structured2d` and + :meth:`xugrid.UgridDataArray.from_structured2d` respectively. + +Added +~~~~~ + +- :meth:`xugrid.Ugrid2d.from_structured_bounds` now accepts 3D bounds to allow + conversion of grids with non-monotonic x and y coordinates, such as strongly + curvilinear grids. +- :meth:`xugrid.Ugrid2d.from_structured_bounds` now takes an optional + ``return_index`` argument to return the indices of invalid grid faces, + identified by one or more NaNs in its bounds. +- This method is used in :meth:`xugrid.UgridDataArray.from_structured2d` and + :meth:`xugrid.UgridDataset.from_structured2d` when the optional arguments + ``x_bounds`` and ``y_bounds`` are provided. + + [0.12.2] 2025-01-31 ------------------- diff --git a/_sources/examples-dev/sg_execution_times.rst.txt b/_sources/examples-dev/sg_execution_times.rst.txt index 6e0cc882f..8655d5e36 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.367** total execution time for 1 file **from examples-dev**: +**00:01.334** 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.367 + - 00:01.334 - 0.0 diff --git a/_sources/examples-dev/voronoi.rst.txt b/_sources/examples-dev/voronoi.rst.txt index 39a9b3796..52412ea8c 100644 --- a/_sources/examples-dev/voronoi.rst.txt +++ b/_sources/examples-dev/voronoi.rst.txt @@ -666,7 +666,7 @@ The figure shows: .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 1.367 seconds) + **Total running time of the script:** (0 minutes 1.334 seconds) .. _sphx_glr_download_examples-dev_voronoi.py: diff --git a/_sources/examples/connectivity.rst.txt b/_sources/examples/connectivity.rst.txt index f38590207..2a690ed6f 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.432 seconds) + **Total running time of the script:** (0 minutes 1.426 seconds) .. _sphx_glr_download_examples_connectivity.py: diff --git a/_sources/examples/overlap_regridder.rst.txt b/_sources/examples/overlap_regridder.rst.txt index 60db537f3..e64456deb 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 3.795 seconds) + **Total running time of the script:** (0 minutes 3.835 seconds) .. _sphx_glr_download_examples_overlap_regridder.py: diff --git a/_sources/examples/partitioning.rst.txt b/_sources/examples/partitioning.rst.txt index 3c5f55cfe..1ff4df2e3 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 - + @@ -674,7 +674,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


@@ -1080,9 +1080,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

@@ -1491,9 +1491,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

@@ -1510,7 +1510,7 @@ partitions. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 3.887 seconds) + **Total running time of the script:** (0 minutes 3.847 seconds) .. _sphx_glr_download_examples_partitioning.py: diff --git a/_sources/examples/plotting.rst.txt b/_sources/examples/plotting.rst.txt index b1cb0a7a9..708902171 100644 --- a/_sources/examples/plotting.rst.txt +++ b/_sources/examples/plotting.rst.txt @@ -457,13 +457,13 @@ faces.
<xarray.Dataset> Size: 19kB
     Dimensions:        (mesh2d_nNodes: 217, mesh2d_nFaces: 384, mesh2d_nEdges: 600)
     Coordinates:
-      * 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
+      * 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
     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


  • @@ -618,7 +618,7 @@ Dataset and calling the :py:meth:`UgridDataArray.ugrid.plot()` method. .. code-block:: none - + @@ -653,7 +653,7 @@ the edges results in a different kind of plot: .. code-block:: none - + @@ -695,7 +695,7 @@ We can put them side by side to illustrate the differences: .. code-block:: none - + @@ -725,7 +725,7 @@ filled contours for data associated with the face dimension: .. code-block:: none - + @@ -756,7 +756,7 @@ We can also overlay this data with the edges: .. code-block:: none - + @@ -831,7 +831,7 @@ All these (2D) plots are illustrated here for completeness' sake: .. code-block:: none - + @@ -864,7 +864,7 @@ The ``surface`` methods generate 3D surface plots: .. code-block:: none - + @@ -898,7 +898,7 @@ used: .. code-block:: none - + @@ -934,7 +934,7 @@ take an xarray DataArray and a xugrid grid as arguments. .. code-block:: none - + @@ -970,14 +970,14 @@ somewhere in the unstructured topology, and plot the resulting timeseries: .. code-block:: none - [] + [] .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 13.953 seconds) + **Total running time of the script:** (0 minutes 14.170 seconds) .. _sphx_glr_download_examples_plotting.py: diff --git a/_sources/examples/quick_overview.rst.txt b/_sources/examples/quick_overview.rst.txt index 9e6056c7d..29e3529ee 100644 --- a/_sources/examples/quick_overview.rst.txt +++ b/_sources/examples/quick_overview.rst.txt @@ -471,7 +471,7 @@ We'll start by fetching a dataset: elevation (node) float64 73kB ... depth (time, node) float64 4MB ... mesh2d int32 4B ... - face_node_connectivity (face, nmax_face) float64 405kB ...


  • @@ -933,7 +933,7 @@ separate the variables: * node (node) int64 73kB 0 1 2 3 4 5 6 ... 9134 9135 9136 9137 9138 9139 Data variables: elevation (node) float64 73kB ... - depth (time, node) float64 4MB ...


  • @@ -1382,7 +1382,7 @@ We can then grab one of the data variables as usual for xarray: Coordinates: node_x (node) float64 73kB ... node_y (node) float64 73kB ... - * node (node) int64 73kB 0 1 2 3 4 5 6 ... 9134 9135 9136 9137 9138 9139 + * node (node) int64 73kB 0 1 2 3 4 5 6 ... 9134 9135 9136 9137 9138 9139

    @@ -1799,7 +1799,7 @@ some data by hand here:
    <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

    @@ -1837,7 +1837,7 @@ Plotting .. code-block:: none - + @@ -1888,7 +1888,7 @@ To select based on the topology, use the ``.ugrid`` attribute: .. code-block:: none - + @@ -2293,7 +2293,7 @@ Computation on DataArrays is unchanged from xarray:
    <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

    @@ -2762,7 +2762,7 @@ Conversion from Geopandas is easy too: Coordinates: * mesh2d_nFaces (mesh2d_nFaces) int64 16B 0 1 Data variables: - test (mesh2d_nFaces) float64 16B 1.0 2.0 + test (mesh2d_nFaces) float64 16B 1.0 2.0

    @@ -3165,13 +3165,13 @@ grid (nodes, faces, edges).
    <xarray.Dataset> Size: 19kB
         Dimensions:        (mesh2d_nNodes: 217, mesh2d_nFaces: 384, mesh2d_nEdges: 600)
         Coordinates:
    -      * 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
    +      * 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
         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
    • mesh2d_nEdges
      PandasIndex
      PandasIndex(RangeIndex(start=0, stop=600, step=1, name='mesh2d_nEdges'))
    • mesh2d_nFaces
      PandasIndex
      PandasIndex(RangeIndex(start=0, stop=384, step=1, name='mesh2d_nFaces'))
    • mesh2d_nNodes
      PandasIndex
      PandasIndex(RangeIndex(start=0, stop=217, step=1, name='mesh2d_nNodes'))


  • @@ -3690,7 +3690,7 @@ a grid object:
    <xarray.Dataset> Size: 0B
         Dimensions:  ()
         Data variables:
    -        *empty*
    + *empty*

    @@ -4092,7 +4092,7 @@ We can then add variables one-by-one, as we might with an xarray Dataset: node_y (node) float64 73kB ... * node (node) int64 73kB 0 1 2 3 4 5 6 ... 9134 9135 9136 9137 9138 9139 Data variables: - elevation (node) float64 73kB ... + elevation (node) float64 73kB ...

    @@ -4504,7 +4504,7 @@ before writing. elevation (node) float64 73kB ... depth (time, node) float64 4MB ... Attributes: - Conventions: CF-1.9 UGRID-1.0
  • Conventions :
    CF-1.9 UGRID-1.0


  • @@ -4565,7 +4565,7 @@ before writing. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 0.569 seconds) + **Total running time of the script:** (0 minutes 0.562 seconds) .. _sphx_glr_download_examples_quick_overview.py: diff --git a/_sources/examples/regridder_overview.rst.txt b/_sources/examples/regridder_overview.rst.txt index 2a71708f8..95344de7a 100644 --- a/_sources/examples/regridder_overview.rst.txt +++ b/_sources/examples/regridder_overview.rst.txt @@ -79,7 +79,7 @@ elevation of the Netherlands. .. code-block:: none - + @@ -151,7 +151,7 @@ the centroids of the new grid fall. .. code-block:: none - + @@ -182,7 +182,7 @@ Xugrid provides the CentroidLocatorRegridder for this: .. code-block:: none - + @@ -217,7 +217,7 @@ so large. Let's try the OverlapOverregridder instead. .. code-block:: none - + @@ -249,7 +249,7 @@ Let's try again, now with the minimum: .. code-block:: none - + @@ -280,7 +280,7 @@ Or the maximum: .. code-block:: none - + @@ -716,7 +716,7 @@ result. mesh2d_face_x (mesh2d_nFaces) float64 42kB ... mesh2d_face_y (mesh2d_nFaces) float64 42kB ... * layer (layer) int64 40B 1 2 3 4 5 - * mesh2d_nFaces (mesh2d_nFaces) int64 42kB 0 1 2 3 4 ... 5244 5245 5246 5247
    • mesh2d_face_x
      (mesh2d_nFaces)
      float64
      ...
      standard_name :
      projection_x_coordinate
      [5248 values with dtype=float64]
    • mesh2d_face_y
      (mesh2d_nFaces)
      float64
      ...
      standard_name :
      projection_y_coordinate
      [5248 values with dtype=float64]
    • layer
      (layer)
      int64
      1 2 3 4 5
      array([1, 2, 3, 4, 5])
    • mesh2d_nFaces
      (mesh2d_nFaces)
      int64
      0 1 2 3 4 ... 5244 5245 5246 5247
      array([   0,    1,    2, ..., 5245, 5246, 5247])
    • layer
      PandasIndex
      PandasIndex(Index([1, 2, 3, 4, 5], dtype='int64', name='layer'))
    • mesh2d_nFaces
      PandasIndex
      PandasIndex(RangeIndex(start=0, stop=5248, step=1, name='mesh2d_nFaces'))


  • @@ -1165,7 +1165,7 @@ all additional dimensions. -45.92794405, -39.50867478]]) Coordinates: * layer (layer) int64 40B 1 2 3 4 5 - * mesh2d_nFaces (mesh2d_nFaces) int64 784B 0 1 2 3 4 5 ... 92 93 94 95 96 97
    • layer
      PandasIndex
      PandasIndex(Index([1, 2, 3, 4, 5], dtype='int64', name='layer'))
    • mesh2d_nFaces
      PandasIndex
      PandasIndex(RangeIndex(start=0, stop=98, step=1, name='mesh2d_nFaces'))


  • @@ -1247,7 +1247,7 @@ and the aggregated mean. .. code-block:: none - [, , , , ] + [, , , , ] @@ -1284,7 +1284,7 @@ To illustrate, we will zoom in to a part of the Netherlands. .. code-block:: none - + @@ -1337,7 +1337,7 @@ the triangles. .. code-block:: none - + @@ -1378,7 +1378,7 @@ the regridders work for any collection of (convex) faces. .. code-block:: none - + @@ -1414,7 +1414,7 @@ is kept the same. .. code-block:: none - + @@ -1430,7 +1430,7 @@ is kept the same. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 9.372 seconds) + **Total running time of the script:** (0 minutes 9.549 seconds) .. _sphx_glr_download_examples_regridder_overview.py: diff --git a/_sources/examples/selection.rst.txt b/_sources/examples/selection.rst.txt index db882f035..554eb15b0 100644 --- a/_sources/examples/selection.rst.txt +++ b/_sources/examples/selection.rst.txt @@ -85,7 +85,7 @@ elevation of the Netherlands. .. code-block:: none - + @@ -130,7 +130,7 @@ A subset of the unstructured grid is returned by using slices without a step: .. code-block:: none - + @@ -161,7 +161,7 @@ In such a case the entire grid is returned. .. code-block:: none - + @@ -196,7 +196,7 @@ This means we can easily select along a single dimension: .. code-block:: none - + @@ -226,7 +226,7 @@ Or, using ``None`` if we only care about the start: .. code-block:: none - + @@ -667,7 +667,7 @@ Two values will select a point: mesh2d_x (mesh2d_nFaces) float64 8B 1.5e+05 mesh2d_y (mesh2d_nFaces) float64 8B 4.63e+05 Attributes: - unit: m NAP + unit: m NAP

    @@ -1080,7 +1080,7 @@ of six points: mesh2d_x (mesh2d_nFaces) float64 48B 1.25e+05 1.5e+05 ... 1.75e+05 mesh2d_y (mesh2d_nFaces) float64 48B 4e+05 4e+05 ... 4.65e+05 4.65e+05 Attributes: - unit: m NAP + unit: m NAP

    @@ -1493,7 +1493,7 @@ To select points without broadcasting, use ``.ugrid.sel_points`` instead: mesh2d_x (mesh2d_nFaces) float64 24B 1.25e+05 1.5e+05 1.75e+05 mesh2d_y (mesh2d_nFaces) float64 24B 4e+05 4.3e+05 4.65e+05 Attributes: - unit: m NAP + unit: m NAP

    @@ -1904,9 +1904,9 @@ We can sample points along a line as well by providing slices **with** a step: mesh2d_x (mesh2d_nFaces) float64 80B 1e+05 1.1e+05 ... 1.8e+05 1.9e+05 mesh2d_y (mesh2d_nFaces) float64 80B 4.65e+05 4.65e+05 ... 4.65e+05 Attributes: - unit: m NAP + unit: m NAP

    @@ -2319,7 +2319,7 @@ Two slices with a step results in broadcasting: mesh2d_x (mesh2d_nFaces) float64 800B 1e+05 1.1e+05 ... 1.9e+05 mesh2d_y (mesh2d_nFaces) float64 800B 4e+05 4e+05 ... 4.9e+05 4.9e+05 Attributes: - unit: m NAP
  • unit :
    m NAP


  • @@ -2780,15 +2780,15 @@ As well as a slice with a step and multiple values: mesh2d_x (mesh2d_nFaces) float64 160B 1e+05 1.1e+05 ... 1.9e+05 mesh2d_y (mesh2d_nFaces) float64 160B 4e+05 4e+05 ... 4.3e+05 4.3e+05 Attributes: - unit: m NAP
  • unit :
    m NAP


  • @@ -2972,7 +2972,7 @@ thousands faces: .. code-block:: none - + @@ -2994,7 +2994,7 @@ face dimension for 2D topologies. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 3.634 seconds) + **Total running time of the script:** (0 minutes 3.597 seconds) .. _sphx_glr_download_examples_selection.py: diff --git a/_sources/examples/sg_execution_times.rst.txt b/_sources/examples/sg_execution_times.rst.txt index 0e4f7a5d4..7389557cc 100644 --- a/_sources/examples/sg_execution_times.rst.txt +++ b/_sources/examples/sg_execution_times.rst.txt @@ -6,7 +6,7 @@ Computation times ================= -**00:50.260** total execution time for 8 files **from examples**: +**00:50.817** total execution time for 8 files **from examples**: .. container:: @@ -33,26 +33,26 @@ Computation times - Time - Mem (MB) * - :ref:`sphx_glr_examples_plotting.py` (``plotting.py``) - - 00:13.953 + - 00:14.170 - 0.0 * - :ref:`sphx_glr_examples_vector_conversion.py` (``vector_conversion.py``) - - 00:13.618 + - 00:13.831 - 0.0 * - :ref:`sphx_glr_examples_regridder_overview.py` (``regridder_overview.py``) - - 00:09.372 + - 00:09.549 - 0.0 * - :ref:`sphx_glr_examples_partitioning.py` (``partitioning.py``) - - 00:03.887 + - 00:03.847 - 0.0 * - :ref:`sphx_glr_examples_overlap_regridder.py` (``overlap_regridder.py``) - - 00:03.795 + - 00:03.835 - 0.0 * - :ref:`sphx_glr_examples_selection.py` (``selection.py``) - - 00:03.634 + - 00:03.597 - 0.0 * - :ref:`sphx_glr_examples_connectivity.py` (``connectivity.py``) - - 00:01.432 + - 00:01.426 - 0.0 * - :ref:`sphx_glr_examples_quick_overview.py` (``quick_overview.py``) - - 00:00.569 + - 00:00.562 - 0.0 diff --git a/_sources/examples/vector_conversion.rst.txt b/_sources/examples/vector_conversion.rst.txt index 201aedd91..56716d7cc 100644 --- a/_sources/examples/vector_conversion.rst.txt +++ b/_sources/examples/vector_conversion.rst.txt @@ -73,7 +73,7 @@ We'll once again use the surface elevation data example. .. code-block:: none - + @@ -525,9 +525,9 @@ GeoDataFrame. Data variables: elevation (mesh2d_nFaces) float32 21kB 1.17 9.81 54.04 ... -15.83 -0.45 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_face_y (mesh2d_nFaces) float64 42kB 3.648e+05 ... 3.964e+05

    @@ -589,7 +589,7 @@ burn into the grid. .. code-block:: none - + @@ -992,9 +992,9 @@ we want to compute the average surface elevation per province: Coordinates: * id (id) float64 96B 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 Attributes: - unit: m NAP
    • id
      (id)
      float64
      0.0 1.0 2.0 3.0 ... 9.0 10.0 11.0
      array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11.])
    • id
      PandasIndex
      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'))
  • unit :
    m NAP


  • @@ -1101,7 +1101,7 @@ We can also use such "masks" to e.g. modify specific parts of the grid data: .. code-block:: none - + @@ -1247,7 +1247,7 @@ burn operation. .. code-block:: none - + @@ -1356,7 +1356,7 @@ compare to the grid faces. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 13.618 seconds) + **Total running time of the script:** (0 minutes 13.831 seconds) .. _sphx_glr_download_examples_vector_conversion.py: diff --git a/_sources/sample_data/adh_san_diego.rst.txt b/_sources/sample_data/adh_san_diego.rst.txt index 8c743064f..d2245ded7 100644 --- a/_sources/sample_data/adh_san_diego.rst.txt +++ b/_sources/sample_data/adh_san_diego.rst.txt @@ -41,7 +41,7 @@ It contains a static dataset (bed elevation) and a time varying dataset .. code-block:: none - + @@ -71,7 +71,7 @@ It contains a static dataset (bed elevation) and a time varying dataset .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 0.365 seconds) + **Total running time of the script:** (0 minutes 0.372 seconds) .. _sphx_glr_download_sample_data_adh_san_diego.py: diff --git a/_sources/sample_data/disk.rst.txt b/_sources/sample_data/disk.rst.txt index 0939a546c..545349d25 100644 --- a/_sources/sample_data/disk.rst.txt +++ b/_sources/sample_data/disk.rst.txt @@ -39,7 +39,7 @@ of a disk. It contains data on the nodes, faces, and edges. .. code-block:: none - + diff --git a/_sources/sample_data/elevation_nl.rst.txt b/_sources/sample_data/elevation_nl.rst.txt index 53bc9d89e..6b664db42 100644 --- a/_sources/sample_data/elevation_nl.rst.txt +++ b/_sources/sample_data/elevation_nl.rst.txt @@ -39,7 +39,7 @@ of the Netherlands. .. code-block:: none - [] + [] @@ -67,7 +67,7 @@ of the Netherlands. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 0.748 seconds) + **Total running time of the script:** (0 minutes 0.753 seconds) .. _sphx_glr_download_sample_data_elevation_nl.py: diff --git a/_sources/sample_data/provinces_nl.rst.txt b/_sources/sample_data/provinces_nl.rst.txt index d2c23d6d5..54fe2c93d 100644 --- a/_sources/sample_data/provinces_nl.rst.txt +++ b/_sources/sample_data/provinces_nl.rst.txt @@ -58,7 +58,7 @@ Netherlands, including water, presented as geopandas GeoDataFrame. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 0.064 seconds) + **Total running time of the script:** (0 minutes 0.066 seconds) .. _sphx_glr_download_sample_data_provinces_nl.py: diff --git a/_sources/sample_data/sg_execution_times.rst.txt b/_sources/sample_data/sg_execution_times.rst.txt index 7d371eaba..6f747dd51 100644 --- a/_sources/sample_data/sg_execution_times.rst.txt +++ b/_sources/sample_data/sg_execution_times.rst.txt @@ -6,7 +6,7 @@ Computation times ================= -**00:01.377** total execution time for 5 files **from sample_data**: +**00:01.392** total execution time for 5 files **from sample_data**: .. container:: @@ -33,17 +33,17 @@ Computation times - Time - Mem (MB) * - :ref:`sphx_glr_sample_data_elevation_nl.py` (``elevation_nl.py``) - - 00:00.748 + - 00:00.753 - 0.0 * - :ref:`sphx_glr_sample_data_adh_san_diego.py` (``adh_san_diego.py``) - - 00:00.365 + - 00:00.372 - 0.0 * - :ref:`sphx_glr_sample_data_disk.py` (``disk.py``) - 00:00.144 - 0.0 * - :ref:`sphx_glr_sample_data_provinces_nl.py` (``provinces_nl.py``) - - 00:00.064 + - 00:00.066 - 0.0 * - :ref:`sphx_glr_sample_data_xoxo.py` (``xoxo.py``) - - 00:00.055 + - 00:00.056 - 0.0 diff --git a/_sources/sample_data/xoxo.rst.txt b/_sources/sample_data/xoxo.rst.txt index b7f07c183..f6cd145f0 100644 --- a/_sources/sample_data/xoxo.rst.txt +++ b/_sources/sample_data/xoxo.rst.txt @@ -55,7 +55,7 @@ directory if it's not there already. .. rst-class:: sphx-glr-timing - **Total running time of the script:** (0 minutes 0.055 seconds) + **Total running time of the script:** (0 minutes 0.056 seconds) .. _sphx_glr_download_sample_data_xoxo.py: diff --git a/_sources/sg_execution_times.rst.txt b/_sources/sg_execution_times.rst.txt index a98c2e76f..ac28c0503 100644 --- a/_sources/sg_execution_times.rst.txt +++ b/_sources/sg_execution_times.rst.txt @@ -6,7 +6,7 @@ Computation times ================= -**00:53.004** total execution time for 14 files **from all galleries**: +**00:53.543** total execution time for 14 files **from all galleries**: .. container:: @@ -33,44 +33,44 @@ Computation times - Time - Mem (MB) * - :ref:`sphx_glr_examples_plotting.py` (``../examples/plotting.py``) - - 00:13.953 + - 00:14.170 - 0.0 * - :ref:`sphx_glr_examples_vector_conversion.py` (``../examples/vector_conversion.py``) - - 00:13.618 + - 00:13.831 - 0.0 * - :ref:`sphx_glr_examples_regridder_overview.py` (``../examples/regridder_overview.py``) - - 00:09.372 + - 00:09.549 - 0.0 * - :ref:`sphx_glr_examples_partitioning.py` (``../examples/partitioning.py``) - - 00:03.887 + - 00:03.847 - 0.0 * - :ref:`sphx_glr_examples_overlap_regridder.py` (``../examples/overlap_regridder.py``) - - 00:03.795 + - 00:03.835 - 0.0 * - :ref:`sphx_glr_examples_selection.py` (``../examples/selection.py``) - - 00:03.634 + - 00:03.597 - 0.0 * - :ref:`sphx_glr_examples_connectivity.py` (``../examples/connectivity.py``) - - 00:01.432 + - 00:01.426 - 0.0 * - :ref:`sphx_glr_examples-dev_voronoi.py` (``../examples-dev/voronoi.py``) - - 00:01.367 + - 00:01.334 - 0.0 * - :ref:`sphx_glr_sample_data_elevation_nl.py` (``../data/examples/elevation_nl.py``) - - 00:00.748 + - 00:00.753 - 0.0 * - :ref:`sphx_glr_examples_quick_overview.py` (``../examples/quick_overview.py``) - - 00:00.569 + - 00:00.562 - 0.0 * - :ref:`sphx_glr_sample_data_adh_san_diego.py` (``../data/examples/adh_san_diego.py``) - - 00:00.365 + - 00:00.372 - 0.0 * - :ref:`sphx_glr_sample_data_disk.py` (``../data/examples/disk.py``) - 00:00.144 - 0.0 * - :ref:`sphx_glr_sample_data_provinces_nl.py` (``../data/examples/provinces_nl.py``) - - 00:00.064 + - 00:00.066 - 0.0 * - :ref:`sphx_glr_sample_data_xoxo.py` (``../data/examples/xoxo.py``) - - 00:00.055 + - 00:00.056 - 0.0 diff --git a/api.html b/api.html index 05f4035e9..897d8f9b7 100644 --- a/api.html +++ b/api.html @@ -350,14 +350,14 @@