Skip to content
Snippets Groups Projects
Commit c2ee3f81 authored by Aurore Dupuis's avatar Aurore Dupuis
Browse files

80 - Synthesis refactoring for hysope2

parent 3a3c29b1
No related branches found
No related tags found
3 merge requests!77Release 1.7.1,!73Dockerfile corrections and optimizations,!70Resolve "[H2] - Code refactoring"
......@@ -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"
......
......@@ -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)
......
......@@ -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:")
......
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