+[docs]@staticmethod
- deffrom_structured(
+ deffrom_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
+ ... ) """ifda.ndim<2:raiseValueError("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")
+ ifx_boundsisnotNoneandy_boundsisnotNone:
+ ifxisNoneoryisNone:
+ raiseValueError("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")
+ )returnUgridDataArray(face_da,grid)
+ @staticmethod
+ deffrom_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,
+ )
+ returnUgridDataArray.from_structured2d(da,x,y,x_bounds,y_bounds)
+
+[docs]@staticmethod
- deffrom_structured(
+ deffrom_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"
+ ... }
+ ... }
+ ... ) """iftopologyisNone:
+ # By default, set None. This communicates to
+ # Ugrid2d.from_structured to infer x and y dims.topology={"mesh2d":(None,None)}grids=[]dss=[]
- forname,(x,y)intopology.items():
- grid,stackdims=Ugrid2d.from_structured(
- dataset,x=x,y=y,name=name,return_dims=True
- )
+ forname,argsintopology.items():
+ x_bounds=None
+ y_bounds=None
+ ifisinstance(args,dict):
+ x=args.get("x")
+ y=args.get("y")
+ if"x_bounds"inargsand"y_bounds"inargs:
+ ifxisNoneoryisNone:
+ raiseValueError("x and y must be provided for bounds")
+ x_bounds=dataset[args["x_bounds"]]
+ y_bounds=dataset[args["y_bounds"]]
+ elifisinstance(args,tuple):
+ x,y=args
+ else:
+ raiseTypeError(
+ "Expected dict or tuple in topology, received: "
+ f"{type(args).__name__}"
+ )
+
+ ifx_boundsisnotNoneandy_boundsisnotNone:
+ 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")returnUgridDataset(merged,grids)
-
+
+
+ @staticmethod
+ deffrom_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,
+ )
+ returnUgridDataset.from_structured2d(dataset,topology)
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()forainnp.meshgrid(y,x,indexing="ij"))
- returnUgrid2d._from_intervals_helper(node_x,node_y,nx,ny,name)
@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!
@@ -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 ...
@@ -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:
@@ -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
@@ -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
@@ -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
@@ -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
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 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.
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.
Create a UgridDataArray from a (structured) xarray DataArray.
-
get_axis_num(dim)
+
get_axis_num(dim)
Return axis number(s) corresponding to dimension(s) in this array.
-
get_index(key)
+
get_index(key)
Get an index for a dimension, with fall-back to a default RangeIndex
-
groupby([group, squeeze, ...])
+
groupby([group, squeeze, ...])
Returns a DataArrayGroupBy object for performing grouped operations.
-
groupby_bins(group, bins[, right, labels, ...])
+
groupby_bins(group, bins[, right, labels, ...])
Returns a DataArrayGroupBy object for performing grouped operations.
-
head([indexers])
+
head([indexers])
Return a new DataArray whose data is given by the the first n values along the specified dimension(s).
-
identical(other)
+
identical(other)
Like equals, but also checks the array name and attributes, and attributes on all coordinates.
-
idxmax([dim, skipna, fill_value, keep_attrs])
+
idxmax([dim, skipna, fill_value, keep_attrs])
Return the coordinate label of the maximum value along a dimension.
-
idxmin([dim, skipna, fill_value, keep_attrs])
+
idxmin([dim, skipna, fill_value, keep_attrs])
Return the coordinate label of the minimum value along a dimension.
-
integrate([coord, datetime_unit])
+
integrate([coord, datetime_unit])
Integrate along the given coordinate using the trapezoidal rule.
-
interp([coords, method, assume_sorted, kwargs])
+
interp([coords, method, assume_sorted, kwargs])
Interpolate a DataArray onto new coordinates.
-
interp_calendar(target[, dim])
+
interp_calendar(target[, dim])
Interpolates the DataArray to another calendar based on decimal year measure.
-
interp_like(other[, method, assume_sorted, ...])
+
interp_like(other[, method, assume_sorted, ...])
Interpolate this object onto the coordinates of another object, filling out of range values with NaN.
-
interpolate_na([dim, method, limit, ...])
+
interpolate_na([dim, method, limit, ...])
Fill in NaNs by interpolating according to different methods.
-
isel([indexers, drop, missing_dims])
+
isel([indexers, drop, missing_dims])
Return a new DataArray whose data is given by selecting indexes along the specified dimension(s).
-
isin(test_elements)
+
isin(test_elements)
Tests each value in the array for whether it is in test elements.
-
isnull([keep_attrs])
+
isnull([keep_attrs])
Test each value in the array for whether it is a missing value.
-
item(*args)
+
item(*args)
Copy an element of an array to a standard Python scalar and return it.
-
load(**kwargs)
+
load(**kwargs)
Manually trigger loading of this array's data from disk or a remote source into memory and return this array.
-
map_blocks(func[, args, kwargs, template])
+
map_blocks(func[, args, kwargs, template])
Apply a function to each block of this DataArray.
-
max([dim, skipna, keep_attrs])
+
max([dim, skipna, keep_attrs])
Reduce this DataArray's data by applying max along some dimension(s).
-
mean([dim, skipna, keep_attrs])
+
mean([dim, skipna, keep_attrs])
Reduce this DataArray's data by applying mean along some dimension(s).
-
median([dim, skipna, keep_attrs])
+
median([dim, skipna, keep_attrs])
Reduce this DataArray's data by applying median along some dimension(s).
-
min([dim, skipna, keep_attrs])
+
min([dim, skipna, keep_attrs])
Reduce this DataArray's data by applying min along some dimension(s).
-
notnull([keep_attrs])
+
notnull([keep_attrs])
Test each value in the array for whether it is not a missing value.
-
pad([pad_width, mode, stat_length, ...])
+
pad([pad_width, mode, stat_length, ...])
Pad this array along one or more dimensions.
-
persist(**kwargs)
+
persist(**kwargs)
Trigger computation in constituent dask arrays
-
pipe(func, *args, **kwargs)
+
pipe(func, *args, **kwargs)
Apply func(self,*args,**kwargs)
-
polyfit(dim, deg[, skipna, rcond, w, full, cov])
+
polyfit(dim, deg[, skipna, rcond, w, full, cov])
Least squares polynomial fit.
-
prod([dim, skipna, min_count, keep_attrs])
+
prod([dim, skipna, min_count, keep_attrs])
Reduce this DataArray's data by applying prod along some dimension(s).
-
quantile(q[, dim, method, keep_attrs, ...])
+
quantile(q[, dim, method, keep_attrs, ...])
Compute the qth quantile of the data along the specified dimension.
-
query([queries, parser, engine, missing_dims])
+
query([queries, parser, engine, missing_dims])
Return a new data array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the values in the array.
-
rank(dim, *[, pct, keep_attrs])
+
rank(dim, *[, pct, keep_attrs])
Ranks the data.
-
reduce(func[, dim, axis, keep_attrs, keepdims])
+
reduce(func[, dim, axis, keep_attrs, keepdims])
Reduce this array by applying func along some dimension(s).
-
reindex([indexers, method, tolerance, copy, ...])
+
reindex([indexers, method, tolerance, copy, ...])
Conform this object onto the indexes of another object, filling in missing values with fill_value.
-
reindex_like(other, *[, method, tolerance, ...])
+
reindex_like(other, *[, method, tolerance, ...])
Conform this object onto the indexes of another object, for indexes which the objects share.
-
rename([new_name_or_name_dict])
+
rename([new_name_or_name_dict])
Returns a new DataArray with renamed coordinates, dimensions or a new name.
-
reorder_levels([dim_order])
+
reorder_levels([dim_order])
Rearrange index levels using input order.
-
resample([indexer, skipna, closed, label, ...])
+
resample([indexer, skipna, closed, label, ...])
Returns a Resample object for performing resampling operations.
-
reset_coords([names, drop])
+
reset_coords([names, drop])
Given names of coordinates, reset them to become variables.
-
reset_encoding()
+
reset_encoding()
-
reset_index(dims_or_levels[, drop])
+
reset_index(dims_or_levels[, drop])
Reset the specified index(es) or multi-index level(s).
-
roll([shifts, roll_coords])
+
roll([shifts, roll_coords])
Roll this array by an offset along one or more dimensions.
-
rolling([dim, min_periods, center])
+
rolling([dim, min_periods, center])
Rolling window object for DataArrays.
-
rolling_exp([window, window_type])
+
rolling_exp([window, window_type])
Exponentially-weighted moving window.
-
round(*args, **kwargs)
+
round(*args, **kwargs)
-
searchsorted(v[, side, sorter])
+
searchsorted(v[, side, sorter])
Find indices where elements of v should be inserted in a to maintain order.
-
sel([indexers, method, tolerance, drop])
+
sel([indexers, method, tolerance, drop])
Return a new DataArray whose data is given by selecting index labels along the specified dimension(s).
-
set_close(close)
+
set_close(close)
Register the function that releases any resources linked to this object.
-
set_index([indexes, append])
+
set_index([indexes, append])
Set DataArray (multi-)indexes using one or more existing coordinates.
-
set_xindex(coord_names[, index_cls])
+
set_xindex(coord_names[, index_cls])
Set a new, Xarray-compatible index from one or more existing coordinate(s).
-
shift([shifts, fill_value])
+
shift([shifts, fill_value])
Shift this DataArray by an offset along one or more dimensions.
-
sortby(variables[, ascending])
+
sortby(variables[, ascending])
Sort object by labels or values (along an axis).
-
squeeze([dim, drop, axis])
+
squeeze([dim, drop, axis])
Return a new object with squeezed data.
-
stack([dim, create_index, index_cls])
+
stack([dim, create_index, index_cls])
Stack any number of existing dimensions into a single new dimension.
-
std([dim, skipna, ddof, keep_attrs])
+
std([dim, skipna, ddof, keep_attrs])
Reduce this DataArray's data by applying std along some dimension(s).
-
sum([dim, skipna, min_count, keep_attrs])
+
sum([dim, skipna, min_count, keep_attrs])
Reduce this DataArray's data by applying sum along some dimension(s).
-
swap_dims([dims_dict])
+
swap_dims([dims_dict])
Returns a new DataArray with swapped dimensions.
-
tail([indexers])
+
tail([indexers])
Return a new DataArray whose data is given by the the last n values along the specified dimension(s).
-
thin([indexers])
+
thin([indexers])
Return a new DataArray whose data is given by each n value along the specified dimension(s).
-
to_dask_dataframe([dim_order, set_index])
+
to_dask_dataframe([dim_order, set_index])
Convert this array into a dask.dataframe.DataFrame.
-
to_dataframe([name, dim_order])
+
to_dataframe([name, dim_order])
Convert this array and its coordinates into a tidy pandas.DataFrame.
-
to_dataset([dim, name, promote_attrs])
+
to_dataset([dim, name, promote_attrs])
Convert a DataArray to a Dataset.
-
to_dict([data, encoding])
+
to_dict([data, encoding])
Convert this xarray.DataArray into a dictionary following xarray naming conventions.
-
to_index()
+
to_index()
Convert this variable to a pandas.Index.
-
to_iris()
+
to_iris()
Convert this array into a iris.cube.Cube
-
to_masked_array([copy])
+
to_masked_array([copy])
Convert this array into a numpy.ma.MaskedArray
-
to_netcdf([path, mode, format, group, ...])
+
to_netcdf([path, mode, format, group, ...])
Write DataArray contents to a netCDF file.
-
to_numpy()
+
to_numpy()
Coerces wrapped data to numpy and returns a numpy.ndarray.
-
to_pandas()
+
to_pandas()
Convert this array into a pandas object with the same shape.
-
to_series()
+
to_series()
Convert this array into a pandas.Series.
-
to_unstacked_dataset(dim[, level])
+
to_unstacked_dataset(dim[, level])
Unstack DataArray expanding to Dataset along a given level of a stacked coordinate.
-
to_zarr([store, chunk_store, mode, ...])
+
to_zarr([store, chunk_store, mode, ...])
Write DataArray contents to a Zarr store
-
transpose(*dim[, transpose_coords, missing_dims])
+
transpose(*dim[, transpose_coords, missing_dims])
Return a new DataArray object with transposed dimensions.
-
unify_chunks()
+
unify_chunks()
Unify chunk size along all chunked dimensions of this DataArray.
-
unstack([dim, fill_value, sparse])
+
unstack([dim, fill_value, sparse])
Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.
-
var([dim, skipna, ddof, keep_attrs])
+
var([dim, skipna, ddof, keep_attrs])
Reduce this DataArray's data by applying var along some dimension(s).
-
weighted(weights)
+
weighted(weights)
Weighted DataArray operations.
-
where(cond[, other, drop])
+
where(cond[, other, drop])
Filter elements from this object according to a condition.
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:
+
The spatial dimensions are flattened into a single UGRID face dimension.
+By default, this method looks for:
-
"x" and "y" dimensions.
-
"longitude" and "latitude" dimensions.
-
"axis" attributes of “X” or “Y” on coordinates.
-
"standard_name" attributes of “longitude”, “latitude”,
-“projection_x_coordinate”, or “project_y_coordinate” on coordinate
-variables.
+
“x” and “y” dimensions
+
“longitude” and “latitude” dimensions
+
“axis” attributes of “X” or “Y” on coordinates
+
“standard_name” attributes of “longitude”, “latitude”,
+“projection_x_coordinate”, or “projection_y_coordinate” on coordinate
+variables
-
Specify the x and y coordinate names explicitly otherwise, see the
-examples.
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)}.
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:
Create a UgridDataset from a (structured) xarray Dataset.
-
get(k[,d])
+
get(k[,d])
-
get_index(key)
+
get_index(key)
Get an index for a dimension, with fall-back to a default RangeIndex
-
groupby([group, squeeze, ...])
+
groupby([group, squeeze, ...])
Returns a DatasetGroupBy object for performing grouped operations.
-
groupby_bins(group, bins[, right, labels, ...])
+
groupby_bins(group, bins[, right, labels, ...])
Returns a DatasetGroupBy object for performing grouped operations.
-
head([indexers])
+
head([indexers])
Returns a new dataset with the first n values of each array for the specified dimension(s).
-
identical(other)
+
identical(other)
Like equals, but also checks all dataset attributes and the attributes on all variables and coordinates.
-
idxmax([dim, skipna, fill_value, keep_attrs])
+
idxmax([dim, skipna, fill_value, keep_attrs])
Return the coordinate label of the maximum value along a dimension.
-
idxmin([dim, skipna, fill_value, keep_attrs])
+
idxmin([dim, skipna, fill_value, keep_attrs])
Return the coordinate label of the minimum value along a dimension.
-
info([buf])
+
info([buf])
Concise summary of a Dataset variables and attributes.
-
integrate(coord[, datetime_unit])
+
integrate(coord[, datetime_unit])
Integrate along the given coordinate using the trapezoidal rule.
-
interp([coords, method, assume_sorted, ...])
+
interp([coords, method, assume_sorted, ...])
Interpolate a Dataset onto new coordinates.
-
interp_calendar(target[, dim])
+
interp_calendar(target[, dim])
Interpolates the Dataset to another calendar based on decimal year measure.
-
interp_like(other[, method, assume_sorted, ...])
+
interp_like(other[, method, assume_sorted, ...])
Interpolate this object onto the coordinates of another object.
-
interpolate_na([dim, method, limit, ...])
+
interpolate_na([dim, method, limit, ...])
Fill in NaNs by interpolating according to different methods.
-
isel([indexers, drop, missing_dims])
+
isel([indexers, drop, missing_dims])
Returns a new dataset with each array indexed along the specified dimension(s).
-
isin(test_elements)
+
isin(test_elements)
Tests each value in the array for whether it is in test elements.
-
isnull([keep_attrs])
+
isnull([keep_attrs])
Test each value in the array for whether it is a missing value.
-
items()
+
items()
-
keys()
+
keys()
-
load(**kwargs)
+
load(**kwargs)
Manually trigger loading and/or computation of this dataset's data from disk or a remote source into memory and return this dataset.
-
load_store([decoder])
+
load_store([decoder])
Create a new dataset from the contents of a backends.*DataStore object
-
map(func[, keep_attrs, args])
+
map(func[, keep_attrs, args])
Apply a function to each data variable in this dataset
-
map_blocks(func[, args, kwargs, template])
+
map_blocks(func[, args, kwargs, template])
Apply a function to each block of this Dataset.
-
max([dim, skipna, keep_attrs])
+
max([dim, skipna, keep_attrs])
Reduce this Dataset's data by applying max along some dimension(s).
-
mean([dim, skipna, keep_attrs])
+
mean([dim, skipna, keep_attrs])
Reduce this Dataset's data by applying mean along some dimension(s).
-
median([dim, skipna, keep_attrs])
+
median([dim, skipna, keep_attrs])
Reduce this Dataset's data by applying median along some dimension(s).
-
merge(other[, overwrite_vars, compat, join, ...])
+
merge(other[, overwrite_vars, compat, join, ...])
Merge the arrays of two datasets into a single dataset.
-
min([dim, skipna, keep_attrs])
+
min([dim, skipna, keep_attrs])
Reduce this Dataset's data by applying min along some dimension(s).
-
notnull([keep_attrs])
+
notnull([keep_attrs])
Test each value in the array for whether it is not a missing value.
-
pad([pad_width, mode, stat_length, ...])
+
pad([pad_width, mode, stat_length, ...])
Pad this dataset along one or more dimensions.
-
persist(**kwargs)
+
persist(**kwargs)
Trigger computation, keeping data as chunked arrays.
-
pipe(func, *args, **kwargs)
+
pipe(func, *args, **kwargs)
Apply func(self,*args,**kwargs)
-
polyfit(dim, deg[, skipna, rcond, w, full, cov])
+
polyfit(dim, deg[, skipna, rcond, w, full, cov])
Least squares polynomial fit.
-
prod([dim, skipna, min_count, keep_attrs])
+
prod([dim, skipna, min_count, keep_attrs])
Reduce this Dataset's data by applying prod along some dimension(s).
-
quantile(q[, dim, method, numeric_only, ...])
+
quantile(q[, dim, method, numeric_only, ...])
Compute the qth quantile of the data along the specified dimension.
-
query([queries, parser, engine, missing_dims])
+
query([queries, parser, engine, missing_dims])
Return a new dataset with each array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the data variables in the dataset.
-
rank(dim, *[, pct, keep_attrs])
+
rank(dim, *[, pct, keep_attrs])
Ranks the data.
-
reduce(func[, dim, keep_attrs, keepdims, ...])
+
reduce(func[, dim, keep_attrs, keepdims, ...])
Reduce this dataset by applying func along some dimension(s).
-
reindex([indexers, method, tolerance, copy, ...])
+
reindex([indexers, method, tolerance, copy, ...])
Conform this object onto a new set of indexes, filling in missing values with fill_value.
-
reindex_like(other[, method, tolerance, ...])
+
reindex_like(other[, method, tolerance, ...])
Conform this object onto the indexes of another object, for indexes which the objects share.
-
rename([name_dict])
+
rename([name_dict])
Returns a new object with renamed variables, coordinates and dimensions.
-
rename_dims([dims_dict])
+
rename_dims([dims_dict])
Returns a new object with renamed dimensions only.
-
rename_vars([name_dict])
+
rename_vars([name_dict])
Returns a new object with renamed variables including coordinates
-
reorder_levels([dim_order])
+
reorder_levels([dim_order])
Rearrange index levels using input order.
-
resample([indexer, skipna, closed, label, ...])
+
resample([indexer, skipna, closed, label, ...])
Returns a Resample object for performing resampling operations.
-
reset_coords([names, drop])
+
reset_coords([names, drop])
Given names of coordinates, reset them to become variables
-
reset_encoding()
+
reset_encoding()
-
reset_index(dims_or_levels, *[, drop])
+
reset_index(dims_or_levels, *[, drop])
Reset the specified index(es) or multi-index level(s).
-
roll([shifts, roll_coords])
+
roll([shifts, roll_coords])
Roll this dataset by an offset along one or more dimensions.
-
rolling([dim, min_periods, center])
+
rolling([dim, min_periods, center])
Rolling window object for Datasets.
-
rolling_exp([window, window_type])
+
rolling_exp([window, window_type])
Exponentially-weighted moving window.
-
round(*args, **kwargs)
+
round(*args, **kwargs)
-
sel([indexers, method, tolerance, drop])
+
sel([indexers, method, tolerance, drop])
Returns a new dataset with each array indexed by tick labels along the specified dimension(s).
-
set_close(close)
+
set_close(close)
Register the function that releases any resources linked to this object.
-
set_coords(names)
+
set_coords(names)
Given names of one or more variables, set them as coordinates
-
set_index([indexes, append])
+
set_index([indexes, append])
Set Dataset (multi-)indexes using one or more existing coordinates or variables.
-
set_xindex(coord_names[, index_cls])
+
set_xindex(coord_names[, index_cls])
Set a new, Xarray-compatible index from one or more existing coordinate(s).
-
shift([shifts, fill_value])
+
shift([shifts, fill_value])
Shift this dataset by an offset along one or more dimensions.
-
sortby(variables[, ascending])
+
sortby(variables[, ascending])
Sort object by labels or values (along an axis).
-
squeeze([dim, drop, axis])
+
squeeze([dim, drop, axis])
Return a new object with squeezed data.
-
stack([dim, create_index, index_cls])
+
stack([dim, create_index, index_cls])
Stack any number of existing dimensions into a single new dimension.
-
std([dim, skipna, ddof, keep_attrs])
+
std([dim, skipna, ddof, keep_attrs])
Reduce this Dataset's data by applying std along some dimension(s).
-
sum([dim, skipna, min_count, keep_attrs])
+
sum([dim, skipna, min_count, keep_attrs])
Reduce this Dataset's data by applying sum along some dimension(s).
-
swap_dims([dims_dict])
+
swap_dims([dims_dict])
Returns a new object with swapped dimensions.
-
tail([indexers])
+
tail([indexers])
Returns a new dataset with the last n values of each array for the specified dimension(s).
-
thin([indexers])
+
thin([indexers])
Returns a new dataset with each array indexed along every n-th value for the specified dimension(s)
-
to_array([dim, name])
+
to_array([dim, name])
Deprecated version of to_dataarray
-
to_dask_dataframe([dim_order, set_index])
+
to_dask_dataframe([dim_order, set_index])
Convert this dataset into a dask.dataframe.DataFrame.
-
to_dataarray([dim, name])
+
to_dataarray([dim, name])
Convert this dataset into an xarray.DataArray
-
to_dataframe([dim_order])
+
to_dataframe([dim_order])
Convert this dataset into a pandas.DataFrame.
-
to_dict([data, encoding])
+
to_dict([data, encoding])
Convert this dataset to a dictionary following xarray naming conventions.
-
to_netcdf([path, mode, format, group, ...])
+
to_netcdf([path, mode, format, group, ...])
Write dataset contents to a netCDF file.
-
to_pandas()
+
to_pandas()
Convert this dataset into a pandas object without changing the number of dimensions.
-
to_stacked_array(new_dim, sample_dims[, ...])
+
to_stacked_array(new_dim, sample_dims[, ...])
Combine variables of differing dimensionality into a DataArray without broadcasting.
-
to_zarr([store, chunk_store, mode, ...])
+
to_zarr([store, chunk_store, mode, ...])
Write dataset contents to a zarr group.
-
transpose(*dim[, missing_dims])
+
transpose(*dim[, missing_dims])
Return a new Dataset object with all array dimensions transposed.
-
unify_chunks()
+
unify_chunks()
Unify chunk size along all chunked dimensions of this Dataset.
-
unstack([dim, fill_value, sparse])
+
unstack([dim, fill_value, sparse])
Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.
-
update(other)
+
update(other)
Update this dataset's variables with those from another dataset.
-
values()
+
values()
-
var([dim, skipna, ddof, keep_attrs])
+
var([dim, skipna, ddof, keep_attrs])
Reduce this Dataset's data by applying var along some dimension(s).
-
weighted(weights)
+
weighted(weights)
Weighted Dataset operations.
-
where(cond[, other, drop])
+
where(cond[, other, drop])
Filter elements from this object according to a condition.
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.
+
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.
xugrid.UgridDataArrayAccessor.from_structured() previously required the
literal dimensions ("y","x"). This requirement has been relaxed, it will
@@ -680,10 +704,10 @@
Release 0.12.0 changed the return type of the face node connectivity of
xugrid.Ugrid2d.voronoi_topology from a scipy.sparse.coo_matrix to
@@ -724,8 +748,8 @@
xugrid.Ugrid1d and xugrid.Ugrid2d will generally preserve
the fill value and start index of grids when roundtripping from and to xarray
@@ -750,10 +774,10 @@
The xugrid.BarycentricInterpolator now interpolates according to
linear weights within the full bounds of the source grid, rather than only
@@ -762,8 +786,8 @@
The regridders will no longer flip around data along an axis when regridding
from data from structured to unstructured form when the coordinates along the
@@ -801,8 +825,8 @@
xugrid.snap_nodes() to snap neighboring vertices together that are
located within a maximum snapping distance from each other. If vertices are
@@ -814,10 +838,10 @@
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
@@ -832,8 +856,8 @@
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.
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
@@ -1091,8 +1115,8 @@
Changed#
parts of xarray were used which no longer existed.
xugrid.UgridDatasetAccessor.sel() would return only a single grid
topology even when the selection subject contains more than one grid. It now
@@ -1100,20 +1124,20 @@