Skip to content
Snippets Groups Projects
Commit 3d7bdc81 authored by Jeremy Commins's avatar Jeremy Commins
Browse files

Add the revisit_period parameter to the run method: number of days, since last...

Add the revisit_period parameter to the run method: number of days, since last tile's date, to check again for new images.
parent 47df6bdb
No related branches found
No related tags found
No related merge requests found
......@@ -148,24 +148,25 @@ class Automatization:
return None
@staticmethod
def _five_days_since_date(date: datetime) -> bool:
"""Checks if at least five days have passed since the date.
def _ndays_since_date(date: datetime, ndays: int) -> bool:
"""Checks if at least ndays have passed since the date.
:param date: date to check.
:param ndays: number of days.
"""
time_period = datetime.today() - date
if time_period.days < 4:
if time_period.days < ndays:
return False
return True
def _get_products_list(self) -> None:
def _get_products_list(self, revisit_period) -> None:
"""Merge each request dict into a single one."""
for tile, request_date in self._tiles_to_update.items():
# Don't overload the server with useless requests :
# Sentinel-2 revisit time is 5 days
if request_date:
if not Automatization._five_days_since_date(request_date):
if not Automatization._ndays_since_date(request_date, revisit_period):
logger.info("Too early to check {}".format(tile))
continue
......@@ -188,7 +189,8 @@ class Automatization:
indices_list: List[str] = None,
nodata_clouds: bool = True,
quicklook: bool = True,
hubs_limit: Dict[str, int] = None
hubs_limit: Dict[str, int] = None,
revisit_period: int = 2,
) -> None:
"""
Runs automatization.
......@@ -198,6 +200,7 @@ class Automatization:
:param indices_list: list of valid indices names that will be processed.
:param nodata_clouds: mask indices output rasters with a cloud-mask.
:param quicklook: creates a quicklook for each indice processed.
:param revisit_period: number of days, since last date, to check again for new images.
"""
logger.info("Running automatization")
logger.info("Ignored tiles: {}".format(self._get_ignored_tiles(self)))
......@@ -210,7 +213,7 @@ class Automatization:
hubs_limit = {"peps": 3, "scihub": 2}
self._get_tiles_to_update(tiles_list=tiles)
self._get_products_list()
self._get_products_list(revisit_period)
if any(self._products_list.values()):
prods = DownloadAndProcess(identifiers=self._products_list,
hubs_limit=hubs_limit,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment