Skip to content

xarray cfgrib backend changed data variable name #678

@emanuel-schmid

Description

@emanuel-schmid

Up to xarray=2023.2.0, cfgrib=0.9.9.1 and eccodes=2.26.0 reading the storm_europe test files named "test_storm_europe_icon_2021012800" created a dataset with a Data variable 'gust'.

With xarray=2023.2.0, cfgrib=0.9.10.3 and eccodes=2.29.0 the (seemingly) same Data variable is called 'i20fg'.

The following code snippet (mostly taken from StormEurope.from_icon_grib) illustrates this:

mport datetime as dt
from pathlib import Path
import bz2
import xarray as xr

from climada.hazard import StormEurope
from climada.util.api_client import Client
from climada.util.dwd_icon_loader import download_icon_grib

apiclient = Client()
ds = apiclient.get_dataset_info(name='test_storm_europe_icon_2021012800', status='test_dataset')
dsdir, _ = apiclient.download_dataset(ds)

event_date = dt.datetime(2021, 1, 28)
model_name = 'test'

file_names = download_icon_grib(
    dt.datetime(2021, 1, 28),
    model_name='test',
    download_dir=dsdir)

# read intensity from files
for ind_i, file_i in enumerate(file_names):
    gripfile_path_i = Path(file_i[:-4])
    with open(file_i, 'rb') as source, open(gripfile_path_i, 'wb') as dest:
        dest.write(bz2.decompress(source.read()))
    ds_i = xr.open_dataset(gripfile_path_i, engine='cfgrib')
    if ind_i == 0:
        stacked = ds_i
    else:
        stacked = xr.concat([stacked,ds_i], 'valid_time')

print(stacked)

This is relevant since the current conda installation comes with the updated versions as above, and consequently runs into a unittest failure for climada.hazard.test.test_storm_europe.TestReader.test_icon_read

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions