xarray-contrib / pint-xarray

Interface for using pint with xarray, providing convenience accessors
https://pint-xarray.readthedocs.io/en/latest/
Apache License 2.0
101 stars 12 forks source link

Support for set_xindex? #218

Closed vasilisniaouris closed 1 month ago

vasilisniaouris commented 1 year ago

The set_xindex methods of DataArray and Dataset drop the units. Is there a way to add a pint.set_xindex functionality?

Edit:

I realized that I can not seem to initialize a dataarray with Quantity objects as dimensions to begin with. The dimensions objects always drop the units. I tried to create a pint set_xindex myself, but that was the bottleneck I run into. Am I doing something wrong, or quantity Indexes are indeed not supported in general?

keewis commented 1 year ago

sorry for the late reply here. As you noticed, quantity indexes are not yet supported in general, which is why we have workaround methods like .pint.sel and .pint.reindex.

I have tried to create a class that wraps other indexes in #163, but couldn't find the time to finish this up yet (so I guess this has stalled).

I also didn't yet figure out how you would use that special index class, so even if it was working I guess you'd have to call set_xindex before quantifying.