Hi,
I have a basic example where I want to use the exp()
process as part of an expression, however, I am receiving the error from job ID 'vito-15d6f90f-fbc8-4ea5-8cc9-0a6eaff846e1'
.Please can you advice the correct way to use this process.
'py4j.protocol.Py4JJavaError: An error occurred while calling '
'o1042.expressionEnd.\n'
': java.lang.IllegalArgumentException: Unsupported operation: exp '
'(arguments: [p])\n'
A reproducible example:
import openeo
from openeo.processes import exp, array_element
connection = openeo.connect("openeo.cloud").authenticate_oidc()
s2_name = 'SENTINEL2_L2A_SENTINELHUB'
start_date = '2021-01-01'
end_date = '2021-01-10'
bands = ['B02', 'B03', 'B04', 'B08', 'CLP', 'SCL', 'sunAzimuthAngles']
spatial_extent = {'west': -74.06810760, 'east': -73.90597343, 'south': 4.689864510, 'north': 4.724080996, 'crs': 4326}
s2_cube = connection.load_collection(
s2_name,
spatial_extent = spatial_extent,
temporal_extent = [start_date, end_date],
bands = bands
)
clp = s2_cube.band("CLP").resample_spatial(resolution=20, method = "bicubic")
mask = (clp / 255) > 0.3
s2_cube = s2_cube.mask(mask)
median = s2_cube.median_time()
def example_expression (dc):
bandx = array_element(dc, index = 3) ##nir in this example.
return exp(bandx)
expression = median.reduce_dimension(reducer = example_expression, dimension = "bands")
result = expression.save_result(format = "GTiff")
job = result.create_job(title = "example")
results = job.start_and_wait(connection_retry_interval=30).get_results()
The VITO backend currently does not support the exp
process in a reduce callback. That is something we should add indeed.
Does your script work if you just return bandx
instead of exp(bandx)
?
another tip: you can use []
as syntactic sugar for array_element
:
def example_expression (dc):
bandx = dc[3] ##nir in this example.
...
How quickly can you add this please?
Yes returning bandx
worked fine. It is specifically the exp()
part that breaks.
Nice tip, that does look much batter than using array_element 
programming-wise it’s not a lot of work, getting it in production could take some time. @jeroen.dries can you give an estimate?
I’ve made a commit for the exp process, so that it can be available on dev at latest on monday.
I do still need to test, but this way you might have it quite fast.
@sulova.andrea Can you try again on openeo-dev.vito.be?
Another thing: I haven’t checked in detail but you are applying exp
to values that might still be in the range of digital numbers (thousands), instead of physical reflectance values (e.g. 0-1 range). Passing these large values to exp
is probably not what you intend.
It works fine Stefaan
I am wondering how the processes/collection with different backends work together.
e.g.: You have mentioned that exp() is not working on the vito backend (now it works once you involved it). Do you mean generally that if we use the SENTINEL2_L2A_SENTINELHUB (vito) and later change the collection to SENTINEL2_L1C(EODC), then some processes migth not work?
That might indeed be a problem, but we try to make sure all backends support as much basic/core processes as possible to avoid this. We are also working on a system to automatically detect these kind of functionality gaps and discrepancies.
If you encounter such a problem, please let us know.
Note that the list of processes that all backends must offer is also documented at the link below. If you need something beyond this, then there’s also network of resources packages available that allow you to ask for a feature from a specific backend.
We’re also working on an approach that transfers data between backends, so that you can mix collections and processes that are not necessarily supported on the same backend.