Open
Description
I'm working with datasets that have coordinates with lots of decimal places. As I don't need this I reassign cords and transform the dtype to float32.
For calculating the extent of the dataset a standard procedure is to use the min() and max() methods but using them over the float32 coordinates yields the float64 values which leads to misaligned coordinates.
Minimum reproducible example:
import xarray as xr
import numpy as np
da = xr.DataArray(
data=np.array([1.2, 2.2, 3.3], dtype=np.float32),
coords={"x": [1.345, 2.345, 3.345]},
dims=("x",),
)
print(da[0].dtype) # dtype('float32')
print(da.min().dtype) # dtype('float64')
print(type(np.min(da.values))) # dtype('float32')
Is there a reason for this?