Open ahuang11 opened 4 years ago
keep_attrs
only affects variable attributes, not coordinate attributes. This is the behavior of xarray.apply_ufunc()
. I think this behavior makes sense, as the output lon
is a different coordinate than the input lon
, so they probably shouldn't share attributes.
On the other hand, the attributes of extra coordinates like time
are always kept regardless of keep_attrs
. This also makes sense as the input time
and output time
are exactly the same.
But if I know both lons are in longitudinal degree and I set keep_attrs=True, I still want them to keep those units. Maybe keep_attrs can accept a str "all" to keep all attributes regardless.
I think it is good to be consistent with the kwargs in xarray.apply_ufunc
and other xarray operations... For your case, you can setds_out['lon'].attrs['unit'] = 'degree'