Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Sen2Chain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESPACE-DEV
Sen2Chain
Commits
52e515bd
Commit
52e515bd
authored
2 years ago
by
pascal.mouquet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
bugfix sen2cor version
parent
0c24d89a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sen2chain/sen2cor.py
+104
-104
104 additions, 104 deletions
sen2chain/sen2cor.py
with
104 additions
and
104 deletions
sen2chain/sen2cor.py
+
104
−
104
View file @
52e515bd
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment