Skip to content

Conversion to_xarray() fails if data inconsistent #613

@j-haacker

Description

@j-haacker

What happened?

I received a grib2 dataset with missing time steps for one observable. This is not convertable to xarray using the corresponding method. I couldn't figure out how to fill no-data values in the grib data.

What are the steps to reproduce the bug?

I don't know how to produce a grib dataset like the one making trouble. I will not be able to offer a minimal working example. Moreover, you will need an upgraded destine.eu account. I apologize for the inconvenience.

Define the request:

    request = {
        'activity': 'CMIP6',
        'class': 'd1',
        'dataset': 'climate-dt',
        'experiment': 'HIST',
        'expver': '0001',
        'generation': '1',
        'levtype': 'sfc',
        'model': 'IFS-NEMO',
        'param': '167/168',  # 2t, 2d
        'realization': '1',
        'resolution': 'high',
        'stream': 'clte',
        'type': 'fc',
        'date': '1993-08-23/1993-08-24',
        'time': '0000',
    }

Download and convert:

data = earthkit.data.from_source("polytope", "destination-earth", request, address="polytope.lumi.apps.dte.destination-earth.eu", stream=False)#
ds = data.to_xarray()

Version

0.12.1

Platform (OS and architecture)

Linux 6.8.0-52-generic Ubuntu 24.04 x86_64

Relevant log output

/lib/python3.12/site-packages/earthkit/data/utils/xarray/builder.py", line 425, in check_tensor_coords
    check_coords(var_name, coord_name, tensor_coords, self.tensor_coords)
  File "/lib/python3.12/site-packages/earthkit/data/utils/xarray/check.py", line 37, in check_coords
    raise ValueError(
ValueError: Variable "2d" has inconsistent dimension "forecast_reference_time" compared to other variables. Expected values: (5) ['1993-08-23T00:00:00', '1993-08-23T06:00:00', '1993-08-23T12:00:00', '1993-08-23T18:00:00', '1993-08-24T00:00:00'], got: (4) ['1993-08-23T00:00:00', '1993-08-23T06:00:00', '1993-08-23T12:00:00', '1993-08-23T18:00:00']. Length mismatch: 5 != 4

Accompanying data

Not allowed.

Organisation

BOKU University

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions