Skip to content

unable to retrive Dataset with converted units #109

Closed
@raybellwaves

Description

@raybellwaves

This is a strange and i'm not sure if I can make a MCVE. I'll try later.

The tutorial equations works fine so must be something else i'm doing

VAR = "air"
OUNIT = "degC"

ds = xr.tutorial.open_dataset("air_temperature")
ds["lat"].attrs["units"] = "degree"
ds["lon"].attrs["units"] = "degree"

ds = ds.pint.quantify({VAR: ds[VAR].attrs["units"]})
ds = ds.pint.to({VAR: OUNIT})
ds = ds.pint.dequantify(format="~P")

ds[VAR].isel(time=0).plot()

ds.to_netcdf("/tmp/tmp.nc")
ds = xr.open_dataset("/tmp/tmp.nc")

ds[VAR].isel(time=0).plot()

I'm trying to save a Dataset where I can converted the units.

I'm unable to see the converted units after loading straight after saving.

The code is something like the example above but with a few extra ETL steps.

Screen Shot 2021-05-31 at 11 56 28 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions