Skip to content

Commit

Permalink
Tweak docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Huite committed Oct 21, 2024
1 parent 8c5535f commit e111a64
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
43 changes: 29 additions & 14 deletions xugrid/core/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,16 @@ def from_structured(
The spatial dimensions are flattened into a single UGRID face dimension.
By default, this method looks for the "x" and "y" coordinates and assumes
they are one-dimensional. To convert rotated or curvilinear coordinates,
provide the names of the x and y coordinates.
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.
Parameters
----------
Expand Down Expand Up @@ -416,47 +423,55 @@ def from_structured(
The spatial dimensions are flattened into a single UGRID face dimension.
By default, this method looks for the ``"x"`` and ``"y"`` coordinates
and assumes they are one-dimensional. To convert rotated or curvilinear
coordinates, provide the names of the x and y coordinates.
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.
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": ("x", "y")}``.
If None, defaults to ``{"mesh2d": (None, None)}``.
Returns
-------
unstructured: UgridDataset
Examples
--------
By default, this method will look for 1D ``"x"`` and ``"y"``
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 rotated or curvilinear coordinates, the name of the
resulting UGRID topology and the x and y coordinates must be specified:
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={"mesh2d": ("xc", "yc")},
>>> topology={"my_mesh2d": ("xc", "yc")},
>>> )
In case of multiple grid topologies in a single dataset, these must be
specified as well:
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"},
>>> )
"""
if topology is None:
topology = {"mesh2d": ("x", "y")}
topology = {"mesh2d": (None, None)}

grids = []
dss = []
Expand Down
11 changes: 11 additions & 0 deletions xugrid/ugrid/ugrid2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,17 @@ def from_structured(
Create a Ugrid2d topology from a structured topology axis-aligned rectilinear, rotated
or (approximated) curvilinear topologies.
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.
Parameters
----------
data: xr.DataArray or xr.Dataset
Expand Down

0 comments on commit e111a64

Please sign in to comment.