Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Fix temporal coverage for ODP datasets that are listed as a single d…
Browse files Browse the repository at this point in the history
…ataset in the CSW and as multiple in the ESGF

 The ESGF dataset entries have the year they are covering in the 'realization' attribute

 fixes #272
  • Loading branch information
mzuehlke committed Sep 6, 2017
1 parent 51637d2 commit 4297ea5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Date and time columns in CSV data are converted into datetime objects
* Fix use case 6 script
* Fix #320 (wrong file dialog for enso_nino34 operation in GUI)
* Fix temporal coverage for ODP datasets that are listed as a single dataset in the CSW and as multiple in the ESGF

## Changes in version 0.9.0.dev5

Expand Down
13 changes: 13 additions & 0 deletions cate/ds/esa_cci_odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
('yr', timedelta(days=365)),
])

_YEAR_REALIZATION = re.compile(4 * '\\d')

_ODP_PROTOCOL_HTTP = 'HTTPServer'
_ODP_PROTOCOL_OPENDAP = 'OPENDAP'

Expand Down Expand Up @@ -473,6 +475,17 @@ def temporal_coverage(self, monitor: Monitor = Monitor.NONE) -> Optional[TimeRan
temp_coverage_end = self._catalogue_data.get('temporal_coverage_end', None)
if temp_coverage_start and temp_coverage_end:
self._temporal_coverage = TimeRangeLike.convert("{},{}".format(temp_coverage_start, temp_coverage_end))
# ODP datasets that are split into per-year datasets
# have the year they are covering in the 'realization' attribute
# the CSW does not have separate temporal coverages for them
realization = self._json_dict.get('realization', None)
if realization and len(realization):
matcher = _YEAR_REALIZATION.match(realization[0])
if matcher:
year = matcher.group(0)
rel_start = max(self._temporal_coverage[0], datetime(int(year), 1, 1))
rel_end = min(self._temporal_coverage[1], datetime(int(year) + 1, 1, 1) - timedelta(seconds=1))
self._temporal_coverage = (rel_start, rel_end)
else:
self.update_file_list(monitor)
if self._temporal_coverage:
Expand Down

0 comments on commit 4297ea5

Please sign in to comment.