diff --git a/sen2chain/indices.py b/sen2chain/indices.py index def26b624721621d6b041bd4056263601353e4e5..db933d8ec7f927a07e21432f9f15c6a358567dfe 100644 --- a/sen2chain/indices.py +++ b/sen2chain/indices.py @@ -106,6 +106,7 @@ class Ndvi(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -194,6 +195,7 @@ class NdwiMcf(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -282,6 +284,7 @@ class NdwiGao(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -369,6 +372,7 @@ class Mndwi(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -455,6 +459,7 @@ class Ndre(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -542,6 +547,7 @@ class IRECI(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -628,6 +634,7 @@ class BIGR(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -716,6 +723,7 @@ class BIRNIR(Indice): if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw @@ -803,6 +811,7 @@ class BIBG(Indice): out_path=(out_path / self.indice_filename)) if nodata_clouds: if not self.cm_product.path.exists(): + logger.info("Cloudmask does not exist, indice not masked") raise ValueError("Cloud mask does not exist") masked_indice_filename = self.indice_stem + "_" + self.cm_product.suffix + self.ext masked_indice_raw = self.indice_stem + "_" + self.cm_product.suffix + self.ext_raw diff --git a/sen2chain/library.py b/sen2chain/library.py index 075a967e5415016a9e8dc4c2034dbff1e90d773b..000f907dc69bef5c17a4fb513cbbb05a28c0ae96 100644 --- a/sen2chain/library.py +++ b/sen2chain/library.py @@ -233,6 +233,10 @@ class Library: cm_version: str = "cm001", probability: int = 1, iterations: int = 5, + cld_shad: bool = True, + cld_med_prob: bool = True, + cld_hi_prob: bool = True, + thin_cir: bool = True, reprocess: bool = False, date_min: str = None, date_max: str = None, @@ -245,6 +249,10 @@ class Library: l2a_list = [p.identifier for p in t.cloudmasks_missing(cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, )\ .filter_dates(date_min = date_min, date_max = date_max)] else: @@ -254,6 +262,10 @@ class Library: cm_version, probability, iterations, + cld_shad, + cld_med_prob, + cld_hi_prob, + thin_cir, reprocess, ]) logger.info("cld_l2a_process_list ({} files): \n{}".format(len(cld_l2a_process_list), cld_l2a_process_list)) @@ -269,6 +281,10 @@ class Library: cm_version: list = "cm001", probability: int = 1, iterations: int = 5, + cld_shad: bool = True, + cld_med_prob: bool = True, + cld_hi_prob: bool = True, + thin_cir: bool = True, date_min: str = None, date_max: str = None, nb_proc: int = 4): @@ -282,6 +298,10 @@ class Library: cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ).filter_dates(date_min = date_min, date_max = date_max)] else: l2a_list = [p.identifier for p in t.l2a.filter_dates(date_min = date_min, date_max = date_max)] @@ -294,7 +314,12 @@ class Library: quicklook, cm_version, probability, - iterations]) + iterations, + cld_shad, + cld_med_prob, + cld_hi_prob, + thin_cir, + ]) logger.info("indices_l2a_process_list ({} files): \n{}".format(len(indices_l2a_process_list), indices_l2a_process_list)) if indices_l2a_process_list: indices_res = idx_multiprocessing(indices_l2a_process_list, nb_proc=nb_proc) diff --git a/sen2chain/multi_processing.py b/sen2chain/multi_processing.py index 079157260ffd6484d1479ea34bdaa010244adf05..f619dfa892318db3b3f83f3f504579fea62c7452 100644 --- a/sen2chain/multi_processing.py +++ b/sen2chain/multi_processing.py @@ -109,6 +109,10 @@ def multi_idx(l2a_id_idx): cm_version = l2a_id_idx[5] probability = l2a_id_idx[6] iterations = l2a_id_idx[7] + cld_shad = l2a_id_idx[8] + cld_med_prob = l2a_id_idx[9] + cld_hi_prob = l2a_id_idx[10] + thin_cir = l2a_id_idx[11] l2a = L2aProduct(l2a_identifier) try: l2a.compute_indice(indice = indice, @@ -118,6 +122,10 @@ def multi_idx(l2a_id_idx): cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ) except: pass diff --git a/sen2chain/products.py b/sen2chain/products.py index 6e51674f27657a8022d6b1a1a0290a6723dca739..3c52fb015923e2a6d99f15b82951e7d9ebbc68e2 100755 --- a/sen2chain/products.py +++ b/sen2chain/products.py @@ -653,6 +653,10 @@ class L2aProduct(Product): cm_version: str = "cm001", probability: int = 1, iterations: int = 5, + cld_shad: bool = True, + cld_med_prob: bool = True, + cld_hi_prob: bool = True, + thin_cir: bool = True, out_path: str = None, ) -> "L2aProduct": """ @@ -687,7 +691,11 @@ class L2aProduct(Product): indice_obj = indice_cls(self, NewCloudMaskProduct(l2a_identifier = self.identifier, cm_version = cm_version, probability = probability, - iterations = iterations)) + iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir)) indice_obj.process_indice(out_path = indice_path, nodata_clouds = nodata_clouds, @@ -700,6 +708,10 @@ class L2aProduct(Product): cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ) indice_masked = IndiceProduct(l2a_identifier = self.identifier, @@ -708,6 +720,10 @@ class L2aProduct(Product): cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ) if quicklook: indice_masked_ql = IndiceProduct(identifier = indice_masked.identifier.replace(".jp2", "_QL.tif")) @@ -719,6 +735,10 @@ class L2aProduct(Product): cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ) return self diff --git a/sen2chain/tiles.py b/sen2chain/tiles.py index 64bbdf43c8d3ca18e54e0508861ddf9814bb2d3b..7e1ba6c5d6dbb1518e0bd6d471ce73ead4a110fe 100644 --- a/sen2chain/tiles.py +++ b/sen2chain/tiles.py @@ -538,6 +538,10 @@ class Tile: cm_version: list = "cm001", probability: int = 1, iterations: int = 5, + cld_shad: bool = True, + cld_med_prob: bool = True, + cld_hi_prob: bool = True, + thin_cir: bool = True, ) -> "ProductsList": """Returns tile's L2A products that don't have indices as a ProductsList.""" prodlist = ProductsList() @@ -669,6 +673,10 @@ class Tile: cm_version: list = "cm001", probability: int = 1, iterations: int = 5, + cld_shad: bool = True, + cld_med_prob: bool = True, + cld_hi_prob: bool = True, + thin_cir: bool = True, date_min: str = None, date_max: str = None, nb_proc: int = 4): @@ -690,6 +698,10 @@ class Tile: cm_version = cm_version, probability = probability, iterations = iterations, + cld_shad = cld_shad, + cld_med_prob = cld_med_prob, + cld_hi_prob = cld_hi_prob, + thin_cir = thin_cir, ).filter_dates(date_min = date_min, date_max = date_max)] else: l2a_list = [p.identifier for p in self.l2a.filter_dates(date_min = date_min, date_max = date_max)] @@ -703,7 +715,11 @@ class Tile: quicklook, cm_version, probability, - iterations]) + iterations, + cld_shad, + cld_med_prob, + cld_hi_prob, + thin_cir]) if indices_l2a_process_list: logger.info("{} indice products to process:".format(len(indices_l2a_process_list))) logger.info("{}".format(indices_l2a_process_list))