Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPEN-EO math functions "add,divide,multiply" used via apply broken in backend #119

Closed
julian-zeidler opened this issue Oct 14, 2021 · 7 comments · Fixed by #122
Closed

Comments

@julian-zeidler
Copy link

julian-zeidler commented Oct 14, 2021

the official OPEN-EO math functions "add,substract,divide,multiply" deliver wrong results.
Calling the functions "add,substract,divide,multiply" via apply for single Band Collection and with 2 as second parameter y
results in identical internal grass call to t.rast.mapcalc with expression=(2) and resulting outputs completely filled with value 2

SubGraph: for apply :
"apply1": {
"process_id": "apply",
"arguments": {
"data": {
"from_node": "loadcollection1"
},
"process": {
"process_graph": {
"add1": {
"process_id": "add",
"arguments": {
"x": {
"from_parameter": "x"
},
"y": 2
},
"result": true
}
}
}
}
}

simpleAddOpenEO-ExampleGraph.txt

@julian-zeidler
Copy link
Author

function absolute also does not work and results in "expression=absolute()" which fails in grass backend

@metzm
Copy link
Collaborator

metzm commented Oct 18, 2021

The syntax of the example seems to be wrong. In

"arguments": {
  "x": {
    "from_parameter": "x"
  },
  "y": 2
}

the value to be used as "x" refers to itself. It should either refer to a different parameter or in this example to the data provided to the apply process:

"arguments": {
  "x": {
    "from_argument": "data"
  },
  "y": 2
}

The openeo absolute() function is now mapped to the GRASS abs() function.

@julian-zeidler
Copy link
Author

The example is directly created by the current (0.9) python client using
absoluteDC=datacube.apply(process="absolute"), so i would expect it to result in a valid Graph.
which results in:
{
"process_graph": {
"loadcollection1": {
"process_id": "load_collection",
"arguments": {
"id": "nc_spm_08.modis_lst.strds.LST_Day_monthly",
"spatial_extent": null,
"temporal_extent": [
"2015-01-01",
"2015-03-01"
]
}
},
"apply1": {
"process_id": "apply",
"arguments": {
"data": {
"from_node": "loadcollection1"
},
"process": {
"process_graph": {
"absolute1": {
"process_id": "absolute",
"arguments": {
"x": {
"from_parameter": "x"
}
},
"result": true
}
}
}
}
},
"saveresult1": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "apply1"
},
"format": "GTIFF",
"options": {}
},
"result": true
}
}
}

@julian-zeidler
Copy link
Author

Creating the same Process using the openEO Webeditor results in a similar Graph:
{
"process_graph": {
"1": {
"process_id": "load_collection",
"arguments": {
"id": "nc_spm_08.modis_lst.strds.LST_Day_monthly",
"spatial_extent": {
"west": -180,
"east": 180,
"south": -90,
"north": 90
},
"temporal_extent": [
"1900-01-01T00:00:00",
"2100-01-01T00:00:00"
],
"bands": null
}
},
"2": {
"process_id": "apply",
"arguments": {
"data": {
"from_node": "1"
},
"process": {
"process_graph": {
"1": {
"process_id": "absolute",
"arguments": {
"x": {
"from_parameter": "x"
}
},
"result": true
}
}
}
},
"result": true
}
},
"parameters": []
}

@metzm
Copy link
Collaborator

metzm commented Oct 18, 2021

Strange. I don't understand how the value for a parameter can come from itself? We can of course adjust the backend such that in this case (self-reference) the "data" parameter of the "apply" process is used, but that feels like a hack.

@julian-zeidler
Copy link
Author

Hi Markus.
The way i understand it. The mapping is via the process description for the process which is called with a child "callback"
E.G https://openeo.org/documentation/1.0/processes.html#apply defines a child process parameter x via which the array is passed. Unfortunatly what makes it a bit confusing (for apply) is that the internal parameter is also called x, resulting in the seeming self-reference.

in comparison for function reduce_dimension (or apply_dimension) the callback variable is data (https://openeo.org/documentation/1.0/processes.html#reduce_dimension) and any auxilary settings can be passed via context variable

@metzm
Copy link
Collaborator

metzm commented Oct 18, 2021

You're right, I confused the name of the child process parameter with parameter of the "add" process. Thus

"process": {
  "process_graph": {
    "add1": {
      "process_id": "add",
      "arguments": {
        "x": {
          "from_parameter": "x"
        },
        "y": 2
      },
      "result": true
    }
  }
}

and

"process": {
  "process_graph": {
    "add1": {
      "process_id": "add",
      "arguments": {
        "x": 2
        "y": {
          "from_parameter": "x"
        },
      },
      "result": true
    }
  }
}

are both correct and should give the same result.

We need to adjust our "apply", "reduce_dimension" process implementations, I will prepare a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants