-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
topic-metadataRelating to the handling of metadata (i.e. attrs and encoding)Relating to the handling of metadata (i.e. attrs and encoding)
Description
Hi all,
I just played around with some data and found that xarray's "rolling" drops the attributes and name (even if I say keep_attrs=True
):
nt, nx = 100, 30
da = xr.DataArray(np.random.randn(nt, nx), dims=['time', 'x'],
name='foo')
da.attrs['place'] = 'here'
da.attrs['long_name'] = 'test'
da
xarray.DataArray'foo'time: 100x: 30
array([[ 0.14720402, -0.29625209, -0.13164254, ..., 0.58363874,
0.20588748, 1.21594309],
[ 1.23770654, -0.18156258, 0.9182397 , ..., 0.16810624,
-0.40726509, 0.2328856 ],
[-0.10127142, 0.55696125, 0.7765333 , ..., -1.24054728,
-0.3520287 , 0.34090885],
...,
[-0.62290589, 0.95234302, 1.33738597, ..., 1.25784705,
0.32367764, 1.7907127 ],
[ 0.2987966 , -0.9820949 , -1.33291223, ..., -0.43975905,
2.28465498, 0.43231269],
[ 0.66635482, 0.74084712, -2.02589549, ..., 1.64077719,
2.84362149, -0.36572597]])
Coordinates: (0)
Attributes:
place : here
long_name : test
da.rolling(time=5).mean(dim='time')
xarray.DataArraytime: 100x: 30
array([[ nan, nan, nan, ..., nan,
nan, nan],
[ nan, nan, nan, ..., nan,
nan, nan],
[ nan, nan, nan, ..., nan,
nan, nan],
...,
[-0.56217953, 0.73100328, 0.03839124, ..., 0.60660493,
-0.22207041, 0.72327949],
[-0.31968275, 0.52925981, 0.00241698, ..., 0.70700785,
0.34605282, 0.69566641],
[-0.15442784, 0.78247162, -0.017953 , ..., 0.75334648,
1.03670267, 0.89595308]])
Coordinates: (0)
Attributes: (0)
Again, this also happens when I include keep_attrs=True
at both steps, rolling and mean. I think it should keep the name and attributes?
Metadata
Metadata
Assignees
Labels
topic-metadataRelating to the handling of metadata (i.e. attrs and encoding)Relating to the handling of metadata (i.e. attrs and encoding)