Skip to content

Commit 5abde69

Browse files
committed
support more temporal queries
1 parent 3f9d8e2 commit 5abde69

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed

earthaccess/search.py

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,105 @@ def temporal(
443443
"""
444444
return super().temporal(date_from, date_to, exclude_boundary)
445445

446+
@override
447+
def revision_date(
448+
self,
449+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
450+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
451+
exclude_boundary: bool = False,
452+
) -> Self:
453+
"""Filter by an open or closed date range. Dates can be provided as date objects
454+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
455+
456+
???+ Tip
457+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
458+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
459+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
460+
objects have `00:00:00` as their built-in default.
461+
462+
Parameters:
463+
date_from: start of revision date range
464+
date_to: end of revision date range
465+
exclude_boundary: whether or not to exclude the date_from/to in
466+
the matched range.
467+
468+
Returns:
469+
self
470+
471+
Raises:
472+
ValueError: `date_from` or `date_to` is a non-`None` value that is
473+
neither a datetime object nor a string that can be parsed as a datetime
474+
object; or `date_from` and `date_to` are both datetime objects (or
475+
parsable as such) and `date_from` is after `date_to`.
476+
"""
477+
return super().revision_date(date_from, date_to, exclude_boundary)
478+
479+
@override
480+
def created_at(
481+
self,
482+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
483+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
484+
exclude_boundary: bool = False,
485+
) -> Self:
486+
"""Filter by an open or closed date range. Dates can be provided as date objects
487+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
488+
489+
???+ Tip
490+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
491+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
492+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
493+
objects have `00:00:00` as their built-in default.
494+
495+
Parameters:
496+
date_from: start of creation time range
497+
date_to: end of creation time range
498+
exclude_boundary: whether or not to exclude the date_from/to in
499+
the matched range.
500+
501+
Returns:
502+
self
503+
504+
Raises:
505+
ValueError: `date_from` or `date_to` is a non-`None` value that is
506+
neither a datetime object nor a string that can be parsed as a datetime
507+
object; or `date_from` and `date_to` are both datetime objects (or
508+
parsable as such) and `date_from` is after `date_to`.
509+
"""
510+
return super().created_at(date_from, date_to, exclude_boundary)
511+
512+
@override
513+
def production_date(
514+
self,
515+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
516+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
517+
exclude_boundary: bool = False,
518+
) -> Self:
519+
"""Filter by an open or closed date range. Dates can be provided as date objects
520+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
521+
522+
???+ Tip
523+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
524+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
525+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
526+
objects have `00:00:00` as their built-in default.
527+
528+
Parameters:
529+
date_from: start of production date range
530+
date_to: end of production date range
531+
exclude_boundary: whether or not to exclude the date_from/to in
532+
the matched range.
533+
534+
Returns:
535+
self
536+
537+
Raises:
538+
ValueError: `date_from` or `date_to` is a non-`None` value that is
539+
neither a datetime object nor a string that can be parsed as a datetime
540+
object; or `date_from` and `date_to` are both datetime objects (or
541+
parsable as such) and `date_from` is after `date_to`.
542+
"""
543+
return super().production_date(date_from, date_to, exclude_boundary)
544+
446545

447546
class DataGranules(GranuleQuery):
448547
"""A Granule oriented client for NASA CMR.
@@ -843,6 +942,102 @@ def temporal(
843942
"""
844943
return super().temporal(date_from, date_to, exclude_boundary)
845944

945+
@override
946+
def revision_date(
947+
self,
948+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
949+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
950+
exclude_boundary: bool = False,
951+
) -> Self:
952+
"""Filter by an open or closed date range. Dates can be provided as date objects
953+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
954+
955+
???+ Tip
956+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
957+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
958+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
959+
objects have `00:00:00` as their built-in default.
960+
961+
Parameters:
962+
date_from: earliest revision date to return
963+
date_to: latest revision date to return
964+
exclude_boundary: whether to exclude the date_from and date_to in the matched range
965+
966+
Returns:
967+
self
968+
969+
Raises:
970+
ValueError: `date_from` or `date_to` is a non-`None` value that is
971+
neither a datetime object nor a string that can be parsed as a datetime
972+
object; or `date_from` and `date_to` are both datetime objects (or
973+
parsable as such) and `date_from` is after `date_to`.
974+
"""
975+
return super().revision_date(date_from, date_to, exclude_boundary)
976+
977+
@override
978+
def created_at(
979+
self,
980+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
981+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
982+
exclude_boundary: bool = False,
983+
) -> Self:
984+
"""Filter by an open or closed date range. Dates can be provided as date objects
985+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
986+
987+
???+ Tip
988+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
989+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
990+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
991+
objects have `00:00:00` as their built-in default.
992+
993+
Parameters:
994+
date_from: earliest creation time to return
995+
date_to: latest creation time to return
996+
exclude_boundary: whether to exclude the date_from and date_to in the matched range
997+
998+
Returns:
999+
self
1000+
1001+
Raises:
1002+
ValueError: `date_from` or `date_to` is a non-`None` value that is
1003+
neither a datetime object nor a string that can be parsed as a datetime
1004+
object; or `date_from` and `date_to` are both datetime objects (or
1005+
parsable as such) and `date_from` is after `date_to`.
1006+
"""
1007+
return super().created_at(date_from, date_to, exclude_boundary)
1008+
1009+
@override
1010+
def production_date(
1011+
self,
1012+
date_from: Optional[Union[str, dt.date, dt.datetime]] = None,
1013+
date_to: Optional[Union[str, dt.date, dt.datetime]] = None,
1014+
exclude_boundary: bool = False,
1015+
) -> Self:
1016+
"""Filter by an open or closed date range. Dates can be provided as date objects
1017+
or ISO 8601 strings. Multiple ranges can be provided by successive method calls.
1018+
1019+
???+ Tip
1020+
Giving either `datetime.date(YYYY, MM, DD)` or `"YYYY-MM-DD"` as the `date_to`
1021+
parameter includes that entire day (i.e. the time is set to `23:59:59`).
1022+
Using `datetime.datetime(YYYY, MM, DD)` is different, because `datetime.datetime`
1023+
objects have `00:00:00` as their built-in default.
1024+
1025+
Parameters:
1026+
date_from: earliest production date to return
1027+
date_to: latest production date to return
1028+
exclude_boundary: whether to exclude the date_from and date_to in the matched range
1029+
1030+
Returns:
1031+
self
1032+
1033+
Raises:
1034+
ValueError: `date_from` or `date_to` is a non-`None` value that is
1035+
neither a datetime object nor a string that can be parsed as a datetime
1036+
object; or `date_from` and `date_to` are both datetime objects (or
1037+
parsable as such) and `date_from` is after `date_to`.
1038+
"""
1039+
return super().production_date(date_from, date_to, exclude_boundary)
1040+
8461041
@override
8471042
def version(self, version: str) -> Self:
8481043
"""Filter by version. Note that CMR defines this as a string. For example,

0 commit comments

Comments
 (0)