Skip to content

Commit 5f6ae12

Browse files
authored
Add examples to to_raggedarray docstrings (#160)
1 parent 76e53ae commit 5f6ae12

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

clouddrift/adapters/gdp1h.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,35 @@ def to_raggedarray(
511511
-------
512512
out : RaggedArray
513513
A RaggedArray instance of the requested dataset
514+
515+
Examples
516+
--------
517+
518+
Invoke `to_raggedarray` without any arguments to download all drifter data
519+
from the 2.00 GDP feed:
520+
521+
>>> from clouddrift.adapters.gdp1h import to_raggedarray
522+
>>> ra = to_raggedarray()
523+
524+
To download a random sample of 100 drifters, for example for development
525+
or testing, use the `n_random_id` argument:
526+
527+
>>> ra = to_raggedarray(n_random_id=100)
528+
529+
To download a specific list of drifters, use the `drifter_ids` argument:
530+
531+
>>> ra = to_raggedarray(drifter_ids=[44136, 54680, 83463])
532+
533+
To download the experimental 2.01 GDP feed, use the `url` argument to
534+
specify the experimental feed URL:
535+
536+
>>> from clouddrift.adapters.gdp1h import GDP_DATA_URL_EXPERIMENTAL, to_raggedarray
537+
>>> ra = to_raggedarray(url=GDP_DATA_URL_EXPERIMENTAL)
538+
539+
Finally, `to_raggedarray` returns a `RaggedArray` instance which provides
540+
a convenience method to emit a `xarray.Dataset` instance:
541+
542+
>>> ds = ra.to_dataset()
514543
"""
515544
ids = download(drifter_ids, n_random_id, url)
516545

clouddrift/adapters/gdp6h.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,29 @@ def to_raggedarray(
439439
-------
440440
out : RaggedArray
441441
A RaggedArray instance of the requested dataset
442+
443+
Examples
444+
--------
445+
446+
Invoke `to_raggedarray` without any arguments to download all drifter data
447+
from the 6-hourly GDP feed:
448+
449+
>>> from clouddrift.adapters.gdp6h import to_raggedarray
450+
>>> ra = to_raggedarray()
451+
452+
To download a random sample of 100 drifters, for example for development
453+
or testing, use the `n_random_id` argument:
454+
455+
>>> ra = to_raggedarray(n_random_id=100)
456+
457+
To download a specific list of drifters, use the `drifter_ids` argument:
458+
459+
>>> ra = to_raggedarray(drifter_ids=[54375, 114956, 126934])
460+
461+
Finally, `to_raggedarray` returns a `RaggedArray` instance which provides
462+
a convenience method to emit a `xarray.Dataset` instance:
463+
464+
>>> ds = ra.to_dataset()
442465
"""
443466
ids = download(drifter_ids, n_random_id, GDP_DATA_URL)
444467

0 commit comments

Comments
 (0)