Open-EO / openeo-processes

Interoperable processes for openEO's big Earth observation cloud processing.
https://processes.openeo.org
Apache License 2.0
48 stars 15 forks source link

bitwise AND process #373

Open clausmichele opened 2 years ago

clausmichele commented 2 years ago

Proposed Process ID: bitwise_and

Context

A possible scenario came up in this issue, when considering quality flags of Sentinel-3 https://github.com/Open-EO/openeo-processes-python/issues/179

Summary

Currently the and process works only with boolean inputs (true or false, 0 or 1). A bitwise_and operator defined similarly to what numpy does would be necessary to accomplish this use case.

Description

Computes the bit-wise AND of the underlying binary representation of the input numbers.

Parameters

x

Optional: no

Description

A number

Data Type

number/null

y

Optional: no

Description

A number

Data Type

number/null

Return Value

Description

boolean value resulting from the bit-wise AND of the underlying binary representation of the input numbers.

Data Type

boolean/null

Links to additional resources (optional)

Examples (optional)

soxofaan commented 2 years ago

That would only work properly if both x and y are (unsigned) integers, right? If I understand correctly, JSON schema only has number without distinction between int and float, so that might be bit of a problem

m-mohr commented 2 years ago

@soxofaan JSON Schema has "integer" support and you can make it unsigned with "minimum": 0.

danielFlemstrom commented 2 years ago

I am currently experimenting with a bitwise implementation of the and/or/xor processes. When I get the mask-data (in the python back-end) , it is of type object since ODC does seems not to care whether it is image data with nulls or np.nan in it. I am not sure about the R and Javascript clients, but python makes a mess by only allowing the bitwise operators to be overloaded. https://github.com/Open-EO/openeo-python-client/issues/266) But masking image data with an integer should not be that unlikely i think, so this means the data on either x or y may have no-data points. As a bit of context, I list the inputs from a Python perspective since, we can have both np.none and None as no-data, which is used by np.array and xarrays. To further mess things up None is only possible in Object data type. This is what I have understood by reading the processes and openeo-processes-python doc, but I am not sure how this translates to the JSON process definition.

None        , None        -> None
None        , float       -> None
None        , float-nan   -> None
None        , float64     -> None
None        , float64-nan -> None
None        , int         -> None
None        , int[]       -> object[]
None        , float[]     -> object[]
None        , object[]    -> object[]
float       , None        -> None
float       , float       -> float
float       , float-nan   -> float
float       , float64     -> float
float       , float64-nan -> float
float       , int         -> float
float       , int[]       -> float[]
float       , float[]     -> float[]
float       , object[]    -> object[]
float-nan   , None        -> None
float-nan   , float       -> float
float-nan   , float-nan   -> float
float-nan   , float64     -> float
float-nan   , float64-nan -> float
float-nan   , int         -> float
float-nan   , int[]       -> float[]
float-nan   , float[]     -> float[]
float-nan   , object[]    -> object[]
float64     , None        -> None
float64     , float       -> float
float64     , float-nan   -> float
float64     , float64     -> float
float64     , float64-nan -> float
float64     , int         -> float
float64     , int[]       -> float[]
float64     , float[]     -> float[]
float64     , object[]    -> object[]
float64-nan , None        -> None
float64-nan , float       -> float
float64-nan , float-nan   -> float
float64-nan , float64     -> float
float64-nan , float64-nan -> float
float64-nan , int         -> float
float64-nan , int[]       -> float[]
float64-nan , float[]     -> float[]
float64-nan , object[]    -> object[]
int         , None        -> None
int         , float       -> float
int         , float-nan   -> float
int         , float64     -> float
int         , float64-nan -> float
int         , int         -> int
int         , int[]       -> int[]
int         , float[]     -> float[]
int         , object[]    -> object[]
int[]       , None        -> object[]
int[]       , float       -> float[]
int[]       , float-nan   -> float[]
int[]       , float64     -> float[]
int[]       , float64-nan -> float[]
int[]       , int         -> int[]
int[]       , int[]       -> int[]
int[]       , float[]     -> float[]
int[]       , object[]    -> object[]
float[]     , None        -> object[]
float[]     , float       -> float[]
float[]     , float-nan   -> float[]
float[]     , float64     -> float[]
float[]     , float64-nan -> float[]
float[]     , int         -> float[]
float[]     , int[]       -> float[]
float[]     , float[]     -> float[]
float[]     , object[]    -> object[]
object[]    , None        -> object[]
object[]    , float       -> object[]
object[]    , float-nan   -> object[]
object[]    , float64     -> object[]
object[]    , float64-nan -> object[]
object[]    , int         -> object[]
object[]    , int[]       -> object[]
object[]    , float[]     -> object[]
object[]    , object[]    -> object[]
m-mohr commented 1 year ago

This is a duplicate of #13