Skip to content

Commit df2f31e

Browse files
authored
Update README.rst
1 parent c1f3355 commit df2f31e

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

README.rst

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,8 @@
3030
cf-xarray
3131
=========
3232

33-
A lightweight convenience wrapper for using CF attributes on xarray objects. Right now all of this works:
33+
A lightweight convenience wrapper for using CF attributes on xarray objects.
3434

35-
.. code-block:: python
35+
For example you can use `.cf.mean("latitude")` instead of `.mean("lat")` if appropriate attributes are set! This allows you to write code that does not require knowledge of specific dimension or coordinate names particular to a dataset.
3636

37-
import cf_xarray
38-
import xarray as xr
39-
40-
ds = xr.tutorial.load_dataset("air_temperature").isel(time=slice(4))
41-
42-
ds.air.cf.var("X")
43-
44-
ds.air.cf.resample(T="M").var()
45-
46-
ds.air.cf.groupby("T").var("Y")
47-
48-
(
49-
ds.air
50-
.cf.isel(T=slice(4))
51-
.cf.plot.contourf(x="Y", y="X", col="T", col_wrap=4)
52-
)
53-
54-
ds.air.isel(lat=[0, 1], lon=1).cf.plot.line(x="T", hue="Y")
55-
56-
ds.air.attrs["cell_measures"] = "area: cell_area"
57-
ds.coords["cell_area"] = (
58-
np.cos(ds.air.cf["latitude"] * np.pi / 180)
59-
* xr.ones_like(ds.air.cf["longitude"])
60-
* 105e3
61-
* 110e3
62-
)
63-
ds.air.cf.weighted("area").sum("latitude")
37+
See more in the introductory notebook `here <https://cf-xarray.readthedocs.io/en/latest/examples/introduction.html>`_.

0 commit comments

Comments
 (0)