Skip to content

Commit 6b447a3

Browse files
author
Joseph Hamman
committed
update README.md
1 parent 06601b6 commit 6b447a3

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
<img
2-
src='https://carbonplan-assets.s3.amazonaws.com/monogram/dark-small.png'
3-
height='48'
4-
/>
1+
<p align="left">
2+
<a href="https://carbonplan.org/#gh-light-mode-only">
3+
<img src="https://carbonplan-assets.s3.amazonaws.com/monogram/dark-small.png" height="48px" />
4+
</a>
5+
<a href="https://carbonplan.org/#gh-dark-mode-only">
6+
<img src="https://carbonplan-assets.s3.amazonaws.com/monogram/light-small.png" height="48px" />
7+
</a>
8+
</p>
59

610
# xarray-schema
711

@@ -43,25 +47,53 @@ schema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, ), dims=['x'])
4347
schema.validate(da)
4448
```
4549

46-
You can also use it to validate a Dataset like so:
50+
You can also use it to validate a `Dataset` like so:
4751

4852
```
4953
schema_ds = DatasetSchema({'foo': schema})
5054
5155
schema_ds.validate(da.to_dataset())
5256
```
5357

58+
Each component of the Xarray data model is implemented as a stand alone class:
59+
60+
```python
61+
from xarray_schema.components import (
62+
DTypeSchema,
63+
DimsSchema,
64+
ShapeSchema,
65+
NameSchema,
66+
ChunksSchema,
67+
ArrayTypeSchema
68+
)
69+
70+
# example constructions
71+
dtype_schema = DTypeSchema('i4')
72+
dims_schema = DimsSchema(('x', 'y', None)) # None is used as a wildcard
73+
shape_schema = ShapeSchema((5, 10, None)) # None is used as a wildcard
74+
name_schema = NameSchema('foo')
75+
chunk_schema = ChunkSchema({'x': None, 'y': -1}) # None is used as a wildcard, -1 is used as
76+
ArrayTypeSchema = ArrayTypeSchema(np.ndarray)
77+
78+
# Example usage
79+
dtype_schama.validate(da.dtype)
80+
81+
# Each object schema can be exported to JSON format
82+
dtype_json = dtype_schama.to_json()
83+
```
84+
5485
# roadmap
5586

5687
This is a very early prototype of a library. Some key things are missing:
5788

5889
1. Validation of `coords` and `attrs`. These are implemented yet.
5990
1. Exceptions: Pandera accumulates schema exceptions and reports them all at once. Currently, we are a eagerly raising `SchemaErrors` when the are found.
91+
1. Roundtrip schemas to/from JSON and/or YAML format
6092

6193
## license
6294

6395
All the code in this repository is [MIT](https://choosealicense.com/licenses/mit/) licensed, but we request that you please provide attribution if reusing any of our digital content (graphics, logo, articles, etc.).
6496

6597
## about us
6698

67-
CarbonPlan is a non-profit organization working on the science and data of carbon removal. We aim to improve the transparency and scientific integrity of carbon removal and climate solutions through open data and tools. Find out more at [carbonplan.org](https://carbonplan.org/) or get in touch by [opening an issue](https://github.com/carbonplan/xarray-schema/issues/new) or [sending us an email](mailto:[email protected]).
99+
CarbonPlan is a non-profit organization that uses data and science for climate action. We aim to improve the transparency and scientific integrity of climate solutions through open data and tools. Find out more at [carbonplan.org](https://carbonplan.org/) or get in touch by [opening an issue](https://github.com/carbonplan/xarray-schema/issues/new) or [sending us an email](mailto:[email protected]).

0 commit comments

Comments
 (0)