Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some ravel/wind docs I missed #104

Merged
merged 1 commit into from Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions docs/concepts/indexing.rst
Expand Up @@ -46,13 +46,14 @@ Using indexes
A convention native index can be transformed in to a linear index by calling
:meth:`Convention.ravel_index(native_index) <.Convention.ravel_index>`.
A linear index can be transformed in to a native index by calling
:meth:`Convention.unravel_index(linear_index, kind) <.Convention.unravel_index>`.
:meth:`Convention.wind_index(linear_index, grid_kind=grid_kind) <.Convention.wind_index>`.

To find the correct native index kind for a data variable,
call :meth:`.Convention.get_grid_kind_and_size`.
This will return a tuple of ``(kind, size)``.
``kind`` is the native index kind (face, edge, node, etc),
while ``size`` is the length of the linear index space for that grid.
call :meth:`.Convention.get_grid_kind(data_array) <.Convention.get_grid_kind>`.
This will return one of the :attr:`Convention.grid_kinds` members.
:attr:`.Convention.default_grid_kind` indicates which grid kind
represents the cells in this convention.
:attr:`.Convention.grid_size` indicates how large the index space is for each grid kind.

:attr:`.Convention.strtree`
is a :class:`spatial index <shapely.strtree.STRtree>`
Expand All @@ -64,8 +65,12 @@ are in linear index order.
If you have the linear index for a cell,
you can find its polygon by indexing directly in to this array.

:meth:`Convention.make_linear` will the surface dimensions of a data variable
:meth:`Convention.ravel` will transform the surface dimensions of a data variable
in to a linear one dimensional array.
The order of this flattened array matches the linear index order.
If you have the linear index for a cell,
you can find its value by indexing directly in to this array.
:meth:`Convention.wind` is the inverse operation.
It takes a linear data array and transforms it in to the same shape as the convention.
This can be used to create arbitrary new data arrays for a dataset
in a way completely agnostic of the underlying convention.
4 changes: 2 additions & 2 deletions docs/releases/development.rst
Expand Up @@ -4,15 +4,15 @@ Next release (in development)

* Use 'ravel' and 'wind' as antonyms instead of 'ravel' and 'unravel'.
English is weird. 'Ravel' and 'unravel' mean the same thing!.
(:pr:`100`)
(:pr:`100`, :pr:`104`).
* Added new :class:`emsarray.conventions.DimensionConvention` subclass.
For conventions with multiple grids defined on unique subsets of dimensions
this base class will provide a number of default method implementations.
All existing conventions have been updated to build off this base class.
(:pr:`100`)
* Remove workaround for `pydata/xarray#6049 <https://github.com/pydata/xarray/pull/6049>`_ (:pr:`101`).
* Add :meth:`.Convention.wind()` method as the inverse to :meth:`.Convention.ravel()`
(:pr:`102`).
(:pr:`102`, :pr:`104`).
* Add :attr:`.Convention.strtree()` spatial index,
deprecate :attr:`.Convention.spatial_index()`.
The old attribute was a compatibility shim around Shapely 1.8.x STRtree implementation.
Expand Down