xarray-contrib / xarray-regrid

Regridding utility for xarray
https://xarray-regrid.readthedocs.org/
Apache License 2.0
71 stars 7 forks source link

dtype changes after `most_common` #52

Closed SarahAlidoost closed 1 month ago

SarahAlidoost commented 1 month ago

It seems that da.regrid.most_common(...) changes the dtype of da from uint8 to float32. Is this change needed? I tested this issue using demo notebook, just inspect dtype before and after regrid.

BSchilperoort commented 1 month ago

Hi Sarah, thanks for raising this issue. This is not the intended behavior.

It turns out there are two problems:

  1. When restoring the input data's properties (attrs etc.), we use .where which will cast data to a floating point number so NaN can be used.
  2. I forgot to expose the fill_value kwarg to regrid.most_common, so no fill value can be passed by the user.