Closed
Description
I can't seem to be able to define attributes to "virtual" coordinates from multi-index coordinates. Taking from the exemple from the docs:
In [1]: import numpy as np
In [2]: import pandas as pd
In [3]: import xarray as xr
In [4]: midx = pd.MultiIndex.from_arrays([['R','R','V','V'], [.1,.2,.7,.9]], names=('band','wn'))
In [5]: mda = xr.DataArray(np.random.rand(4), coords={'spec': midx}, dims='spec')
# Setting up attrs to the full coordinate works:
In [6]: mda['spec'].attrs
Out[6]: OrderedDict()
In [7]: mda['spec'].attrs = {'spec_attr': 'some_attr'}
In [8]: mda['spec'].attrs
Out[8]: OrderedDict([('spec_attr', 'some_attr')])
# Setting attrs to the virtual coordinate does not produce any effect:
In [9]: mda['band'].attrs
Out[9]: OrderedDict()
In [10]: mda['band'].attrs = {'band_attr': 'another_attr'}
In [11]: mda['band'].attrs
Out[11]: OrderedDict()
Metadata
Metadata
Assignees
Labels
No labels