From d7915eebe5837da8a47af02583dab9b66ad452fb Mon Sep 17 00:00:00 2001 From: impact <pascal.mouquet@ird.fr> Date: Fri, 8 Jul 2022 16:43:53 +0400 Subject: [PATCH] added auto choose output folder for eodag download, and online / offline status --- sen2chain/download_eodag.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/sen2chain/download_eodag.py b/sen2chain/download_eodag.py index dbe9752..8ca4375 100644 --- a/sen2chain/download_eodag.py +++ b/sen2chain/download_eodag.py @@ -57,9 +57,10 @@ class S2cEodag: self, productType: str = "L1C", start: str = "2015-01-01", - end: str = "9999-01-01", + end: str = "9999-12-31", ): + ######### ici faudrait virer le self.productType, qui ne doit pas être global pour le download... if productType == "L1C": self.productType = "S2_MSI_L1C" outputs_prefix = Path(Config().get("l1c_path")) / self.name @@ -74,27 +75,19 @@ class S2cEodag: ) self.products = self.dag.search_all( - locations=dict(s2_tile_centroid=self.name), + locations = dict(s2_tile_centroid = self.name), **default_search_criteria ) - #### Vériffier ici si le produit existe déjà en local - # ~ logger.info(outputs_prefix) - for p in self.products: - - - # ~ logger.info("location: {}".format(p.location)) if (outputs_prefix / (p.properties["title"] + ".SAFE")).exists(): p.location = "file://" + str(outputs_prefix / (p.properties["title"] + ".SAFE")) - logger.info("Product {} locally present ".format(p.properties["title"])) + logger.info("Product {} - {} - locally present".format(p.properties["title"], p.properties["storageStatus"])) else: - logger.info("Product {} locally absent ".format(p.properties["title"])) - # ~ logger.info("location: {}".format(p.location)) + logger.info("Product {} - {} - locally absent".format(p.properties["title"], p.properties["storageStatus"])) # ~ logger.info("{} products were found given the above search criteria".format(len(self.products))) # ~ logger.info(self.products) - # ~ logger.info([p.properties["storageStatus"] for p in self.products]) # ~ logger.info("{} products were found given the above search criteria".format(len(self.products))) # ~ logger.info("{} products were found given the above search criteria, online".format(len(self.products.filter_online()))) @@ -106,16 +99,16 @@ class S2cEodag: extract: bool = True, delete_archive: bool = True, ): - ######### faudrait ici récupérer le type de produit L1C/L2A du nom du product_id et adapter le dossier en conséquence if not outputs_prefix: - if self.productType == "S2_MSI_L1C": + if "L1C" in product_id.properties['title']: root_path = "l1c_path" - elif self.productType == "S2_MSI_L2A": + elif "L2A" in product_id.properties['title']: root_path = "l2a_path" outputs_prefix = str(Path(Config().get(root_path)) / self.name) ########## faudrait aussi mettre une condition sur le online ########## et si offline supprimer les retry + # ~ logger.info([p.properties["storageStatus"] for p in self.products]) downloaded_path = self.dag.download( product_id, outputs_prefix = outputs_prefix, -- GitLab