arlmet.converters.from_icon#

arlmet.converters.from_icon(datasets)[source]#

Convert ICON forecasts on a regular lat/lon grid to a Dataset for arlmet.write_dataset().

This reads DWD’s ICON-EU and ICON-D2 GRIB2 files on their regular lat/lon grids (DWD’s open data, regular-lat-lon_pressure-level and single-level, one file per variable, level and forecast step), taking the Datasets cfgrib.open_datasets() returns for them. HYSPLIT has no converter for ICON. Each valid time is one time step, on ICON’s pressure levels (vertical flag 2); the levels of each variable are stacked.

ICON’s precipitation and surface fluxes are totals and means from the start of the forecast. Each is written as the total or mean since the step before among the files given, of the same forecast (since the start of the forecast for its first): TPP1 is that precipitation per hour, as arw2arl writes WRF’s. A forecast’s step 0 has none. Where two files hold a field at the same valid time, the one with the shorter forecast step is used, as in from_gfs(), so the forecasts of several runs make one series, each step 0 taking its fluxes from the run before. A field a time step has no file for is written as a missing record there. The index record’s forecast hour is the step of the pressure-level fields.

ICON (cfgrib name)

ARL

conversion

FI (z)

HGTS

geopotential (m2 s-2) / 9.80665

T, U, V

TEMP, UWND, VWND

K, m s-1

OMEGA (w)

WWND

Pa s-1 to hPa s-1

RELHUM (r)

RELH

%

PS

PRSS

Pa to hPa

PMSL

MSLP

Pa to hPa

HSURF

SHGT

m, the same at every time step

T_G

TMPS

K

T_2M, RELHUM

T02M,

K, %

_2M

RH2M

U_10M, V_10M

U10M, V10M

m s-1

CLCT

TCLD

%

CAPE_ML,

CAPE,

J kg-1

CIN_ML

CINH

MH

PBLH

m

Z0

RGHS

m

TOT_PREC

TPP1

kg m-2 to m, per hour since the step before

ASHFL_S

SHTF

W m-2, sign changed (positive upward)

ALHFL_S

LHTF

W m-2, sign changed (positive upward)

ASWDIR_S +

DSWF

W m-2, direct plus diffuse downward

ASWDIFD_S

AUMFL_S,

UMOF,

N m-2

AVMFL_S

VMOF

cfgrib names some of these by ecCodes’ standard names (sp, t2m, tp, avg_slhtf, mld, fsr, …) and the rest by DWD’s; both, and DWD’s in lower case, are read.

Parameters:

datasets (Iterable[Dataset]) – The Datasets of ICON GRIB2 files, as cfgrib.open_datasets() returns them (each with scalar time, step and valid_time coordinates), one list after another. Datasets and variables not in the table are left out. Every time step must have the same pressure levels.

Returns:

The fields in arlmet.open_dataset()’s layout, with source "ICON" and each variable’s ARL units in its attrs.

Return type:

Dataset

Raises:

ValueError – If no Dataset holds pressure-level fields, a Dataset lacks its scalar times, a field is given twice for one step, the time steps have different pressure levels, or the grids differ.

Notes

ICON’s own grid (icosahedral, as in DWD’s global ICON files) and its model levels (heights that follow the terrain, which no ARL vertical coordinate describes) are not converted; regrid to a lat/lon grid and interpolate to pressure levels first. No DIF* records are written.

Examples

>>> import glob
>>> import cfgrib
>>> import arlmet
>>> files = sorted(glob.glob("icon-eu_europe_regular-lat-lon_*.grib2"))
>>> datasets = [
...     ds for f in files for ds in cfgrib.open_datasets(f)
... ]
>>> ds = arlmet.converters.from_icon(datasets)
>>> arlmet.write_dataset(ds, "icon-eu.arl")