In the existing code, we're comparing data from Earth Engine, which arrives as floating-point numbers with 7-digit precision, to a masked value that's accurate to 9 digits. This discrepancy prevents a direct match. To address this, I introduced np.isclose(), which can match masked value with earth-engine data despite this precision difference.
Let's take an example:
import numpy as np
data = [(9999.,), (9999.01,), (9999.1,)]
Previous_Result = np.where( data == 9999, np.nan, data)
Current_Result = np.where( np.isclose(data, 9999), np.nan, data)
print(Previous_Result, Current_Result)
Fixed #86.
In the existing code, we're comparing data from Earth Engine, which arrives as floating-point numbers with 7-digit precision, to a masked value that's accurate to 9 digits. This discrepancy prevents a direct match. To address this, I introduced
np.isclose()
, which can match masked value with earth-engine data despite this precision difference.Let's take an example:
Output:
So
np.isclose
is match the value when their difference is less than0.1
. Official documentation link: https://numpy.org/doc/stable/reference/generated/numpy.isclose.html#numpy-isclose.