Skip to content

Commit

Permalink
Add examples to to_raggedarray docstrings (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
milancurcic authored Apr 12, 2023
1 parent 76e53ae commit 5f6ae12
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
29 changes: 29 additions & 0 deletions clouddrift/adapters/gdp1h.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,35 @@ def to_raggedarray(
-------
out : RaggedArray
A RaggedArray instance of the requested dataset
Examples
--------
Invoke `to_raggedarray` without any arguments to download all drifter data
from the 2.00 GDP feed:
>>> from clouddrift.adapters.gdp1h import to_raggedarray
>>> ra = to_raggedarray()
To download a random sample of 100 drifters, for example for development
or testing, use the `n_random_id` argument:
>>> ra = to_raggedarray(n_random_id=100)
To download a specific list of drifters, use the `drifter_ids` argument:
>>> ra = to_raggedarray(drifter_ids=[44136, 54680, 83463])
To download the experimental 2.01 GDP feed, use the `url` argument to
specify the experimental feed URL:
>>> from clouddrift.adapters.gdp1h import GDP_DATA_URL_EXPERIMENTAL, to_raggedarray
>>> ra = to_raggedarray(url=GDP_DATA_URL_EXPERIMENTAL)
Finally, `to_raggedarray` returns a `RaggedArray` instance which provides
a convenience method to emit a `xarray.Dataset` instance:
>>> ds = ra.to_dataset()
"""
ids = download(drifter_ids, n_random_id, url)

Expand Down
23 changes: 23 additions & 0 deletions clouddrift/adapters/gdp6h.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,29 @@ def to_raggedarray(
-------
out : RaggedArray
A RaggedArray instance of the requested dataset
Examples
--------
Invoke `to_raggedarray` without any arguments to download all drifter data
from the 6-hourly GDP feed:
>>> from clouddrift.adapters.gdp6h import to_raggedarray
>>> ra = to_raggedarray()
To download a random sample of 100 drifters, for example for development
or testing, use the `n_random_id` argument:
>>> ra = to_raggedarray(n_random_id=100)
To download a specific list of drifters, use the `drifter_ids` argument:
>>> ra = to_raggedarray(drifter_ids=[54375, 114956, 126934])
Finally, `to_raggedarray` returns a `RaggedArray` instance which provides
a convenience method to emit a `xarray.Dataset` instance:
>>> ds = ra.to_dataset()
"""
ids = download(drifter_ids, n_random_id, GDP_DATA_URL)

Expand Down

0 comments on commit 5f6ae12

Please sign in to comment.