Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Mar 28, 2024
1 parent 54f2b37 commit 993ae33
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 33 deletions.
3 changes: 3 additions & 0 deletions docs/using/code/combine_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from anemoi.datasets import open_dataset

ds = open_dataset("path/to/dataset1.zarr", "path/to/dataset2.zarr")
1 change: 1 addition & 0 deletions docs/using/code/end_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open_dataset(dataset, end="2020-12-31")
1 change: 1 addition & 0 deletions docs/using/code/frequency_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ds = open_dataset(dataset, frequency="6h")
7 changes: 7 additions & 0 deletions docs/using/code/some_attributes_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
print(ds.shape)

print(len(ds))

print(ds[0])

print(ds[10:20])
1 change: 1 addition & 0 deletions docs/using/code/start_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open_dataset(dataset, start=1980)
3 changes: 3 additions & 0 deletions docs/using/code/subset_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from anemoi.datasets import open_dataset

ds = open_dataset("path/to/dataset.zarr", start=2000, end=2020)
29 changes: 5 additions & 24 deletions docs/using/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,24 @@ organised in such a way that I/O operations are minimised (see

To open a dataset, you can use the `open_dataset` function.

.. code:: python
from anemoi.datasets import open_dataset
ds = open_dataset("path/to/dataset.zarr")
.. literalinclude:: code/open_path.py

You can then access the data in the dataset using the `ds` object as if
it was a NumPy array.

.. code:: python
print(ds.shape)
print(len(ds))
print(ds[0])
print(ds[10:20])
.. literalinclude:: code/some_attributes_.py

One of the main feature of the *anemoi-datasets* package is the ability
to subset or combine datasets.

.. code:: python
from anemoi.datasets import open_dataset
ds = open_dataset("path/to/dataset.zarr", start=2000, end=2020)
.. literalinclude:: code/subset_example.py

In that case, a dataset is created that only contains the data between
the years 2000 and 2020. Combining is done by passing multiple paths to
the `open_dataset` function:

.. code:: python
from anemoi.datasets import open_dataset
ds = open_dataset("path/to/dataset1.zarr", "path/to/dataset2.zarr")
.. literalinclude:: code/combine_example.py
:language: python

In the latter case, the datasets are combined along the time dimension
or the variable dimension depending on the datasets structure.
14 changes: 5 additions & 9 deletions docs/using/subsetting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

This option let you subset the dataset by time. You can pass a date or a

.. code:: python
open_dataset(dataset, start=1980)
.. literalinclude:: code/start_.py

.. _end:

Expand All @@ -24,9 +22,8 @@ This option let you subset the dataset by time. You can pass a date or a

As for the start option, you can pass a date or a string:

.. code:: python
open_dataset(dataset, end="2020-12-31")
.. literalinclude:: code/end_.py
:language: python

The following are equivalent way of describing ``start`` or ``end``:

Expand All @@ -42,6 +39,5 @@ The following are equivalent way of describing ``start`` or ``end``:

You can change the frequency of the dataset by passing a string with the

.. code:: python
ds = open_dataset(dataset, frequency="6h")
.. literalinclude:: code/frequency_.py
:language: python

0 comments on commit 993ae33

Please sign in to comment.