From 9ad9e5b12cfe3dc9ec587c5f0dd41b88612f7cb1 Mon Sep 17 00:00:00 2001 From: Eric Bruning Date: Thu, 8 Apr 2021 16:13:44 -0500 Subject: [PATCH] Expand documentation on indexing and interation for DatasetCollection --- src/siphon/catalog.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/siphon/catalog.py b/src/siphon/catalog.py index 31f2c72ca..91d4726fa 100644 --- a/src/siphon/catalog.py +++ b/src/siphon/catalog.py @@ -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\d{4})(?P[01]\d)(?P[0123]\d)_' r'(?P[012]\d)(?P[0-5]\d)')