From ba9c3259c4b393da771c732ed1a4a58b8b4bb8ff Mon Sep 17 00:00:00 2001
From: Jeremy Commins <commins.jeremy@gmail.com>
Date: Fri, 23 Nov 2018 14:59:00 -0300
Subject: [PATCH] Code style and comments: create_cloud_mask_v2

---
 sen2chain/cloud_mask.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/sen2chain/cloud_mask.py b/sen2chain/cloud_mask.py
index 125baa9..490c305 100755
--- a/sen2chain/cloud_mask.py
+++ b/sen2chain/cloud_mask.py
@@ -14,11 +14,12 @@ from shapely.ops import transform
 import rasterio
 from rasterio.features import shapes, rasterize
 import numpy as np
-from typing import Mapping, Sequence, AbstractSet, List, Set, Dict, Tuple, Optional, Union
+import gdal
 import otbApplication
+# type annotations
+from typing import Mapping, Sequence, AbstractSet, List, Set, Dict, Tuple, Optional, Union
+
 from .config import Config
-import gdal
-import os
 
 
 LOGGER = logging.getLogger(__name__)
@@ -253,13 +254,16 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./
     LOGGER.info("Creating cloud-mask_v2")
 
     out_temp_path = Path(Config().get("temp_path"))
-#    LOGGER.info(out_temp_path)
-#    LOGGER.info(str(out_temp_path))
-    out_bin = str(out_temp_path) + '/temp_bin.tif'
-    out_erode = str(out_temp_path) + '/temp_erode.tif'
-    out_dilate = str(out_temp_path) + '/temp_dilate.tif'
-
-    # Seuillage du masque nuage SEN2COR
+    # LOGGER.info(out_temp_path)
+    # LOGGER.info(str(out_temp_path))
+    # ATTENTION, si jamais des traitements en parallèle: les fichiers
+    # temporaires auront le même nom => conflits
+    # à utiliser uniquement pour des tests
+    out_bin = str(out_temp_path / "temp_bin.tif")
+    out_erode = str(out_temp_path / "temp_erode.tif")
+    out_dilate = str(out_temp_path / "temp_dilate.tif")
+
+    # Seuillage du masque nuage Sen2Cor
     CLD_seuil = 25
     BandMath = otbApplication.Registry.CreateApplication("BandMath")
     BandMath.SetParameterStringList("il", [str(cloud_mask)])
@@ -299,11 +303,11 @@ def create_cloud_mask_v2(cloud_mask: Union[str, pathlib.PosixPath], out_path="./
     # Enregistrement JP2000
     src_ds = gdal.Open(out_dilate)
     driver = gdal.GetDriverByName("JP2OpenJPEG")
-    dst_ds = driver.CreateCopy(str(out_path), src_ds, options=['CODEC=JP2', 'QUALITY=100', 'REVERSIBLE=YES', 'YCBCR420=NO'])
+    dst_ds = driver.CreateCopy(str(out_path), src_ds, options=["CODEC=JP2", "QUALITY=100", "REVERSIBLE=YES", "YCBCR420=NO"])
     dst_ds = None
     src_ds = None
 
     #os.remove(out_bin)
     #os.remove(out_erode)
     #os.remove(out_dilate)
-    
+
-- 
GitLab