Skip to content

Commit

Permalink
Expand documentation on indexing and interation for DatasetCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
deeplycloudy authored and dopplershift committed Dec 11, 2024
1 parent 7aa5353 commit 9ad9e5b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ def __getitem__(self, item):


class DatasetCollection(IndexableMapping):
"""Extend ``IndexableMapping`` to allow datetime-based filter queries."""
r"""Extend ``IndexableMapping`` to allow datetime-based filter queries.
Indexing works like a dictionary. The dataset name ('my_data.nc', a string) is the key,
and the value returned is an instance of ``Dataset``. Positional indexing
(e.g., [0]) is another valid method of indexing.
``DatasetCollection`` is commonly encountered as the ``datasets`` attribute of a
``TDSCatalog``. If a ``regex`` in ``filter_time_nearest`` or ```filter_time_range` does not
provide sufficient flexibility, or the ``TDSCatalog`` does not provide accurate times,
iterating over ``datasets`` can be useful as part implementing a custom filter. For
example, in ``for ds in catalog.datasets: print(ds)``, ``ds`` will be the dataset name, and
``ds`` can be used to implement further filtering logic.
"""

default_regex = re.compile(r'(?P<year>\d{4})(?P<month>[01]\d)(?P<day>[0123]\d)_'
r'(?P<hour>[012]\d)(?P<minute>[0-5]\d)')
Expand Down

0 comments on commit 9ad9e5b

Please sign in to comment.