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
37bb2a57
Commit
37bb2a57
authored
5 years ago
by
pascal.mouquet_ird.fr
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of framagit.org:espace-dev/sen2chain
parents
9aadee48
96e18d79
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/automatization.py
+14
-8
14 additions, 8 deletions
sen2chain/automatization.py
with
14 additions
and
8 deletions
sen2chain/automatization.py
+
14
−
8
View file @
37bb2a57
...
...
@@ -3,7 +3,7 @@
"""
Module for automatized downloading, processing and time series computing of new Sentinel-2 images.
"""
import
time
import
logging
import
pandas
as
pd
import
numpy
as
np
...
...
@@ -148,24 +148,25 @@ class Automatization:
return
None
@staticmethod
def
_
five_
days_since_date
(
date
:
datetime
)
->
bool
:
"""
Checks if at least
five
days have passed since the date.
def
_
n
days_since_date
(
date
:
datetime
,
ndays
:
int
)
->
bool
:
"""
Checks if at least
n
days have passed since the date.
:param date: date to check.
:param ndays: number of days.
"""
time_period
=
datetime
.
today
()
-
date
if
time_period
.
days
<
4
:
if
time_period
.
days
<
ndays
:
return
False
return
True
def
_get_products_list
(
self
)
->
None
:
def
_get_products_list
(
self
,
revisit_period
)
->
None
:
"""
Merge each request dict into a single one.
"""
for
tile
,
request_date
in
self
.
_tiles_to_update
.
items
():
# Don't overload the server with useless requests :
# Sentinel-2 revisit time is 5 days
if
request_date
:
if
not
Automatization
.
_
five_
days_since_date
(
request_date
):
if
not
Automatization
.
_
n
days_since_date
(
request_date
,
revisit_period
):
logger
.
info
(
"
Too early to check {}
"
.
format
(
tile
))
continue
...
...
@@ -188,7 +189,8 @@ class Automatization:
indices_list
:
List
[
str
]
=
None
,
nodata_clouds
:
bool
=
True
,
quicklook
:
bool
=
True
,
hubs_limit
:
Dict
[
str
,
int
]
=
None
hubs_limit
:
Dict
[
str
,
int
]
=
None
,
revisit_period
:
int
=
2
,
)
->
None
:
"""
Runs automatization.
...
...
@@ -198,6 +200,7 @@ class Automatization:
:param indices_list: list of valid indices names that will be processed.
:param nodata_clouds: mask indices output rasters with a cloud-mask.
:param quicklook: creates a quicklook for each indice processed.
:param revisit_period: number of days, since last date, to check again for new images.
"""
logger
.
info
(
"
Running automatization
"
)
logger
.
info
(
"
Ignored tiles: {}
"
.
format
(
self
.
_get_ignored_tiles
(
self
)))
...
...
@@ -210,7 +213,7 @@ class Automatization:
hubs_limit
=
{
"
peps
"
:
3
,
"
scihub
"
:
2
}
self
.
_get_tiles_to_update
(
tiles_list
=
tiles
)
self
.
_get_products_list
()
self
.
_get_products_list
(
revisit_period
)
if
any
(
self
.
_products_list
.
values
()):
prods
=
DownloadAndProcess
(
identifiers
=
self
.
_products_list
,
hubs_limit
=
hubs_limit
,
...
...
@@ -223,6 +226,9 @@ class Automatization:
failed
=
prods
.
failed_products
if
failed
:
print
(
failed
)
# When working on a local network storage, pause the process in
# order to let the file to be checked by the filesystem (lags).
time
.
sleep
(
2
)
self
.
_update_df
()
self
.
_save_csv
()
...
...
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