Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand documentation on indexing and interation for DatasetCollection #362

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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