Describe the bug
According to the documentation, satpy.composites.core.CompositeBase.drop_coordinates drops coordinates that do not correspond to any dimension:
|
"""Drop negligible non-dimensional coordinates. |
|
|
|
Drops negligible coordinates if they do not correspond to any |
|
dimension. Negligible coordinates are defined in the |
|
:attr:`NEGLIGIBLE_COORDS` module attribute. |
|
|
|
Args: |
|
data_arrays: Arrays to be checked |
In reality, it also drops coordinates that do correspond to a dimension.
To Reproduce
import numpy as np
import xarray as xr
import satpy.composites.core
ds = xr.DataArray(
np.arange(3*4).reshape(3, 4),
dims=("y", "x"),
coords={"time": xr.DataArray(
np.arange(3).reshape(3), dims=("y",))})
print(ds.coords)
# this dataset has a coordinate (time) corresponding to a dimension (y)
ds_new = satpy.composites.core.CompositeBase.drop_coordinates([ds])[0]
# but the coordinate is still dropped
print(ds_new.coords)
Expected behaviour
I'm not sure what the intention is of the code.
I expect that either
- the documentation accurate describes that coordinates are dropped even if they correspond to a dimension, unless that dimension has the same name as the coordinate, or
- this coordinate is retained, as is documented.
Actual results
The coordinate is dropped:
Coordinates:
time (y) int64 24B 0 1 2
Coordinates:
*empty*
Environment Info:
- OS: openSUSE Leap 15.6
- Satpy Version: v0.60.0
Additional context
This behaviour was originally introduced in #796. It breaks #3168, which intends to retain time information.
Describe the bug
According to the documentation,
satpy.composites.core.CompositeBase.drop_coordinatesdrops coordinates that do not correspond to any dimension:satpy/satpy/composites/core.py
Lines 207 to 214 in 58ce536
In reality, it also drops coordinates that do correspond to a dimension.
To Reproduce
Expected behaviour
I'm not sure what the intention is of the code.
I expect that either
Actual results
The coordinate is dropped:
Environment Info:
Additional context
This behaviour was originally introduced in #796. It breaks #3168, which intends to retain time information.