Check and clean coordinate cellsize handling
We've started adding cellsize data as dx
for x
, dy
for y
, etc. Initially, I figured it would be a good idea to encode the increasing or decreasing direction of the coordinate with the sign of the cellsize. This is a terrible idea in retrospect, since we cannot expect xarray to guarantee flipping the sign on selection, combine
's, etc.
A much more robust way is simply checking the index is_monotonic_increasing
or is_monotonic_decreasing
.
This logic should ideally also be combined in a single place, taking care of directions, but also whether cellsizes are array or scalar.
-
Find places where this logic occurs -
Identify what's needed, refactor that into a single function -
Check copying behaviour: I expect sel
andisel
to work without copying, but I'm not sure -
Set all cellsizes to positive, rely on is_monotonic...
to determine direction instead -
Special case single value coordinates? Since I believe they always return False