From c2ee3f819845a7dbebe9f15b4d13886180e99762 Mon Sep 17 00:00:00 2001 From: Aurore Dupuis <aurore.dupuis@cnes.fr> Date: Tue, 12 Oct 2021 09:05:24 +0200 Subject: [PATCH] 80 - Synthesis refactoring for hysope2 --- python/s2snow/lis_constant.py | 1 + python/s2snow/snow_product.py | 17 +++++++++++++++-- python/s2snow/snow_synthesis.py | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/python/s2snow/lis_constant.py b/python/s2snow/lis_constant.py index 65cdecb9..5617b3bd 100644 --- a/python/s2snow/lis_constant.py +++ b/python/s2snow/lis_constant.py @@ -44,6 +44,7 @@ MISSION_T5 = "T5" # snow product mission name SENTINEL2 = "SENTINEL2" +LIS = "LIS" LANDSAT8_OLITIRS_XS = "LANDSAT8-OLITIRS-XS" LANDSAT8 = "LANDSAT8" N2A = "N2A" diff --git a/python/s2snow/snow_product.py b/python/s2snow/snow_product.py index 1326d934..d73eacca 100644 --- a/python/s2snow/snow_product.py +++ b/python/s2snow/snow_product.py @@ -26,17 +26,19 @@ import os.path as op import zipfile from os.path import basename, dirname -from s2snow.lis_constant import SENTINEL2, LANDSAT8_OLITIRS_XS, LANDSAT8, N2A +from s2snow.lis_constant import SENTINEL2, LIS, LANDSAT8_OLITIRS_XS, LANDSAT8, N2A from s2snow.lis_exception import UnknownPlatform from s2snow.utils import str_to_datetime MUSCATE_DATETIME_FORMAT = "%Y%m%d-%H%M%S-%f" +LIS_DATETIME_FORMAT = "%Y%m%dT%H%M%S" class snow_product: def __init__(self, absoluteFilename): # example 1 "SENTINEL2A_20160912-103551-370_L2B-SNOW_T32TLS_D_V1-0" # example 2 "LANDSAT8_OLITIRS_XS_20160812_N2A_France-MetropoleD0005H0001" + # exemple 3 : "LIS_S2-SNOW-FSC_T31TCH_20180101T105435_1.7.0_1" logging.debug("snow_product initialisation") logging.debug("absoluteFilename : " + absoluteFilename) @@ -50,7 +52,7 @@ class snow_product: logging.debug("product_path : " + self.product_path) logging.debug("platform : " + self.platform) - if SENTINEL2 in self.platform: + if SENTINEL2 in self.platform : self.acquisition_date = datetime.strptime(name_splitted[1], MUSCATE_DATETIME_FORMAT) logging.debug("acquisition_date : " + str(self.acquisition_date)) self.product_level = name_splitted[2] @@ -81,6 +83,17 @@ class snow_product: logging.debug("tile_id : " + self.tile_id) self.flag = None self.product_version = None + elif LIS in self.platform: + # FSC product + self.acquisition_date = datetime.strptime(name_splitted[3], LIS_DATETIME_FORMAT) + logging.debug("acquisition_date : " + str(self.acquisition_date)) + self.product_level = "L2B" + logging.debug("product_level : " + self.product_level) + self.tile_id = name_splitted[2] + logging.debug("tile_id : " + self.tile_id) + self.flag = None + self.product_version = name_splitted[4] + logging.debug("product_version : " + self.product_version) else: msg = "Unknown platform: " + self.platform logging.error(msg) diff --git a/python/s2snow/snow_synthesis.py b/python/s2snow/snow_synthesis.py index 17c969d3..bf552dcc 100644 --- a/python/s2snow/snow_synthesis.py +++ b/python/s2snow/snow_synthesis.py @@ -325,7 +325,8 @@ def convert_snow_masks_into_binary_snow_masks(path_out, ram, product_dict): logging.debug("ram : %s", str(ram)) # convert the snow masks into binary snow masks - expression = "(im1b1==" + LABEL_SNOW + ")?1:0" + #expression = "(im1b1==" + LABEL_SNOW + ")?1:0" + expression = "(im1b1>0 and im1b1<=" + LABEL_SNOW + ")?1:0" binary_snow_mask_list = convert_mask_list(path_out, product_dict, expression, "snow", ram, mask_format=GDAL_OPT) logging.debug("Binary snow mask list:") -- GitLab