xarray-contrib/xarray-regrid

dtype changes after `most_common`

SarahAlidoost opened this issue · 1 comments

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.

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.