From 46da9f221baf66a3a15d4d72bc664e4cdff936e8 Mon Sep 17 00:00:00 2001 From: ltrotter Date: Wed, 4 Sep 2024 12:24:57 +0200 Subject: [PATCH 1/2] chore: update tools to v1.3.1 --- door/tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/door/tools b/door/tools index 054e472..7cb08f8 160000 --- a/door/tools +++ b/door/tools @@ -1 +1 @@ -Subproject commit 054e472e772517b599ad702b9e7d73b69f24d46b +Subproject commit 7cb08f844fdd97ee269e2a5ae52b10c926fb4123 From dd428daaf755de0a195fcee7ab9efbd97435b13e Mon Sep 17 00:00:00 2001 From: ltrotter Date: Wed, 4 Sep 2024 12:25:25 +0200 Subject: [PATCH 2/2] fix(cmr): improve method to find last available --- door/data_sources/earthdata/cmr_downloader.py | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/door/data_sources/earthdata/cmr_downloader.py b/door/data_sources/earthdata/cmr_downloader.py index dbf8653..342c1b0 100644 --- a/door/data_sources/earthdata/cmr_downloader.py +++ b/door/data_sources/earthdata/cmr_downloader.py @@ -6,9 +6,8 @@ import itertools import sys import numpy as np -from datetime import datetime, timedelta - -from osgeo import gdal +from datetime import datetime +from typing import Optional from ...base_downloaders import DOORDownloader from ...utils.auth import get_credentials @@ -71,11 +70,27 @@ def get_credentials(self, url: str) -> str: return self.credentials - def get_last_published_ts(self, bounds: BoundingBox = BoundingBox(-180, -90, 180, 90), expected_tiles: int = 1) -> ts.TimeRange: + def get_last_published_ts(self, + bounds: Optional[BoundingBox] = None, + expected_tiles: Optional[int] = None) -> ts.TimeRange: + """ Get the last published date for the dataset. """ - #global_bounds = BoundingBox(-180, -90, 180, 90) + # get the space bounds + if bounds is None: + if hasattr(self, 'bounds'): + bounds = self.bounds + else: + raise ValueError('No space bounds specified') + + # get the number of tiles + if expected_tiles is None: + if hasattr(self, 'destination'): + expected_tiles = self.destination.ntiles + else: + raise ValueError('No expected number of tiles specified') + now = datetime.now() all_times = ts.TimeRange(self.start, now) all_timesteps = self._get_timesteps(all_times)