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

sen2cor2.8 intro and naming

parent a9698858
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,7 @@ class L1cProduct(Product):
l2a_identifier = self.identifier.replace("L1C_", "L2A_").replace("_OPER_", "_USER_")
l2a_path = self.path.parent / (l2a_identifier + ".SAFE")
l2a_path_tmp = l2a_path.parent / (l2a_path.stem + '.tmp')
l2a_prod = L2aProduct(l2a_identifier, self.tile, l2a_path.parent)
if not l2a_prod.in_library and not l2a_path.exists():
......@@ -200,10 +201,11 @@ class L1cProduct(Product):
process_it = True
if process_it:
process_sen2cor(self.path)
process_sen2cor(self.path, l2a_path_tmp, self.processing_baseline)
# sen2cor creates the L2A in the parent folder of the L1C.
# Therefore, if the L1C computed is in the L1C library folder,
# the newly L2A must be moved to his L2A library folder.
sorted(l2a_path_tmp.glob("*.SAFE"))[0].rename(l2a_path)
if self._library_product:
l2a_prod.archive()
L2aProduct(l2a_identifier).setPermissions()
......
......@@ -18,6 +18,8 @@ logging.basicConfig(level=logging.INFO)
def process_sen2cor(
l1c_product_path: Union[str, pathlib.PosixPath],
l2a_product_path: Union[str, pathlib.PosixPath],
pb: str = '99.99',
resolution: int = 10
) -> None:
"""Process a L1C SAFE folder using sen2cor thanks to a subprocess call.
......@@ -34,30 +36,39 @@ def process_sen2cor(
sen2cor_bashrc_path = Config().get("sen2cor_bashrc_path")
if resolution == 10:
logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
command1 = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
sen2cor_bashrc=str(sen2cor_bashrc_path),
res=20,
l1c_folder=str(l1c_product_path)
)
process1 = subprocess.run(command1.split(", "))
logger.info("sen2cor processing 10 m: {}".format(l1c_product_path))
command2 = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
sen2cor_bashrc=str(sen2cor_bashrc_path),
res=10,
l1c_folder=str(l1c_product_path)
)
process2 = subprocess.run(command2.split(", "))
else:
logger.debug("sen2cor processing: {}".format(l1c_product_path))
command = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {resolution} {l1c_folder}".format(
sen2cor_bashrc=str(sen2cor_bashrc_path),
resolution=resolution,
l1c_folder=str(l1c_product_path)
)
process = subprocess.run(command.split(", "))
#~ if resolution == 10:
#~ logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
#~ command1 = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
#~ sen2cor_bashrc=str(sen2cor_bashrc_path),
#~ res=20,
#~ l1c_folder=str(l1c_product_path)
#~ )
#~ process1 = subprocess.run(command1.split(", "))
#~ logger.info("sen2cor processing 10 m: {}".format(l1c_product_path))
#~ command2 = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
#~ sen2cor_bashrc=str(sen2cor_bashrc_path),
#~ res=10,
#~ l1c_folder=str(l1c_product_path)
#~ )
#~ process2 = subprocess.run(command2.split(", "))
#~ else:
#~ logger.debug("sen2cor processing: {}".format(l1c_product_path))
#~ command = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --resolution {resolution} {l1c_folder}".format(
#~ sen2cor_bashrc=str(sen2cor_bashrc_path),
#~ resolution=resolution,
#~ l1c_folder=str(l1c_product_path)
#~ )
#~ process = subprocess.run(command.split(", "))
logger.debug("sen2cor 2.8 processing: {}".format(l1c_product_path))
command = "/bin/bash, -i, -c, source {sen2cor_bashrc} && L2A_Process --processing_baseline {processing_baseline} --output_dir {out_dir} {l1c_folder}".format(
sen2cor_bashrc = str(sen2cor_bashrc_path),
processing_baseline = pb,
out_dir = l2a_product_path,
l1c_folder = str(l1c_product_path)
)
process = subprocess.run(command.split(", "))
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