Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_xarray from GRIB dropping units #571

Open
JamesVarndell opened this issue Dec 16, 2024 · 0 comments
Open

to_xarray from GRIB dropping units #571

JamesVarndell opened this issue Dec 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JamesVarndell
Copy link
Collaborator

What happened?

When calling to_xarray() on GRIBReader objects in earthkit-data, somnetimes the data units are lost. This seems to happen when there is a single variable in the GRIB input - but when there are multiple variables, the units are correctly carried into the xarray object.

What are the steps to reproduce the bug?

import earthkit.data

data = earthkit.data.from_source(
    'cds',
    'reanalysis-era5-single-levels',
    {
        'product_type': 'reanalysis',
        'variable': '2m_temperature',
        'year': '2024',
        'month': '08',
        'day': '09',
        'time': '18:00',
    },
)

ds = data.to_xarray()

If you look at the global and variable attributes of ds, there are no units in either. However, if we slightly tweak the above request to as for two variables as below, then the two variables in ds both have their correct units in the variable attributes.

import earthkit.data

data = earthkit.data.from_source(
    'cds',
    'reanalysis-era5-single-levels',
    {
        'product_type': 'reanalysis',
        'variable': ['2m_temperature', 'total_precipitation'],
        'year': '2024',
        'month': '08',
        'day': '09',
        'time': '18:00',
    },
)

ds = data.to_xarray()

Version

0.11.4

Platform (OS and architecture)

MacOS

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF

@JamesVarndell JamesVarndell added the bug Something isn't working label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant