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
Math on all values throws error #537
Comments
Complete example that I ended up with: from openeo.processes import sqrt
data = connection.load_collection(
"ERA5",
spatial_extent = None,
temporal_extent = ["2000-01-01", "2000-01-02"],
bands = ["u10", "v10"]
)
u10 = data.band('u10') ** 2.01
v10 = data.band('v10') ** 2.01
data = u10 * v10
data = data.apply(process = lambda x: sqrt(x))
result = data.save_result("PNG") What I'd like it to look like (or similar): from openeo.processes import sqrt
data = connection.load_collection(
"AGERA5",
spatial_extent = None,
temporal_extent = ["2000-01-01", "2000-01-02"],
bands = ["u10", "v10"]
)
data = data ** 2.01
u10 = data.band('u10')
v10 = data.band('v10')
data = sqrt(u10 * v10)
result = data.save_result("PNG") |
Also, why is there no sqrt function on the datacube class? :-) |
indeed,
|
This can be simplified to # no import necessary
...
data = data.apply(process = lambda x: x.sqrt()) or even # no import necessary
...
data = data.apply(process="sqrt") |
General answer: because the E.g. we currently already have a bit of mixed behaviour: # "Band-math" mode
cube.band("B02") + 5 # -> translates to reduce_dimension(dimension=bands, ...)
# merge cube mode
cube1 + cube2 # -> translates to merge_cubes(cube1, cube2, overlap_resolver=add)
# "Apply" mode
cube + 5 # -> translates to apply( x -> x+5) The distinction is not obvious for the untrained eye (and it also not very easy to explain without getting too technical), so I'd prefer to promote a code style that keeps things more explicit. For example for the apply mode: cube.apply(lambda x: x+5) The decoupling between the data cube and the |
I'm trying to run
I'd expect that it computes the power for all vales in the data cube (i.e.
apply(process = power)
).Unfortunately I get:
The text was updated successfully, but these errors were encountered: