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

Add User-Defined Processes #19

Open
danlooo opened this issue Jul 28, 2023 · 1 comment
Open

Add User-Defined Processes #19

danlooo opened this issue Jul 28, 2023 · 1 comment

Comments

@danlooo
Copy link
Collaborator

danlooo commented Jul 28, 2023

OpenEO specifies elementary processes, e.g., add, divide and sqrt to perform arbitrary operations on the datacube arrays. This is useful for implementing own metrics and reducers that use multiple bands. The R client allows to provide R functions to describe the calculation:

ndvi_data = p$reduce_dimension(data=temporal_subset,dimension=[c](https://rdrr.io/r/base/c.html)("t"),
   reducer = function(x, ...) {
      b04 = x[1]
      b08 = x[2]
      (b08-b04)/(b08+b04)
    })

Lowered Julia code seems to be a promising starting point to map Julia expressions to openEO processes:

function reduce_ndvi(x::Vector{Real})
    red = x[1]
    nir = x[2]
    ndvi = (nir - red) / (nir + red)
    return ndvi
end
code_lowered(reduce_ndvi, (Vector{Real},))[1].code
# 6-element Vector{Any}:
#  :(_5 = Base.getindex(_2, 1))
#  :(_4 = Base.getindex(_2, 2))
#  :(_4 - _5)
#  :(_4 + _5)
#  :(_3 = %3 / %4)
#  :(return _3)

Process graphs are somewhat a domain specific programming language (DSL). I'd be nice to be able to transpile Julia expressions into openEO processes as well. Since the ProcessGraph is a DAG with one-directional data flow, there are no for and goto statements possible e.g. inside reducer functions and only simple arithmetic and if. Am I right, @m-mohr ?

More complex code would probably require user defined function and a Julia runtime in the backend that is not developed yet. So this is just to enable writing openEO process graphs with Julia syntax that can be executed on backend with different languages.

@m-mohr
Copy link
Member

m-mohr commented Jul 28, 2023

Yes, correct.

danlooo added a commit that referenced this issue Jul 28, 2023
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

No branches or pull requests

2 participants