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

bugfix sen2cor version

parent 0c24d89a
No related branches found
No related tags found
No related merge requests found
......@@ -46,119 +46,119 @@ def process_sen2cor(
# TODO: Add 60m resolution.
# <<<<<<< HEAD
# s2c_path = s2c_path or get_latest_s2c_version_path(pathlib.Path(l1c_product_path).stem)
# if s2c_path:
# s2c_v = get_Sen2Cor_version(s2c_path)
# l2a_product_path_tmp = l2a_product_path.parent / (l2a_product_path.stem + '.tmp')
# if s2c_v == '02.05.05':
# logger.info("sen2cor {} processing: {}".format(s2c_v, l1c_product_path))
# if resolution == 10:
# logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
# command1 = "/bin/bash, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
# sen2cor_bashrc=str(s2c_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, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
# sen2cor_bashrc=str(s2c_path),
# res=10,
# l1c_folder=str(l1c_product_path)
# )
# process2 = subprocess.run(command2.split(", "))
s2c_path = s2c_path or get_latest_s2c_version_path(pathlib.Path(l1c_product_path).stem)
if s2c_path:
s2c_v = get_Sen2Cor_version(s2c_path)
l2a_product_path_tmp = l2a_product_path.parent / (l2a_product_path.stem + '.tmp')
if s2c_v == '02.05.05':
logger.info("sen2cor {} processing: {}".format(s2c_v, l1c_product_path))
if resolution == 10:
logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
command1 = "/bin/bash, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
sen2cor_bashrc=str(s2c_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, -c, source {sen2cor_bashrc} && L2A_Process --resolution {res} {l1c_folder}".format(
sen2cor_bashrc=str(s2c_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, -c, source {sen2cor_bashrc} && L2A_Process --resolution {resolution} {l1c_folder}".format(
# sen2cor_bashrc=str(s2c_path),
# resolution=resolution,
# l1c_folder=str(l1c_product_path)
# )
# process = subprocess.run(command.split(", "))
else:
logger.debug("sen2cor processing: {}".format(l1c_product_path))
command = "/bin/bash, -c, source {sen2cor_bashrc} && L2A_Process --resolution {resolution} {l1c_folder}".format(
sen2cor_bashrc=str(s2c_path),
resolution=resolution,
l1c_folder=str(l1c_product_path)
)
process = subprocess.run(command.split(", "))
# elif s2c_v in ['02.08.00','02.09.00', '02.10.01']:
# logger.info("sen2cor {} processing: {}".format(s2c_v, l1c_product_path))
# command = "/bin/bash, -c, source {sen2cor_bashrc} && L2A_Process --processing_baseline {processing_baseline} --output_dir {out_dir} {l1c_folder}".format(
# sen2cor_bashrc = str(s2c_path),
# processing_baseline = pb,
# out_dir = l2a_product_path_tmp,
# l1c_folder = str(l1c_product_path)
# )
# process = subprocess.run(command.split(", "))
# sorted(l2a_product_path_tmp.glob("*.SAFE"))[0].rename(l2a_product_path.parent / (l2a_product_path.stem + '.SAFE'))
# l2a_product_path_tmp.rmdir()
# elif s2c_v is not None:
# logger.info('Provided Sen2Cor version {} is not compatible with Sen2Chain yet'.format(s2c_v))
elif s2c_v in ['02.08.00','02.09.00', '02.10.01']:
logger.info("sen2cor {} processing: {}".format(s2c_v, l1c_product_path))
command = "/bin/bash, -c, source {sen2cor_bashrc} && L2A_Process --processing_baseline {processing_baseline} --output_dir {out_dir} {l1c_folder}".format(
sen2cor_bashrc = str(s2c_path),
processing_baseline = pb,
out_dir = l2a_product_path_tmp,
l1c_folder = str(l1c_product_path)
)
process = subprocess.run(command.split(", "))
sorted(l2a_product_path_tmp.glob("*.SAFE"))[0].rename(l2a_product_path.parent / (l2a_product_path.stem + '.SAFE'))
l2a_product_path_tmp.rmdir()
elif s2c_v is not None:
logger.info('Provided Sen2Cor version {} is not compatible with Sen2Chain yet'.format(s2c_v))
# else:
# logger.info('Could not determine Sen2Cor version from provided path, please check pattern "Sen2Cor-**.**.**" is in path')
else:
logger.info('Could not determine Sen2Cor version from provided path, please check pattern "Sen2Cor-**.**.**" is in path')
# else:
# logger.info('Could not determine a compatible installed sen2cor version to process this product')
else:
logger.info('Could not determine a compatible installed sen2cor version to process this product')
# =======
sen2cor_bashrc_path = Config().get("sen2cor_bashrc_path")
# sen2cor_bashrc_path = Config().get("sen2cor_bashrc_path")
# ~ s2c_v = next(iter(re.findall('Sen2Cor-(\d{2}\.\d{2}\.\d{2})', str(sen2cor_bashrc_path))), None)
s2c_v = get_current_Sen2Cor_version()
l2a_product_path_tmp = l2a_product_path.parent / (
l2a_product_path.stem + ".tmp"
)
if s2c_v == "02.05.05":
logger.info(
"sen2cor {} processing: {}".format(s2c_v, l1c_product_path)
)
if resolution == 10:
logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
command1 = "/bin/bash, -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),
)
# s2c_v = get_current_Sen2Cor_version()
# l2a_product_path_tmp = l2a_product_path.parent / (
# l2a_product_path.stem + ".tmp"
# )
# if s2c_v == "02.05.05":
# logger.info(
# "sen2cor {} processing: {}".format(s2c_v, l1c_product_path)
# )
# if resolution == 10:
# logger.info("sen2cor processing 20 m: {}".format(l1c_product_path))
# command1 = "/bin/bash, -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(", "))
# process1 = subprocess.run(command1.split(", "))
logger.info("sen2cor processing 10 m: {}".format(l1c_product_path))
command2 = "/bin/bash, -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(", "))
# logger.info("sen2cor processing 10 m: {}".format(l1c_product_path))
# command2 = "/bin/bash, -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, -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(", "))
# else:
# logger.debug("sen2cor processing: {}".format(l1c_product_path))
# command = "/bin/bash, -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(", "))
elif s2c_v in ["02.08.00", "02.09.00", "02.10.01"]:
logger.info(
"sen2cor {} processing: {}".format(s2c_v, l1c_product_path)
)
command = "/bin/bash, -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_tmp,
l1c_folder=str(l1c_product_path),
)
process = subprocess.run(command.split(", "))
sorted(l2a_product_path_tmp.glob("*.SAFE"))[0].rename(
l2a_product_path.parent / (l2a_product_path.stem + ".SAFE")
)
l2a_product_path_tmp.rmdir()
elif s2c_v is not None:
logger.info(
"Sen2Cor version {} is not compatible with Sen2Chain".format(s2c_v)
)
# elif s2c_v in ["02.08.00", "02.09.00", "02.10.01"]:
# logger.info(
# "sen2cor {} processing: {}".format(s2c_v, l1c_product_path)
# )
# command = "/bin/bash, -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_tmp,
# l1c_folder=str(l1c_product_path),
# )
# process = subprocess.run(command.split(", "))
# sorted(l2a_product_path_tmp.glob("*.SAFE"))[0].rename(
# l2a_product_path.parent / (l2a_product_path.stem + ".SAFE")
# )
# l2a_product_path_tmp.rmdir()
# elif s2c_v is not None:
# logger.info(
# "Sen2Cor version {} is not compatible with Sen2Chain".format(s2c_v)
# )
else:
logger.info(
'Could not determine sen2cor version from path, please check pattern "Sen2Cor-**.**.**" is in path'
)
# else:
# logger.info(
# 'Could not determine sen2cor version from path, please check pattern "Sen2Cor-**.**.**" is in path'
# )
# >>>>>>> 571a1f934055bd9bc242e2f3dde14e38a7f4b5ca
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