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
9749ac2b
Commit
9749ac2b
authored
4 years ago
by
pascal.mouquet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
New NDR function more generic to compute indices, new IRECI
parent
7dddbec5
No related branches found
No related tags found
No related merge requests found
Pipeline
#30
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sen2chain/indices.py
+95
-139
95 additions, 139 deletions
sen2chain/indices.py
sen2chain/indices_functions.py
+259
-297
259 additions, 297 deletions
sen2chain/indices_functions.py
with
354 additions
and
436 deletions
sen2chain/indices.py
+
95
−
139
View file @
9749ac2b
...
...
@@ -13,9 +13,9 @@ import os
# type annotations
from
typing
import
Union
,
List
from
.indices_functions
import
(
create_raw_ndvi
,
create_raw_ndre
,
create_raw_ndwigao
,
create_raw_ndwimcf
,
from
.indices_functions
import
(
create_raw_ndr
,
create_raw_ireci
,
#~ create_raw_ndvi, create_raw_ndre, create_raw_ndwigao, create_raw_ndwimcf, create_raw_mndwi
create_raw_bigr
,
create_raw_birnir
,
create_raw_bibg
,
create_raw_mndwi
,
create_raw_ndr
,
create_masked_indice
,
index_tiff_2_jp2
)
from
.colormap
import
matplotlib_colormap_to_rgb
,
create_colormap
,
create_rvb
...
...
@@ -66,7 +66,6 @@ class Ndvi(Indice):
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
colormap
=
cm
.
RdYlGn
# _colors_table_path = functions_data_path = Path("../share/data/RdYlGn.lut")
def
__init__
(
self
,
l2a_product_object
,
cm_product_object
):
if
(
l2a_product_object
or
cm_product_object
)
is
None
:
...
...
@@ -75,10 +74,8 @@ class Ndvi(Indice):
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
...
...
@@ -100,11 +97,12 @@ class Ndvi(Indice):
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
create_raw_nd
vi
(
nir
_path
=
self
.
l2a_product
.
b08_10m
,
vir
_path
=
self
.
l2a_product
.
b04_10m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
create_raw_nd
r
(
b1
_path
=
self
.
l2a_product
.
b08_10m
,
b2
_path
=
self
.
l2a_product
.
b04_10m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
))
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
...
...
@@ -112,11 +110,6 @@ class Ndvi(Indice):
masked_indice_filename
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
self
.
ext
masked_indice_raw
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
self
.
ext_raw
#~ if self.l2a_product.user_cloud_mask is None:
#~ raise ValueError("Cloud mask does not exist")
#~ masked_indice_filename = self.indice_stem + "_MASKED" + self.ext
#~ masked_indice_raw = self.indice_stem + "_MASKED" + self.ext_raw
if
(
out_path
/
masked_indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
masked_indice_filename
))
else
:
...
...
@@ -128,7 +121,8 @@ class Ndvi(Indice):
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
20
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
...
...
@@ -146,24 +140,11 @@ class Ndvi(Indice):
logger
.
info
(
"
{} already exists
"
.
format
(
quicklook_filename
))
else
:
logger
.
info
(
"
creating quicklook
"
)
# create_colormap(raster=(self.out_path / self.indice_filename),
# cloud_mask=self.l2a_product.user_cloud_mask,
# # lut_dict=get_colormap(self._colors_table_path.absolute()),
# lut_dict=cmap, clouds_color="white",
# out_path=(self.out_path / quicklook_filename))
#~ create_colormap2(raster=(self.out_path / self.indice_filename),
#~ cloud_mask=self.l2a_product.user_cloud_mask,
#~ # lut_dict=get_colormap(self._colors_table_path.absolute()),
#~ lut_dict=cmap, clouds_color="white",
#~ out_path=(self.out_path / quicklook_filename))
create_rvb
(
raster
=
(
self
.
out_path
/
self
.
indice_filename
),
cloud_mask
=
self
.
cm_product
.
path
,
# lut_dict=get_colormap(self._colors_table_path.absolute()),
lut_dict
=
cmap
,
clouds_color
=
"
white
"
,
out_path
=
(
self
.
out_path
/
quicklook_filename
))
#~ IndiceProduct(identifier = self.indice_filename).init_md()
#~ IndiceProduct(identifier = masked_indice_filename).init_md()
#~ IndiceProduct(identifier = quicklook_filename).init_md()
class
NdwiMcf
(
Indice
):
"""
...
...
@@ -176,7 +157,6 @@ class NdwiMcf(Indice):
filename_template
=
"
{product_identifier}_NDWIMCF{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
#~ colormap = cm.RdYlBu
colormap
=
cm
.
colors
.
LinearSegmentedColormap
.
from_list
(
""
,
[
"
green
"
,
"
white
"
,
"
blue
"
])
...
...
@@ -187,10 +167,8 @@ class NdwiMcf(Indice):
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
...
...
@@ -207,11 +185,12 @@ class NdwiMcf(Indice):
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
create_raw_nd
wimcf
(
nir
_path
=
self
.
l2a_product
.
b0
8
_10m
,
green
_path
=
self
.
l2a_product
.
b0
3
_10m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
create_raw_nd
r
(
b1
_path
=
self
.
l2a_product
.
b0
3
_10m
,
b2
_path
=
self
.
l2a_product
.
b0
8
_10m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
))
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
...
...
@@ -230,7 +209,8 @@ class NdwiMcf(Indice):
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
20
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
...
...
@@ -254,21 +234,18 @@ class NdwiMcf(Indice):
out_path
=
(
self
.
out_path
/
quicklook_filename
))
class
GenericNDR
(
Indice
):
class
NdwiGao
(
Indice
):
"""
ND
R = (B1-B2) / (B1+B2
)
ND
WI(Gao) = (NIR-SWIR) / (NIR+SWIR
)
B1
: band
B2
: band
NIR
: band
08
SWIR
: band
11
"""
name
=
"
GENERICNDR
"
filename_template
=
"
{product_identifier}_
GENERICNDR
{ext}
"
name
=
"
NDWIGAO
"
filename_template
=
"
{product_identifier}_
NDWIGAO
{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
#~ colormap = cm.RdYlBu
colormap
=
cm
.
colors
.
LinearSegmentedColormap
.
from_list
(
""
,
[
"
red
"
,
"
white
"
,
"
blue
"
])
colormap
=
cm
.
RdYlBu
def
__init__
(
self
,
l2a_product_object
,
cm_product_object
):
if
(
l2a_product_object
or
cm_product_object
)
is
None
:
...
...
@@ -277,10 +254,8 @@ class GenericNDR(Indice):
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
...
...
@@ -294,6 +269,7 @@ class GenericNDR(Indice):
)
->
None
:
"""
process
"""
self
.
out_path
=
out_path
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
...
...
@@ -301,9 +277,8 @@ class GenericNDR(Indice):
b2_path
=
self
.
l2a_product
.
b11_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
...
...
@@ -315,18 +290,19 @@ class GenericNDR(Indice):
logger
.
info
(
"
{} already exists
"
.
format
(
masked_indice_filename
))
else
:
if
(
out_path
/
self
.
indice_raw
).
exists
():
ndwi
mcf_path
=
(
out_path
/
self
.
indice_raw
)
ndwi
gao_name
=
(
out_path
/
self
.
indice_raw
)
else
:
ndwi
mcf_path
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
ndwi
mcf_path
,
ndwi
gao_name
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
ndwi
gao_name
,
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
#~ os.remove(str(out_path / masked_indice_raw))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
20
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
#~
os.remove(str(out_path / self.indice_raw))
os
.
remove
(
str
(
out_path
/
self
.
indice_raw
))
logger
.
info
(
"
Removing {}
"
.
format
(
self
.
indice_raw
))
except
:
pass
...
...
@@ -334,8 +310,7 @@ class GenericNDR(Indice):
if
quicklook
:
cmap
=
matplotlib_colormap_to_rgb
(
self
.
colormap
,
revers
=
False
)
quicklook_filename
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
"
_QL.tif
"
quicklook_filename
=
self
.
indice_stem
+
"
_QUICKLOOK.tif
"
if
(
self
.
out_path
/
quicklook_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
quicklook_filename
))
else
:
...
...
@@ -346,18 +321,18 @@ class GenericNDR(Indice):
out_path
=
(
self
.
out_path
/
quicklook_filename
))
class
N
dwi
Gao
(
Indice
):
class
Mn
dwi
(
Indice
):
"""
NDWI
(Gao) = (NIR
-SWIR) / (
NIR
+SWIR)
M
NDWI
= (GREEN
-SWIR) / (
GREEN
+SWIR)
NIR
: band 0
8
GREEN
: band 0
3
SWIR: band 11
"""
name
=
"
NDWI
GAO
"
filename_template
=
"
{product_identifier}_NDWI
GAO
{ext}
"
name
=
"
M
NDWI
"
filename_template
=
"
{product_identifier}_
M
NDWI{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
colormap
=
cm
.
RdYlBu
colormap
=
cm
.
BrBG
def
__init__
(
self
,
l2a_product_object
,
cm_product_object
):
if
(
l2a_product_object
or
cm_product_object
)
is
None
:
...
...
@@ -366,11 +341,8 @@ class NdwiGao(Indice):
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
...
...
@@ -388,30 +360,32 @@ class NdwiGao(Indice):
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
create_raw_nd
wigao
(
nir
_path
=
self
.
l2a_product
.
b0
8
_10m
,
swir
_path
=
self
.
l2a_product
.
b11_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
create_raw_nd
r
(
b1
_path
=
self
.
l2a_product
.
b0
3
_10m
,
b2
_path
=
self
.
l2a_product
.
b11_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
))
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
raise
ValueError
(
"
Cloud mask does not exist
"
)
masked_indice_filename
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
self
.
ext
masked_indice_raw
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
self
.
ext_raw
if
(
out_path
/
masked_indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
masked_indice_filename
))
else
:
if
(
out_path
/
self
.
indice_raw
).
exists
():
ndwi
gao
_name
=
(
out_path
/
self
.
indice_raw
)
m
ndwi_name
=
(
out_path
/
self
.
indice_raw
)
else
:
ndwi
gao
_name
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
ndwi
gao
_name
,
m
ndwi_name
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
m
ndwi_name
,
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
20
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
...
...
@@ -423,33 +397,29 @@ class NdwiGao(Indice):
if
quicklook
:
cmap
=
matplotlib_colormap_to_rgb
(
self
.
colormap
,
revers
=
False
)
quicklook_filename
=
self
.
indice_stem
+
"
_
QUICKLOOK
.tif
"
quicklook_filename
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
"
_QL
.tif
"
if
(
self
.
out_path
/
quicklook_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
quicklook_filename
))
else
:
logger
.
info
(
"
creating quicklook
"
)
# create_colormap(raster=(self.out_path / self.indice_filename),
# cloud_mask=self.l2a_product.user_cloud_mask,
# lut_dict=cmap, clouds_color="white",
# out_path=(self.out_path / quicklook_filename))
create_rvb
(
raster
=
(
self
.
out_path
/
self
.
indice_filename
),
cloud_mask
=
self
.
cm_product
.
path
,
lut_dict
=
cmap
,
clouds_color
=
"
white
"
,
out_path
=
(
self
.
out_path
/
quicklook_filename
))
class
Mndwi
(
Indice
):
class
Ndre
(
Indice
):
"""
M
ND
WI
= (
GREEN-SWIR) / (GREEN+SWIR
)
ND
RE
= (
NIR - REDEDGE) / (NIR + REDEDGE
)
GREEN
: band 0
3
SWIR
: band
11
NIR
: band 0
8
REDEDGE
: band
05
"""
name
=
"
M
ND
WI
"
filename_template
=
"
{product_identifier}_
M
ND
WI
{ext}
"
name
=
"
ND
RE
"
filename_template
=
"
{product_identifier}_ND
RE
{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
colormap
=
cm
.
BrBG
colormap
=
cm
.
Spectral
def
__init__
(
self
,
l2a_product_object
,
cm_product_object
):
if
(
l2a_product_object
or
cm_product_object
)
is
None
:
...
...
@@ -457,33 +427,31 @@ class Mndwi(Indice):
else
:
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
def
process_indice
(
self
,
out_path
:
pathlib
.
PosixPath
,
reprocess
:
bool
=
False
,
nodata_clouds
:
bool
=
False
,
quicklook
:
bool
=
False
)
->
None
:
def
process_indice
(
self
,
out_path
:
pathlib
.
PosixPath
,
reprocess
:
bool
=
False
,
nodata_clouds
:
bool
=
False
,
quicklook
:
bool
=
False
)
->
None
:
"""
process
"""
self
.
out_path
=
out_path
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
create_raw_
m
nd
wi
(
green
_path
=
self
.
l2a_product
.
b0
3
_10m
,
swir
_path
=
self
.
l2a_product
.
b
11
_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
create_raw_nd
r
(
b1
_path
=
self
.
l2a_product
.
b0
8
_10m
,
b2
_path
=
self
.
l2a_product
.
b
05
_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
))
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
20
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
...
...
@@ -495,14 +463,15 @@ class Mndwi(Indice):
logger
.
info
(
"
{} already exists
"
.
format
(
masked_indice_filename
))
else
:
if
(
out_path
/
self
.
indice_raw
).
exists
():
m
nd
wi
_name
=
(
out_path
/
self
.
indice_raw
)
nd
re
_name
=
(
out_path
/
self
.
indice_raw
)
else
:
m
nd
wi
_name
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
m
nd
wi
_name
,
nd
re
_name
=
(
out_path
/
self
.
indice_filename
)
create_masked_indice
(
indice_path
=
nd
re
_name
,
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
20
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
...
...
@@ -510,10 +479,8 @@ class Mndwi(Indice):
logger
.
info
(
"
Removing {}
"
.
format
(
self
.
indice_raw
))
except
:
pass
if
quicklook
:
cmap
=
matplotlib_colormap_to_rgb
(
self
.
colormap
,
revers
=
False
)
quicklook_filename
=
self
.
indice_stem
+
"
_
"
+
self
.
cm_product
.
suffix
+
"
_QL.tif
"
if
(
self
.
out_path
/
quicklook_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
quicklook_filename
))
...
...
@@ -525,19 +492,20 @@ class Mndwi(Indice):
out_path
=
(
self
.
out_path
/
quicklook_filename
))
class
Ndre
(
Indice
):
class
IRECI
(
Indice
):
"""
NDRE = (NIR - REDEDGE) / (NIR + REDEDGE)
NIR: band 08
REDEDGE: band 05
IRECI = (NIR-R)/(RE1/RE2)
NIR: band 783nm (B7 - 20m)
R: band 665nm (B4 - 10m)
RE1: band 705nm (B5 - 20m)
RE2: band 740nm (B6 - 20m)
"""
name
=
"
NDRE
"
filename_template
=
"
{product_identifier}_
NDRE
{ext}
"
name
=
"
IRECI
"
filename_template
=
"
{product_identifier}_
IRECI
{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
colormap
=
cm
.
Spectral
def
__init__
(
self
,
l2a_product_object
,
cm_product_object
):
if
(
l2a_product_object
or
cm_product_object
)
is
None
:
raise
ValueError
(
"
A L2aProduct and NewCloudMask objects must be provided
"
)
...
...
@@ -545,10 +513,8 @@ class Ndre(Indice):
self
.
l2a_product
=
l2a_product_object
self
.
cm_product
=
cm_product_object
# output path
self
.
out_path
=
None
# filenames
self
.
indice_stem
=
self
.
filename_template
.
format
(
product_identifier
=
self
.
l2a_product
.
identifier
,
ext
=
""
)
self
.
indice_filename
=
self
.
indice_stem
+
self
.
ext
self
.
indice_raw
=
self
.
indice_stem
+
self
.
ext_raw
...
...
@@ -565,11 +531,14 @@ class Ndre(Indice):
if
(
out_path
/
self
.
indice_filename
).
exists
()
and
not
reprocess
:
logger
.
info
(
"
{} already exists
"
.
format
(
self
.
indice_filename
))
else
:
create_raw_ndre
(
nir_path
=
self
.
l2a_product
.
b08_10m
,
redge_path
=
self
.
l2a_product
.
b05_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
create_raw_ireci
(
b1_path
=
self
.
l2a_product
.
b07_20m
,
b2_path
=
self
.
l2a_product
.
b04_10m
,
b3_path
=
self
.
l2a_product
.
b05_20m
,
b4_path
=
self
.
l2a_product
.
b06_20m
,
out_path
=
(
out_path
/
self
.
indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
self
.
indice_raw
),
out_path
=
(
out_path
/
self
.
indice_filename
))
out_path
=
(
out_path
/
self
.
indice_filename
),
quality
=
30
)
if
nodata_clouds
:
if
not
self
.
cm_product
.
path
.
exists
():
...
...
@@ -588,7 +557,8 @@ class Ndre(Indice):
cloud_mask_path
=
self
.
cm_product
.
path
,
out_path
=
(
out_path
/
masked_indice_raw
))
index_tiff_2_jp2
(
img_path
=
(
out_path
/
masked_indice_raw
),
out_path
=
(
out_path
/
masked_indice_filename
))
out_path
=
(
out_path
/
masked_indice_filename
),
quality
=
30
)
os
.
remove
(
str
(
out_path
/
masked_indice_raw
))
try
:
...
...
@@ -609,20 +579,6 @@ class Ndre(Indice):
out_path
=
(
self
.
out_path
/
quicklook_filename
))
# A faire
class
IRECI
(
Indice
):
"""
IRECI =
"""
name
=
"
IRECI
"
filename_template
=
"
{product_identifier}_IRECI{ext}
"
ext
=
"
.jp2
"
ext_raw
=
"
.tif
"
colormap
=
cm
.
Spectral
class
BIGR
(
Indice
):
"""
Brightness Index Green Red = ( (GREEN² + RED²)/2 ) ^ 0.5
...
...
This diff is collapsed.
Click to expand it.
sen2chain/indices_functions.py
+
259
−
297
View file @
9749ac2b
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