Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
maja
maja
Commits
5227bead
Commit
5227bead
authored
Nov 05, 2021
by
jbrossar
Browse files
[BUG] Fix dtf writing in the header file
parent
12b7e2cc
Pipeline
#9185
failed with stages
in 94 minutes and 3 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
orchestrator/plugins/common/muscate/maja_muscate_l2_header_writer.py
View file @
5227bead
...
...
@@ -538,36 +538,29 @@ class MajaMuscateL2HeaderWriter(L2HeaderWriterBase):
elt
.
set
(
"detector_id"
,
det
)
oss
=
str
(
i
+
1
)
elt
.
set
(
"bit_number"
,
oss
)
elt
.
text
=
os
.
path
.
join
(
"MASKS"
,
l_ShortFileName
.
replace
(
"_L1C_"
,
"_L2A_"
))
main_node
.
append
(
elt
)
# Copy the dedicated file
if
(
l_l1info
.
new_format_detected
==
True
):
l_l2DTFFilename
=
l_ShortFileName
.
replace
(
"_L1C_"
,
"_L2A_"
)
l_OldName
=
"{}.tif"
.
format
(
l_ListOfBand
[
i
])
l_NewName
=
"{}-D{}.tif"
.
format
(
l_StrResolution
,
det
)
l_DTFFilenameWithResol
=
l_l2DTFFilename
.
replace
(
l_OldName
,
l_NewName
)
l_OutputFilename
=
os
.
path
.
join
(
l_L2OutputMaskDirectoryFilename
,
l_DTFFilenameWithResol
)
listOfL1BandsForResol
=
l_BandsDefinitions
.
get_list_of_l1_band_code
(
l_StrResolution
)
nbL1Bands
=
len
(
listOfL1BandsForResol
)
l_OutputValue
=
pow
(
2
,
nbL1Bands
)
-
1
bmexpr
=
"im1b1 == {} ? {} : 0"
.
format
(
det
,
l_OutputValue
)
extract_channel_app
=
band_math
([
filename
],
bmexpr
,
l_OutputFilename
+
":uint8"
,
write_output
=
True
,
)
else
:
l_DTFFilenameWithResol
=
l_ShortFileName
.
replace
(
"_L1C_"
,
"_L2A_"
)
elt
.
text
=
os
.
path
.
join
(
"MASKS"
,
l_DTFFilenameWithResol
)
main_node
.
append
(
elt
)
# if we are not in the case of sentinel 2 with new format (PSD > 14.8)
# we copy the L1C DTF to the output L2 product
if
(
l_l1info
.
new_format_detected
==
False
):
l_OutputFilename
=
l_ShortFileName
.
replace
(
"_L1C_"
,
"_L2A_"
)
file_utils
.
copy_file
(
l_FullPathFilename
,
os
.
path
.
join
(
l_L2OutputMaskDirectoryFilename
,
l_OutputFilename
))
else
:
LOGGER
.
debug
(
"No 'Detector_Footprint' masks detected in the L1 product."
)
#Remove the node
xml_tools
.
remove_node
(
output_handler
.
root
,
"//Mask_List/Mask[Mask_Properties/NATURE='Detector_Footprint']"
)
# Fin si manage Detfoo
# ---------------------------------------------------------------------------------------------
...
...
orchestrator/plugins/common/muscate/maja_muscate_l2_image_writer.py
View file @
5227bead
...
...
@@ -531,6 +531,30 @@ class MajaMuscateL2ImageWriter(L2ImageWriterBase):
l_grpSuffix
+
".tif"
,
use_filenames
=
l_cld_uses_filenames
)
LOGGER
.
debug
(
"Writing L2 resolution image done !"
)
# If the L1C is a Sentinel2 new format product
# we have to write the DTF in the same way as the old format
if
(
self
.
_l1_image_info
.
new_format_detected
==
True
):
listOfL1BandsForResol
=
l_BandsDefinitions
.
get_list_of_l1_band_code
(
l_StrResolution
)
nbL1Bands
=
len
(
listOfL1BandsForResol
)
l_OutputValue
=
pow
(
2
,
nbL1Bands
)
-
1
# All DTF masks are the same for all bands
# so we can take one mask per resolution to output the DTF per resolution
l1BandId
=
l_BandsDefinitions
.
get_band_id_in_l1
(
l_ListOfBand
[(
resol
*
nbL1Bands
)
-
1
])
l_MapBandDetFnames
=
self
.
_l1_image_info
.
MuscateData
[
"ZoneMaskFileNames"
][
l1BandId
]
for
det
,
filename
in
l_MapBandDetFnames
.
items
():
l_ShortFileName
=
os
.
path
.
basename
(
filename
)
l_l2DTFFilename
=
l_ShortFileName
.
replace
(
"_L1C_"
,
"_L2A_"
)
l_OldName
=
"{}.tif"
.
format
(
l_ListOfBand
[(
resol
*
nbL1Bands
)
-
1
])
l_NewName
=
"{}-D{}.tif"
.
format
(
l_StrResolution
,
det
)
l_DTFFilenameWithResol
=
l_l2DTFFilename
.
replace
(
l_OldName
,
l_NewName
)
l_OutputFilename
=
os
.
path
.
join
(
l_MASKSDirectory
,
l_DTFFilenameWithResol
)
bmexpr
=
"im1b1 == {} ? {} : 0"
.
format
(
det
,
l_OutputValue
)
extract_channel_app
=
band_math
([
filename
],
bmexpr
,
l_OutputFilename
+
":uint8"
,
write_output
=
True
,
)
# *************************************************************************************************************
# **** END LOOP on RESOLUTION *****************************************
# *************************************************************************************************************
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment