Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Content Zone

Table of Contents


Set up the environment

Using conda ...

Cartopy, xarray,cfgrib,netcdf4,pyproj, matplotlib, cdsapi

EFAS

Retrieve data

...


Code Block

...

model outputs

Code Block
languagepybash
titleRetrieve EFAS model outputsSet up the python local environment and install required packages
collapsetrue
# 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

# install the cdsapi
pip install cdsapi

EFAS

Retrieve data

These exercises require EFAS model output parameters and auxiliary data. You can retrieve them using the CDS API, as described in the code block below:

Model outputs

Code Block
languagepy
titleRetrieve EFAS model outputs
collapsetrue
import cdsapi

c = cdsapi.Client()

# Climatology
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": "import cdsapi

c = cdsapi.Client()

# Climatology
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
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','clim_2020111500.nc')

# Forecast
c.retrieve(
    'efas-forecast',
    {
        'yearformat': '2020netcdf',
        'monthoriginating_centre': '11ecmwf',
        'dayproduct_type': '15ensemble_perturbed_forecasts',
        'timevariable': '00:00river_discharge_in_the_last_6_hours',
        'leadtimemodel_hourlevels': [
   'surface_level',
         '6year': '2020',
 '12',       'month': '1811',
        'day': '15',
        '24time',: '3000:00',
 '36',       'leadtime_hour': [
            '426', '4812', '5418',
            '6024', '6630', '7236',
        ],
    }'42',
 '48',   ''54',
            '60', '66', '72',
        ],
    },
    'eue_2020111500.nc')

# Forecast
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',
    : [
            '6', '12', '18',
            '24', '30', '36',
            '42', '48', '54',
            '60', '66', '72',
        ],
        'soil_level': [
            '1', '2', '3',
        ],
    },
    'eud_2019013000.nc')


Auxiliary data

From the CDS Static files link, download the following NetCDFs:

thmin1.nc, thmin2.nc, thmin3.nc, thmax1.nc, thmax2.nc, thmax3.nc


When the marsurl will be in production one can access the auxiliary data simply requesting then through a CDS API request:


Code Block
languagepy
collapsetrue
import cdsapi

c = cdsapi.Client()

c.retrieve(
    'efas-forecast,
    {
        '24format',: '30netcdf', '36',
            '42variable', '48', '54',: [
            '60field_capacity', '66', '72wilting_point',
        ],
        'soil_level': [
            '1', '2', '3',
        ],
    },
    'auxiliary.zip')

And then unzip the auxiliary.zip

Code Block
languagebash
collapsetrue
$ 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: 'eudthmin_2019013000.nc')

auxiliary data

Info

This is available only when marsurl adaptor will be in production. For the moment I am using the datasets from the test stack.

Before the marsurl

Code Block
languagepy
titleRetrieve EFAS auxiliary data
collapsetrue
dsd3.nc


Plot map discharge

In order to plot a map, we are going to use 

...