Skip to content

Commit 7784d97

Browse files
committed
General tidying of docs
1 parent dbcd5b7 commit 7784d97

File tree

1 file changed

+45
-26
lines changed

1 file changed

+45
-26
lines changed

src/emsarray/conventions/_base.py

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@
7474

7575
@dataclasses.dataclass
7676
class SpatialIndexItem(Generic[Index]):
77-
"""Information about an item in the STRtree spatial index for a dataset.
77+
"""Information about an item in the :class:`~shapely.strtree.STRtree`
78+
spatial index for a dataset.
7879
7980
See Also
8081
--------
81-
:attr:`.Convention.spatial_index`
82+
Convention.spatial_index
8283
"""
8384

8485
#: The linear index of this cell
@@ -161,7 +162,7 @@ def __init__(self, dataset: xr.Dataset):
161162
@classmethod
162163
def check_validity(cls, dataset: xr.Dataset) -> None:
163164
"""Checks that the dataset is OK to use.
164-
Called during __init__, and raises exceptions if the dataset has problems.
165+
Called during ``__init__``, and raises an exception if the dataset has problems.
165166
"""
166167
pass # Subclasses can override this. By default, no checks are made
167168

@@ -191,7 +192,7 @@ def check_dataset(cls, dataset: xr.Dataset) -> Optional[int]:
191192
192193
Parameters
193194
----------
194-
dataset : :class:`xarray.Dataset`
195+
dataset : xarray.Dataset
195196
The dataset instance to inspect.
196197
197198
Returns
@@ -234,8 +235,8 @@ def bind(self) -> None:
234235
to autodetect the dataset convention you do not need to call this method.
235236
:meth:`Convention.bind` is only useful if you manually construct a :class:`Convention`.
236237
237-
Example
238-
-------
238+
Examples
239+
--------
239240
240241
.. code-block:: python
241242
@@ -521,7 +522,7 @@ def ravel_index(self, index: Index) -> int:
521522
522523
See Also
523524
--------
524-
:meth:`.unravel_index`
525+
:meth:`.Convention.unravel_index` : The inverse operation
525526
"""
526527
pass
527528

@@ -540,7 +541,7 @@ def unravel_index(
540541
----------
541542
linear_index : int
542543
The linear index to unravel.
543-
grid_kind : GridKind, optional
544+
grid_kind : :data:`.GridKind`, optional
544545
Used to indicate what kind of index is being unravelled,
545546
for conventions with multiple grids.
546547
Optional, if not provided this will return the unravelled face index.
@@ -568,23 +569,23 @@ def unravel_index(
568569
569570
See Also
570571
--------
571-
:meth:`.ravel_index`
572+
:meth:`.Convention.ravel_index` : The inverse operation
572573
"""
573574
pass
574575

575576
@property
576577
@abc.abstractmethod
577578
def grid_kinds(self) -> FrozenSet[GridKind]:
578579
"""
579-
All of the :data:`grid kinds <GridKind>` this dataset includes.
580+
All of the :data:`grid kinds <.GridKind>` this dataset includes.
580581
"""
581582
pass
582583

583584
@property
584585
@abc.abstractmethod
585586
def default_grid_kind(self) -> GridKind:
586587
"""
587-
The default :data:`grid kind <GridKind>` for this dataset.
588+
The default :data:`grid kind <.GridKind>` for this dataset.
588589
For most datasets this should be the face grid.
589590
"""
590591
pass
@@ -602,16 +603,16 @@ def get_grid_kind_and_size(
602603
603604
Parameters
604605
----------
605-
data_array
606+
data_array : xarray.DataArray
606607
The data array to introspect
607608
608609
Returns
609610
-------
610-
tuple of :data:`GridKind` and int
611+
tuple of :data:`.GridKind` and int
611612
612613
Raises
613614
------
614-
`ValueError`
615+
ValueError
615616
If the data array passed in is not indexable using any native index type
616617
a ValueError is raised.
617618
Depth coordinates or time coordinates are examples of data arrays
@@ -644,7 +645,7 @@ def get_grid_kind_and_size(
644645
def make_linear(self, data_array: xr.DataArray) -> xr.DataArray:
645646
"""
646647
Flatten the surface dimensions of a :class:`~xarray.DataArray`,
647-
returning a flatter :class:`np.ndarray` indexed in the same order as the linear index.
648+
returning a flatter :class:`numpy.ndarray` indexed in the same order as the linear index.
648649
649650
For DataArrays with extra dimensions such as time or depth,
650651
only the surface dimensions are flattened.
@@ -657,7 +658,7 @@ def make_linear(self, data_array: xr.DataArray) -> xr.DataArray:
657658
658659
Parameters
659660
----------
660-
data_array
661+
data_array : xarray.DataArray
661662
One of the data variables from this dataset.
662663
663664
Returns
@@ -675,7 +676,7 @@ def data_crs(self) -> CRS:
675676
"""
676677
The coordinate reference system that coordinates in this dataset are
677678
defined in.
678-
Used by :meth:`.make_poly_collection` and :meth:`.make_quiver`.
679+
Used by :meth:`.Convention.make_poly_collection` and :meth:`.Convention.make_quiver`.
679680
Defaults to :class:`cartopy.crs.PlateCarree`.
680681
"""
681682
# Lazily imported here as cartopy is an optional dependency
@@ -698,21 +699,20 @@ def plot_on_figure(
698699
The data array does not have to come from the same dataset,
699700
as long as the dimensions are the same.
700701
702+
This method will only plot a single time step and depth layer.
703+
Callers are responsible for selecting a single slice before calling this method.
704+
701705
Parameters
702706
----------
703-
figure
707+
figure : matplotlib.figure.Figure
704708
The :class:`~matplotlib.figure.Figure` instance to plot this on.
705-
scalar : data array
709+
scalar : xarray.DataArray or str
706710
The :class:`~xarray.DataArray` to plot,
707711
or the name of an existing DataArray in this Dataset.
708-
This method will only plot a single time step and depth layer.
709-
Callers are responsible for selecting a single slice.
710-
vector : tuple of data arrays
712+
vector : tuple of xarray.DataArray or str
711713
A tuple of the *u* and *v* components of a vector.
712714
The components should be a :class:`~xarray.DataArray`,
713715
or the name of an existing DataArray in this Dataset.
714-
This method will only plot a single time step and depth layer.
715-
Callers are responsible for selecting a single slice.
716716
717717
See Also
718718
--------
@@ -967,6 +967,25 @@ def make_quiver(
967967
v: Optional[DataArrayOrName] = None,
968968
**kwargs: Any,
969969
) -> Quiver:
970+
"""
971+
Make a :class:`matplotlib.quiver.Quiver` instance to plot vector data.
972+
973+
Parameters
974+
----------
975+
axes : matplotlib.axes.Axes
976+
The axes to make this quiver on.
977+
u, v : xarray.DataArray or str, optional
978+
The DataArrays or the names of DataArrays in this dataset
979+
that make up the *u* and *v* components of the vector.
980+
If omitted, a Quiver will be constructed with all components set to 0.
981+
**kwargs
982+
Any keyword arguments are passed on to the Quiver constructor.
983+
984+
Returns
985+
-------
986+
matplotlib.quiver.Quiver
987+
A quiver instance that can be added to a plot
988+
"""
970989
from matplotlib.quiver import Quiver
971990

972991
x, y = np.transpose(self.face_centres)
@@ -1006,7 +1025,7 @@ def make_quiver(
10061025
@property
10071026
@abc.abstractmethod
10081027
def polygons(self) -> np.ndarray:
1009-
"""A :class:`np.ndarray` of :class:`shapely.Polygon` instances
1028+
"""A :class:`numpy.ndarray` of :class:`shapely.Polygon` instances
10101029
representing the cells in this dataset.
10111030
10121031
The order of the polygons in the list
@@ -1047,7 +1066,7 @@ def face_centres(self) -> np.ndarray:
10471066
@cached_property
10481067
def mask(self) -> np.ndarray:
10491068
"""
1050-
A boolean :class:`np.ndarray` indicating which cells have valid polygons.
1069+
A boolean :class:`numpy.ndarray` indicating which cells have valid polygons.
10511070
This can be used to select only items from linear arrays
10521071
that have a corresponding polygon.
10531072

0 commit comments

Comments
 (0)