Commit 86521a31 authored by Clément Haëck's avatar Clément Haëck
Browse files

Add make_land for GLOBAL_025

parent f23ea5cc
"""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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment