...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# create a local virtual environment, you can call it as you wish, here 'myenv' is used.
conda create -n myenv python=3.8
# add repository channel
conda config --add channels conda-forge
# activate the local environment.
conda activate myenv
# install the required packages
conda install -c conda-forge/label/main xarray cfgrib eccodes
conda install cartopy netcdf4 matplotlib
# install the cdsapi
pip install cdsapi
|
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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') # Forecast river discharge 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') # 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') |
...
thmin1.nc, thmin2.nc, thmin3.nc, thmax1.nc, thmax2.nc, thmax3.nc
When the marsurl will be in production one can access download the auxiliary data simply requesting then them through a CDS API request:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import cdsapi c = cdsapi.Client() c.retrieve( 'efas-forecast, { 'format': 'netcdf', 'variable': [ 'field_capacity', 'wilting_point', ], 'soil_level': [ '1', '2', '3', ], }, 'auxiliary.zip') |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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_199103002020111500.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["dis06"var_name].plot(ax=ax,cmap=cmap,vmin=20vmin,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].dis06.GRIB_name) |
Plot Discharge Timeseries
...