Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Remote Modules
let-it-snow
Commits
abaf77c8
Commit
abaf77c8
authored
Nov 23, 2018
by
Germain Salgues
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH:add support for L8 new format in snow_annual_map
parent
6b1ef554
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
8 deletions
+27
-8
python/s2snow/snow_annual_map.py
python/s2snow/snow_annual_map.py
+17
-5
python/s2snow/snow_annual_map_evaluation.py
python/s2snow/snow_annual_map_evaluation.py
+2
-2
python/s2snow/snow_detector.py
python/s2snow/snow_detector.py
+1
-0
python/s2snow/snow_product_parser.py
python/s2snow/snow_product_parser.py
+7
-1
No files found.
python/s2snow/snow_annual_map.py
View file @
abaf77c8
...
...
@@ -132,7 +132,17 @@ class snow_annual_map():
self
.
use_l8_for_densification
=
params
.
get
(
"use_l8_for_densification"
,
False
)
if
self
.
use_l8_for_densification
:
self
.
l8_tile_id
=
params
.
get
(
"l8_tile_id"
)
self
.
l8_input_dir
=
str
(
params
.
get
(
"l8_input_dir"
))
self
.
l8_input_dir
=
str
(
op
.
join
(
params
.
get
(
"l8_input_dir"
),
self
.
l8_tile_id
))
if
not
os
.
path
.
exists
(
self
.
l8_input_dir
)
or
not
self
.
l8_tile_id
:
logging
.
error
(
"Cannot use L8 densification with "
+
str
(
self
.
l8_tile_id
)
+
", "
+
self
.
l8_input_dir
)
else
:
logging
.
info
(
"Using L8 densification with "
+
str
(
self
.
l8_tile_id
)
+
", "
+
self
.
l8_input_dir
)
# Define label for output snow product
self
.
label_no_snow
=
"0"
...
...
@@ -158,7 +168,7 @@ class snow_annual_map():
os
.
environ
[
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"
]
=
str
(
self
.
nbThreads
)
# search matching snow product
self
.
product_list
=
self
.
find_products
(
self
.
input_dir
,
self
.
tile_id
)
self
.
product_list
=
self
.
find_products
(
self
.
input_dir
,
self
.
tile_id
,
"SENTINEL2"
)
logging
.
debug
(
"Product list:"
)
logging
.
debug
(
self
.
product_list
)
...
...
@@ -169,7 +179,7 @@ class snow_annual_map():
# @TODO clean the loading of the L8 products to densify the timeserie
if
self
.
use_l8_for_densification
:
# search matching L8 snow product
l8_product_list
=
self
.
find_products
(
self
.
l8_input_dir
,
self
.
l8_tile_id
)
l8_product_list
=
self
.
find_products
(
self
.
l8_input_dir
,
self
.
l8_tile_id
,
"LANDSAT8"
)
logging
.
info
(
"L8 product list:"
)
logging
.
info
(
l8_product_list
)
...
...
@@ -315,7 +325,7 @@ class snow_annual_map():
shutil
.
copytree
(
self
.
path_tmp
,
dest_debug_dir
)
def
find_products
(
self
,
input_dir
,
tile_id
):
def
find_products
(
self
,
input_dir
,
tile_id
,
product_type
=
None
):
logging
.
info
(
"Retrieving products in "
+
input_dir
)
product_files
=
os
.
listdir
(
input_dir
)
product_list
=
[]
...
...
@@ -329,7 +339,9 @@ class snow_annual_map():
if
tile_id
in
product
.
tile_id
and
\
search_start_date
<=
product
.
acquisition_date
and
\
search_stop_date
>=
product
.
acquisition_date
:
product_list
.
append
(
product
)
if
(
product_type
is
not
None
)
and
(
product_type
in
product
.
platform
):
product_list
.
append
(
product
)
logging
.
info
(
"Keeping: "
+
str
(
product
))
except
Exception
:
logging
.
error
(
"Unable to load product :"
+
product_path
)
return
product_list
...
...
python/s2snow/snow_annual_map_evaluation.py
View file @
abaf77c8
...
...
@@ -123,7 +123,7 @@ class snow_annual_map_evaluation(snow_annual_map):
snow_annual_map
.
__init__
(
self
,
params
)
self
.
l8_tile_id
=
params
.
get
(
"l8_tile_id"
)
self
.
l8_input_dir
=
str
(
params
.
get
(
"l8_input_dir"
))
self
.
l8_input_dir
=
str
(
op
.
join
(
params
.
get
(
"l8_input_dir"
)
,
self
.
l8_tile_id
)
)
# Build useful paths
self
.
l8_dates_filename
=
op
.
join
(
self
.
path_tmp
,
"l8_inputs_dates.txt"
)
...
...
@@ -149,7 +149,7 @@ class snow_annual_map_evaluation(snow_annual_map):
os
.
environ
[
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS"
]
=
str
(
self
.
nbThreads
)
# search matching L8 snow product
self
.
product_list
=
self
.
find_products
(
self
.
l8_input_dir
,
self
.
l8_tile_id
)
self
.
product_list
=
self
.
find_products
(
self
.
l8_input_dir
,
self
.
l8_tile_id
,
"LANDSAT8"
)
logging
.
debug
(
"Product list:"
)
logging
.
debug
(
self
.
product_list
)
...
...
python/s2snow/snow_detector.py
View file @
abaf77c8
...
...
@@ -614,6 +614,7 @@ class snow_detector:
mask
=
x
**
2
+
y
**
2
<=
radius
**
2
struct
[
mask
]
=
1
# compute individual snow area size
(
labels
,
label_counts
)
=
np
.
unique
(
snowlabels
,
return_counts
=
True
)
labels_area
=
dict
(
zip
(
labels
,
label_counts
))
logging
.
debug
(
labels_area
)
...
...
python/s2snow/snow_product_parser.py
View file @
abaf77c8
...
...
@@ -57,7 +57,13 @@ class snow_product:
self
.
tile_id
=
name_splitted
[
3
]
self
.
flag
=
name_splitted
[
4
]
self
.
product_version
=
name_splitted
[
5
]
elif
"LANDSAT8"
in
self
.
platform
:
elif
"LANDSAT8-OLITIRS-XS"
==
self
.
platform
:
self
.
acquisition_date
=
str_to_datetime
(
name_splitted
[
1
],
MUSCATE_DATETIME_FORMAT
)
self
.
product_level
=
name_splitted
[
2
]
self
.
tile_id
=
name_splitted
[
3
]
self
.
flag
=
name_splitted
[
4
]
self
.
product_version
=
name_splitted
[
5
]
elif
"LANDSAT8"
in
self
.
platform
and
"N2A"
in
self
.
product_name
:
self
.
acquisition_date
=
str_to_datetime
(
name_splitted
[
3
],
"%Y%m%d"
)
self
.
product_level
=
name_splitted
[
4
]
self
.
tile_id
=
name_splitted
[
5
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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