Skip to content

Commit af209d2

Browse files
committed
cleanup
1 parent c17bc4d commit af209d2

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

cf_xarray/geometry.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import copy
34
from collections.abc import Sequence
45

56
import numpy as np
@@ -8,15 +9,21 @@
89

910
GEOMETRY_CONTAINER_NAME = "geometry_container"
1011

12+
__all__ = [
13+
"decode_geometries",
14+
"encode_geometries",
15+
"cf_to_shapely",
16+
"shapely_to_cf",
17+
]
18+
1119

1220
def decode_geometries(encoded: xr.Dataset) -> xr.Dataset:
1321
"""
14-
Decodes CF encoded geometries to a numpy object array
15-
containing shapely geometries.
22+
Decode CF encoded geometries to a numpy object array containing shapely geometries.
1623
1724
Parameters
1825
----------
19-
encoded: Dataset
26+
encoded : Dataset
2027
A Xarray Dataset containing encoded geometries.
2128
2229
Returns
@@ -74,14 +81,9 @@ def decode_geometries(encoded: xr.Dataset) -> xr.Dataset:
7481
return decoded
7582

7683

77-
import copy
78-
79-
GEOMETRY_CONTAINER_NAME = "geometry_container"
80-
81-
8284
def encode_geometries(ds: xr.Dataset):
8385
"""
84-
Encodes any discovered geometry variables using the CF conventions.
86+
Encode any discovered geometry variables using the CF conventions.
8587
8688
Practically speaking, geometry variables are numpy object arrays where the first
8789
element is a shapely geometry.
@@ -93,7 +95,7 @@ def encode_geometries(ds: xr.Dataset):
9395
9496
Parameters
9597
----------
96-
ds: Dataset
98+
ds : Dataset
9799
Dataset containing at least one geometry variable.
98100
99101
Returns

doc/geometry.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ kernelspec:
88
---
99

1010
```{eval-rst}
11-
.. currentmodule:: xarray
11+
.. currentmodule:: cf_xarray
1212
```
1313

1414
# Geometries
1515

1616
```{seealso}
1717
1. [The CF conventions on Geometries](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#geometries)
18-
1. {py:func}`cf_xarray.shapely_to_cf`
19-
1. {py:func}`cf_xarray.cf_to_shapely`
18+
1. {py:func}`shapely_to_cf`
19+
1. {py:func}`cf_to_shapely`
2020
```
2121

2222
`cf_xarray` can convert between vector geometries represented as shapely objects
@@ -42,6 +42,7 @@ da = xr.DataArray(
4242
dims=("index",),
4343
name="geometry"
4444
)
45+
da
4546
```
4647

4748
```{warning}
@@ -73,7 +74,7 @@ ds.identical(decoded)
7374

7475
## Lower-level conversions
7576

76-
Encoding a single DataArray is possible using {py:func}`cf_xarray.geometry.shapely_to_cf`.
77+
Encoding a single DataArray is possible using {py:func}`geometry.shapely_to_cf`.
7778

7879
```{code-cell}
7980
ds_cf = cfxr.shapely_to_cf(da)

0 commit comments

Comments
 (0)