Astropy quantities are converted to bare arrays when creating an Index
What is your issue?
When provided as a data variable, an astropy Quantity is kept as a Quantity. But when provided as an index through the coords argument when constructing a Dataset, the Quantity is converted to an array, erasing the units. Is it possible to fix this?
that's to be expected, see the list of operations converting to numpy. You can work around this using a custom index, but this is going to be quite a bit of effort (you can use pint-xarray's index as an example).
I wonder if a "basic array index", as prototyped by @benbovy here, would be a good default for this case.
Basically we'd use PandasIndex only if the provided data are numpy (or basic python types that we cast to numpy), and this "array index" is used otherwise to preserve any attached metadata.
Yes I think a basic array index would help for such case. Even better here would be an Astropy-specific custom index (see https://github.com/pydata/xarray/pull/9543#issuecomment-2385562215 and https://xarray-indexes.readthedocs.io/blocks/transform.html)!