Hi Valentina,
It’s currently a badly documented feature, but the trick is to also make your UDF context aware, like this:
binarize = openeo.UDF(..., context={"from_parameter": "context"})
I hope this already solves your problem. However some more notes:
If you load your UDF from a file, it’s typically a lot easier to use UDF.from_file()
instead of doing Path().read_text()
:
binarize = openeo.UDF.from_file("udf-binarize.py", context={"from_parameter": "context"})
I also think there is a bug in your UDF at the moment:
array = xr.where((array >= snowT) & (array <= 100), array, 0)
array = xr.where(array < snowT, array, 100)
The first statement will map all values outside of the rangesnowT-100
to 0 and the second statement will map this 0 value to 100. As this can be done with a single where
, I guess there is something wrong here.