...
Code Block |
---|
language | py |
---|
title | Retrieve EFAS model outputsHistorical river discharge |
---|
collapse | true |
---|
|
import cdsapi
c = cdsapi.Client()
# Climatology river discharge
c.retrieve('efas-historical', {
"format": "netcdf",
"hday": ["15","16","17","18"],
"hmonth": "november",
"hyear": "2020",
"model_levels": "surface_level",
"system_version": "version_4_0",
"time": ["00:00","06:00","18:00"],
"variable": "river_discharge_in_the_last_6_hours"
},
'clim_2020111500.nc') |
Code Block |
---|
language | py |
---|
title | Forecast river discharge |
---|
collapse | true |
---|
|
import cdsapi
#c Forecast river discharge= cdsapi.Client()
c.retrieve(
'efas-forecast',
{
'format': 'netcdf',
'originating_centre': 'ecmwf',
'product_type': 'ensemble_perturbed_forecasts',
'variable': 'river_discharge_in_the_last_6_hours',
'model_levels': 'surface_level',
'year': '2020',
'month': '11',
'day': '15',
'time': '00:00',
'leadtime_hour': [
'6', '12', '18',
'24', '30', '36',
'42', '48', '54',
'60', '66', '72',
],
},
'eue_2020111500.nc') |
Code Block |
---|
language | py |
---|
title | Forecast volumetric soil moisture and soil depth |
---|
collapse | true |
---|
|
import cdsapi
c = cdsapi.Client()
# Forecast soil moisture
c.retrieve(
'efas-forecast',
{
'format': 'netcdf',
'originating_centre': 'ecmwf',
'product_type': 'high_resolution_forecast',
'variable': [
'soil_depth', 'volumetric_soil_moisture',
],
'model_levels': 'soil_levels',
'year': '2019',
'month': '01',
'day': '30',
'time': '00:00',
'leadtime_hour': [
'6', '12', '18',
'24', '30', '36',
'42', '48', '54',
'60', '66', '72',
],
'soil_level': [
'1', '2', '3',
],
},
'eud_2019013000.nc') |
Code Block |
---|
language | py |
---|
title | Forecast snow depth water equivalent |
---|
collapse | true |
---|
|
import cdsapi
c = cdsapi.Client()
# forecast snow depth water equivalent
c.retrieve(
'efas-forecast',
{
'format': 'netcdf',
'originating_centre': 'ecmwf',
'variable': 'snow_depth_water_equivalent',
'product_type': 'control_forecast',
'model_levels': 'surface_level',
'year': '2021',
'month': '01',
'day': '30',
'time': '00:00',
'leadtime_hour': [
'6', '12', '18',
'24', '30', '36',
'42', '48', '54',
'60', '66', '72',
'78', '84', '90',
'96', '102',
],
},
'esd_2021013000.nc')
|
Auxiliary data
From the CDS Static files link, download the following NetCDFsNetCDF:
thmin1.nc, thmin2.nc, thmin3.nc, thmax1.nc, thmax2.nc, thmax3.nc
Info |
---|
When the marsurl will be in production one can download the auxiliary data simply requesting them through a CDS API request: Note: the soil depth is now part of the auxiliary data. Before it was downloaded as you would download a model output. Code Block |
---|
language | py |
---|
title | Retrieve auxiliary files |
---|
collapse | true |
---|
| import cdsapi
c = cdsapi.Client()
c.retrieve(
'efas-forecast,
{
'format': 'netcdf',
'variable': [
'field_capacity', 'wilting_point', 'soil_depth'
],
'soil_level': [
'1', '2', '3',
],
},
'auxiliary.zip') |
And then unzip the auxiliary.zip Code Block |
---|
language | bash |
---|
theme | Emacs |
---|
title | unzip |
---|
| $ unzip auxiliary.zip
Archive: auxiliary.zip
extracting: thmax_1.nc
extracting: thmin_1.nc
extracting: thmax_2.nc
extracting: thmin_2.nc
extracting: thmax_3.nc
extracting: thmin_3.nc
|
|
Plot map discharge
Code Block |
---|
language | py |
---|
title | Discharge map |
---|
collapse | true |
---|
|
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cf
import numpy as np
import pandas as pd
import xarray as xr
var_name = "dis06"
ds = xr.open_dataset('../data/clim_2020111500.nc')
cmap = plt.cm.get_cmap('jet').copy()
cmap.set_under('white')
# set the coordinate reference system for EFAS
crs = ccrs.LambertAzimuthalEqualArea(central_longitude=10,central_latitude=52,false_easting=4321000,false_northing=3210000)
# define the filter for visualizing only discharge above that value
vmin = 20
# selecting a date
ds = ds[var_name].isel(time=1)
# Plot map discharge > 20 m/s
fig, ax = plt.subplots(1,1,subplot_kw={'projection': crs}, figsize=(20,20) )
ax.gridlines(crs=crs, linestyle="-")
ax.coastlines()
ax.add_feature(cf.BORDERS)
sc = ds[var_name].plot(ax=ax,cmap=cmap,vmin=vmin,add_colorbar=False)
ax.set_title(f'{ds[var_name].long_name}> {vmin} $m^{3}s^{-1}$')
cbar = plt.colorbar(sc, shrink=.5,)
cbar.set_label(ds[var_name].GRIB_name) |
...