Skip to content
Snippets Groups Projects
Commit 9abdbbc3 authored by pascal.mouquet_ird.fr's avatar pascal.mouquet_ird.fr
Browse files

Add new parameter to remove Tiff format indices and 0B files while cleaning...

Add new parameter to remove Tiff format indices and 0B files while cleaning Tiles. Raw Tiff indices are now removed after being masked
parent 98cb27f6
No related branches found
No related tags found
No related merge requests found
......@@ -106,6 +106,7 @@ class Ndvi(Indice):
out_path=(out_path / self.indice_raw))
index_tiff_2_jp2(img_path=(out_path / self.indice_raw),
out_path=(out_path / self.indice_filename))
if nodata_clouds:
if self.l2a_product.user_cloud_mask is None:
raise ValueError("Cloud mask does not exist")
......@@ -126,6 +127,11 @@ class Ndvi(Indice):
out_path=(out_path / masked_indice_filename))
os.remove(str(out_path / masked_indice_raw))
try:
os.remove(str(out_path / self.indice_raw))
except:
pass
if quicklook:
cmap = matplotlib_colormap_to_rgb(self.colormap, revers=False)
......
......@@ -58,13 +58,14 @@ class Library:
def clean(self,
clean_list: list = [],
remove_indice_tif: bool = False,
remove: bool = False):
if not clean_list:
clean_list = self.l1c
for t in clean_list:
try:
til = Tile(t)
til.clean_lib(remove=remove)
til.clean_lib(remove=remove, remove_indice_tif=remove_indice_tif)
except:
pass
......
......@@ -334,6 +334,7 @@ class Tile:
return prods_list
def clean_lib(self,
remove_indice_tif: bool = False,
remove: bool = False):
"""
Search and clean processing error products
......@@ -410,6 +411,19 @@ class Tile:
if remove:
logger.info("Removing indice QL {}".format(q.name))
q.unlink()
for q in p.glob("*.*"):
if q.stat().st_size == 0:
logger.info("Corrupted file {} (0B size)".format(q.name))
if remove:
logger.info("Removing indice QL {}".format(q.name))
q.unlink()
if remove_indice_tif:
for q in p.glob("*" + f.upper() + ".tif"):
logger.info("Identified indice in tif format {}".format(q.name))
if remove:
logger.info("Removing indice QL {}".format(q.name))
q.unlink()
def archive_l1c(self):
"""
......@@ -443,10 +457,3 @@ class Tile:
logger.info("No L1C products to archive")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment