Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Climax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
earth_observation_public
Climax
Commits
894a0199
Commit
894a0199
authored
3 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented support for multiple users.
parent
93408d75
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
climax/main/preprocess/download_ERA5.py
+39
-9
39 additions, 9 deletions
climax/main/preprocess/download_ERA5.py
with
39 additions
and
9 deletions
climax/main/preprocess/download_ERA5.py
+
39
−
9
View file @
894a0199
...
...
@@ -5,18 +5,27 @@
# builtins
import
os
import
pathlib
from
joblib
import
Parallel
,
delayed
# externals
import
cdsapi
import
numpy
as
np
# locals
from
climax.core.constants
import
ERA5_P_VARIABLES
,
ERA5_VARIABLES
from
climax.main.io
import
ERA5_PATH
# ERA5 predictor variables on pressure levels
ERA5_P_VARIABLES
=
[
'
geopotential
'
,
'
temperature
'
,
'
u_component_of_wind
'
,
'
v_component_of_wind
'
,
'
specific_humidity
'
]
# path to store downloaded ERA-5 data
ERA5_PATH
=
pathlib
.
Path
(
'
/mnt/CEPH_PROJECTS/FACT_CLIMAX/REANALYSIS/
'
)
# user: Daniel or Alice
# @Alice: comment Daniel, activate Alice
user
=
'
Daniel
'
# user = 'Alice'
# pressure levels
pressure_levels
=
[
'
850
'
,
'
50
0
'
]
pressure_levels
=
[
'
1000
'
,
'
850
'
,
'
700
'
,
'
500
'
,
'
25
0
'
]
# time period
years
=
[
str
(
y
)
for
y
in
np
.
arange
(
1981
,
2011
)]
...
...
@@ -37,6 +46,22 @@ CONFIG = {
'
area
'
:
area
}
# whether to overwrite existing files
OVERWRITE
=
False
# whether to skip variables on single levels
SKIP_SINGLE_LEVELS
=
True
# variables depending on user
if
user
==
'
Daniel
'
:
ERA5_VARIABLES
=
[
'
geopotential
'
,
'
temperature
'
,
'
u_component_of_wind
'
,
'
mean_sea_level_pressure
'
,
'
orography
'
,
'
2m_temperature
'
]
if
user
==
'
Alice
'
:
ERA5_VARIABLES
=
[
'
v_component_of_wind
'
,
'
specific_humidity
'
,
'
surface_pressure
'
,
'
2m_dewpoint_temperature
'
,
'
total_precipitation
'
]
if
__name__
==
'
__main__
'
:
...
...
@@ -60,18 +85,23 @@ if __name__ == '__main__':
product
=
'
reanalysis-era5-pressure-levels
'
CONFIG
[
'
pressure_level
'
]
=
pressure_levels
# pressure levels
else
:
# whether to skip single-level variables
if
SKIP_SINGLE_LEVELS
:
continue
# "orography" variable was recently renamed to "geopotential": this
# results in conflicting file names
var
=
'
geopotential
'
if
var
==
'
orography
'
else
var
# download configuration: ERA5 variable on single level
product
=
'
reanalysis-era5-single-levels
'
if
'
pressure_level
'
in
CONFIG
:
_
=
CONFIG
.
pop
(
'
pressure_level
'
)
# remove pressure levels
# "orography" variable was recently renamed to "geopotential": this
# results in conflicting file names
var
=
'
geopotential
'
if
var
==
'
orography
'
else
var
# split the download to the different years: CDS API cannot handle
# requests over the whole time period
Parallel
(
n_jobs
=
min
(
len
(
years
),
os
.
cpu_count
()),
verbose
=
51
)(
delayed
(
c
.
retrieve
)(
product
,
{
**
CONFIG
,
**
{
'
variable
'
:
var
,
'
year
'
:
year
}},
file
)
for
file
,
year
in
zip
(
files
,
years
)
if
not
file
.
exists
())
for
file
,
year
in
zip
(
files
,
years
)
if
(
not
file
.
exists
()
or
OVERWRITE
))
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