xugrid.UgridDataset.from_structured#
- static UgridDataset.from_structured(dataset: Dataset, topology: dict | None = None) UgridDataset [source]#
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:
"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.
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)}
.
- Returns:
unstructured
- Return type:
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"}, >>> )