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
29bcffde
Commit
29bcffde
authored
3 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Reproject and resample to target grid.
parent
3bdf91b7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
climax/core/cli.py
+10
-0
10 additions, 0 deletions
climax/core/cli.py
climax/main/preprocess_ERA5.py
+10
-0
10 additions, 0 deletions
climax/main/preprocess_ERA5.py
with
20 additions
and
0 deletions
climax/core/cli.py
+
10
−
0
View file @
29bcffde
...
@@ -132,6 +132,10 @@ def preprocess_era5_parser():
...
@@ -132,6 +132,10 @@ def preprocess_era5_parser():
# positional arguments
# positional arguments
# positional argument: path to the target grid file
parser
.
add_argument
(
'
grid
'
,
type
=
pathlib
.
Path
,
help
=
'
Path to the target grid file.
'
)
# positional argument: path to search for ERA5 NetCDF files
# positional argument: path to search for ERA5 NetCDF files
parser
.
add_argument
(
'
source
'
,
type
=
pathlib
.
Path
,
parser
.
add_argument
(
'
source
'
,
type
=
pathlib
.
Path
,
help
=
'
Path to search for ERA5 NetCDF files.
'
)
help
=
'
Path to search for ERA5 NetCDF files.
'
)
...
@@ -162,4 +166,10 @@ def preprocess_era5_parser():
...
@@ -162,4 +166,10 @@ def preprocess_era5_parser():
.
format
(
default
)),
default
=
False
,
nargs
=
'
?
'
,
.
format
(
default
)),
default
=
False
,
nargs
=
'
?
'
,
const
=
True
,
metavar
=
''
)
const
=
True
,
metavar
=
''
)
# optional argument: resampling mode
parser
.
add_argument
(
'
-m
'
,
'
--mode
'
,
type
=
str
,
help
=
'
Resampling mode {}.
'
.
format
(
default
),
default
=
'
bilinear
'
,
choices
=
CDO_RESAMPLING_MODES
,
metavar
=
''
)
return
parser
return
parser
This diff is collapsed.
Click to expand it.
climax/main/preprocess_ERA5.py
+
10
−
0
View file @
29bcffde
...
@@ -15,6 +15,7 @@ import xarray as xr
...
@@ -15,6 +15,7 @@ import xarray as xr
# locals
# locals
from
climax.core.cli
import
preprocess_era5_parser
from
climax.core.cli
import
preprocess_era5_parser
from
climax.core.constants
import
ERA5_VARIABLES
from
climax.core.constants
import
ERA5_VARIABLES
from
climax.core.utils
import
reproject_cdo
from
pysegcnn.core.logging
import
log_conf
from
pysegcnn.core.logging
import
log_conf
from
pysegcnn.core.utils
import
search_files
from
pysegcnn.core.utils
import
search_files
from
pysegcnn.core.trainer
import
LogConfig
from
pysegcnn.core.trainer
import
LogConfig
...
@@ -41,6 +42,11 @@ if __name__ == '__main__':
...
@@ -41,6 +42,11 @@ if __name__ == '__main__':
# check whether the source directory exists
# check whether the source directory exists
if
args
.
source
.
exists
():
if
args
.
source
.
exists
():
# check whether the target grid file exists
if
not
args
.
grid
.
exists
():
LOGGER
.
info
(
'
{} does not exist.
'
.
format
(
args
.
grid
))
sys
.
exit
()
# check whether a single variable is specified
# check whether a single variable is specified
variables
=
ERA5_VARIABLES
variables
=
ERA5_VARIABLES
if
args
.
variable
is
not
None
:
if
args
.
variable
is
not
None
:
...
@@ -92,6 +98,10 @@ if __name__ == '__main__':
...
@@ -92,6 +98,10 @@ if __name__ == '__main__':
LOGGER
.
info
(
'
Compressing NetCDF: {}
'
.
format
(
filename
))
LOGGER
.
info
(
'
Compressing NetCDF: {}
'
.
format
(
filename
))
ds
.
to_netcdf
(
filename
,
engine
=
'
h5netcdf
'
)
ds
.
to_netcdf
(
filename
,
engine
=
'
h5netcdf
'
)
# reproject and resample to target grid
reproject_cdo
(
args
.
grid
,
filename
,
filename
,
mode
=
args
.
mode
,
overwrite
=
args
.
overwrite
)
else
:
else
:
LOGGER
.
info
(
'
{} does not exist.
'
.
format
(
str
(
args
.
source
)))
LOGGER
.
info
(
'
{} does not exist.
'
.
format
(
str
(
args
.
source
)))
sys
.
exit
()
sys
.
exit
()
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