Skip to content

Commit a4d78cb

Browse files
committed
Switch to rst and add binder config
1 parent a8f3b97 commit a4d78cb

File tree

3 files changed

+73
-34
lines changed

3 files changed

+73
-34
lines changed

.binder/environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: cf_xarray
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- matplotlib
6+
- netcdf4
7+
- xarray
8+
pip:
9+
- cf_xarray

README.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

README.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. image:: https://img.shields.io/static/v1.svg?logo=Jupyter&label=Pangeo+Binder&message=GCE+us-central1&color=blue&style=for-the-badge
2+
:target: https://binder.pangeo.io/v2/gh/xarray-contrib/cf-xarray/master?urlpath=lab
3+
:alt: Binder
4+
5+
.. image:: https://img.shields.io/github/workflow/status/xarray-contrib/cf-xarray/CI?logo=github&style=for-the-badge
6+
:target: https://github.com/xarray-contrib/cf-xarray/actions
7+
:alt: GitHub Workflow CI Status
8+
9+
.. image:: https://img.shields.io/github/workflow/status/xarray-contrib/cf-xarray/code-style?label=Code%20Style&style=for-the-badge
10+
:target: https://github.com/xarray-contrib/cf-xarray/actions
11+
:alt: GitHub Workflow Code Style Status
12+
13+
.. image:: https://img.shields.io/codecov/c/github/xarray-contrib/cf-xarray.svg?style=for-the-badge
14+
:target: https://codecov.io/gh/xarray-contrib/cf-xarray
15+
:alt: Code Coverage
16+
17+
.. image:: https://img.shields.io/pypi/v/cf-xarray.svg?style=for-the-badge
18+
:target: https://pypi.org/project/cf-xarray
19+
:alt: Python Package Index
20+
21+
.. If you want the following badges to be visible, please remove this line, and unindent the lines below
22+
.. image:: https://img.shields.io/readthedocs/cf-xarray/latest.svg?style=for-the-badge
23+
:target: https://cf-xarray.readthedocs.io/en/latest/?badge=latest
24+
:alt: Documentation Status
25+
26+
.. image:: https://img.shields.io/conda/vn/conda-forge/cf-xarray.svg?style=for-the-badge
27+
:target: https://anaconda.org/conda-forge/cf-xarray
28+
:alt: Conda Version
29+
30+
31+
cf-xarray
32+
=========
33+
34+
A lightweight convenience wrapper for using CF attributes on xarray objects. Right now all of this works:
35+
36+
.. code-block:: python
37+
38+
import cf_xarray
39+
import xarray as xr
40+
41+
ds = xr.tutorial.load_dataset("air_temperature").isel(time=slice(4))
42+
43+
ds.air.cf.var("X")
44+
45+
ds.air.cf.resample(T="M").var()
46+
47+
ds.air.cf.groupby("T").var("Y")
48+
49+
(
50+
ds.air
51+
.cf.isel(T=slice(4))
52+
.cf.plot.contourf(x="Y", y="X", col="T", col_wrap=4)
53+
)
54+
55+
ds.air.isel(lat=[0, 1], lon=1).cf.plot.line(x="T", hue="Y")
56+
57+
ds.air.attrs["cell_measures"] = "area: cell_area"
58+
ds.coords["cell_area"] = (
59+
xr.DataArray(np.cos(ds.cf["latitude"] * np.pi / 180))
60+
* xr.ones_like(ds.cf["longitude"])
61+
* 105e3
62+
* 110e3
63+
)
64+
ds.air.cf.weighted("area").sum("latitude")

0 commit comments

Comments
 (0)