Skip to content

convert_units without losing attributes #2275

@juliettelavoie

Description

@juliettelavoie

Converting units removes the attributes.

xclim docs says : "Attributes are preserved unless an automatic CF conversion is performed, in which case only the new standard_name appears in the result."

This means that if I have a dataset with attrs

long_name : Precipitation
standard_name : precipitation_flux
cell_measures : area: areacella
cell_methods : area: mean time: mean
units : kg m-2 s-1
grid_mapping : crs
history : blabla

and I do
xc.core.units.convert_units_to(ds_raw.pr, 'mm/day', context='hydro')

I am only left with:

units : mm d-1
standard_name : lwe_precipitation_rate

I understand changing the standard_name, but I don't think we should lose the other attrs.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions