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
9f362b40
Commit
9f362b40
authored
2 years ago
by
pascal.mouquet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
download_eodag
parent
c8a619a2
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/download_eodag.py
+59
-7
59 additions, 7 deletions
sen2chain/download_eodag.py
with
59 additions
and
7 deletions
sen2chain/download_eodag.py
+
59
−
7
View file @
9f362b40
...
...
@@ -55,13 +55,20 @@ class S2cEodag:
def
search
(
self
,
productType
=
"
S2_MSI_
L1C
"
,
productType
:
str
=
"
L1C
"
,
start
:
str
=
"
2015-01-01
"
,
end
:
str
=
"
9999-01-01
"
,
):
if
productType
==
"
L1C
"
:
self
.
productType
=
"
S2_MSI_L1C
"
outputs_prefix
=
Path
(
Config
().
get
(
"
l1c_path
"
))
/
self
.
name
elif
productType
==
"
L2A
"
:
self
.
productType
=
"
S2_MSI_L2A
"
outputs_prefix
=
Path
(
Config
().
get
(
"
l2a_path
"
))
/
self
.
name
default_search_criteria
=
dict
(
productType
=
productType
,
productType
=
self
.
productType
,
start
=
start
,
end
=
end
)
...
...
@@ -71,11 +78,56 @@ class S2cEodag:
**
default_search_criteria
)
logger
.
info
(
"
{} products were found given the above search criteria
"
.
format
(
len
(
self
.
products
)))
logger
.
info
(
self
.
products
)
logger
.
info
([
p
.
properties
[
"
storageStatus
"
]
for
p
in
self
.
products
])
#### Vériffier ici si le produit existe déjà en local
# ~ logger.info(outputs_prefix)
for
p
in
self
.
products
:
# ~ logger.info("location: {}".format(p.location))
if
(
outputs_prefix
/
(
p
.
properties
[
"
title
"
]
+
"
.SAFE
"
)).
exists
():
p
.
location
=
"
file://
"
+
str
(
outputs_prefix
/
(
p
.
properties
[
"
title
"
]
+
"
.SAFE
"
))
logger
.
info
(
"
Product {} locally present
"
.
format
(
p
.
properties
[
"
title
"
]))
else
:
logger
.
info
(
"
Product {} locally absent
"
.
format
(
p
.
properties
[
"
title
"
]))
# ~ logger.info("location: {}".format(p.location))
# ~ logger.info("{} products were found given the above search criteria".format(len(self.products)))
# ~ logger.info(self.products)
# ~ logger.info([p.properties["storageStatus"] for p in self.products])
logger
.
info
(
"
{} products were found given the above search criteria
"
.
format
(
len
(
self
.
products
)))
logger
.
info
(
"
{} products were found given the above search criteria, online
"
.
format
(
len
(
self
.
products
.
filter_online
())))
# ~
logger.info("{} products were found given the above search criteria".format(len(self.products)))
# ~
logger.info("{} products were found given the above search criteria, online".format(len(self.products.filter_online())))
def
download
(
self
,
product_id
,
outputs_prefix
:
str
=
None
,
extract
:
bool
=
True
,
delete_archive
:
bool
=
True
,
):
######### faudrait ici récupérer le type de produit L1C/L2A du nom du product_id et adapter le dossier en conséquence
if
not
outputs_prefix
:
if
self
.
productType
==
"
S2_MSI_L1C
"
:
root_path
=
"
l1c_path
"
elif
self
.
productType
==
"
S2_MSI_L2A
"
:
root_path
=
"
l2a_path
"
outputs_prefix
=
str
(
Path
(
Config
().
get
(
root_path
))
/
self
.
name
)
########## faudrait aussi mettre une condition sur le online
########## et si offline supprimer les retry
downloaded_path
=
self
.
dag
.
download
(
product_id
,
outputs_prefix
=
outputs_prefix
,
extract
=
extract
,
delete_archive
=
delete_archive
,
)
if
Path
(
downloaded_path
).
stem
==
Path
(
downloaded_path
).
parent
.
stem
:
upper_location
=
Path
(
downloaded_path
).
parent
.
parent
/
Path
(
downloaded_path
).
name
Path
(
downloaded_path
).
replace
(
upper_location
)
product_id
.
location
=
"
file://
"
+
str
(
upper_location
)
Path
(
downloaded_path
).
parent
.
rmdir
()
logger
.
info
(
"
Moving up SAVE file
"
)
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