Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Clément Haëck
submeso-color
Commits
86521a31
Commit
86521a31
authored
Sep 15, 2021
by
Clément Haëck
Browse files
Add make_land for GLOBAL_025
parent
f23ea5cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
Compute/make_land.py
Compute/make_land.py
+15
-0
No files found.
Compute/make_land.py
View file @
86521a31
"""Obtain land masks."""
from
os
import
path
import
numpy
as
np
import
xarray
as
xr
...
...
@@ -31,6 +32,7 @@ def write_land(ds, land, filename, grid):
if
'time'
in
ds
.
land
.
dims
:
ds
=
ds
.
isel
(
time
=
0
)
ds
=
enlarge
(
ds
)
ds
=
ds
.
reset_coords
(
drop
=
True
)
ds
.
to_netcdf
(
filename
,
encoding
=
{
'land'
:
{
'zlib'
:
True
}})
return
ds
...
...
@@ -38,6 +40,11 @@ def write_land(ds, land, filename, grid):
def
enlarge
(
ds
):
n_km
=
20
n
=
int
(
n_km
/
abs
(
ds
.
lat
.
diff
(
'lat'
).
mean
().
values
*
111
))
if
n
<
1
:
ds
[
'land_large'
]
=
ds
[
'land'
]
return
ds
N
=
2
*
n
+
1
pos
=
np
.
indices
([
N
,
N
])
-
n
rad
=
np
.
linalg
.
norm
(
pos
,
2
,
axis
=
0
)
...
...
@@ -60,6 +67,14 @@ def enlarge(ds):
def
make_land
(
args
):
# 1/4°
grid
=
'GLOBAL_025'
filename
=
get_filename
(
grid
,
args
)
ds
=
xr
.
open_dataset
(
path
.
join
(
lib
.
root_data
,
args
[
'region'
],
'zones'
,
'ERA5_land_area_fraction.nc'
))
land
=
ds
.
sftlf
>
0.1
write_land
(
ds
,
land
,
filename
,
grid
)
# 1km
grid
=
'1km'
filename
=
get_filename
(
grid
,
args
)
...
...
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