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

labelled arrays #155

Merged
merged 5 commits into from
Feb 26, 2024
Merged

labelled arrays #155

merged 5 commits into from
Feb 26, 2024

Conversation

clausmichele
Copy link
Member

First draft to support labelled arrays.

I modified only the processes required to run the following simple example. We would have to go through all the math processes and others as well if we want to implement this.

from openeo.local import LocalConnection
from openeo.processes import pi
local_conn = LocalConnection("./")

url = "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a"
spatial_extent =  {"east": 11.40, "north": 46.52, "south": 46.46, "west": 11.25}
temporal_extent = ["2022-06-01", "2022-06-30"]
bands = ["red", "nir"]
properties = {"eo:cloud_cover": dict(lt=80)}
s2_datacube = local_conn.load_stac(
    url=url,
    spatial_extent=spatial_extent,
    temporal_extent=temporal_extent,
    bands=bands,
    properties=properties,
)

from openeo.processes import array_element
def labeled_ndvi(x):
    b4 = array_element(x,label="red")
    b8 = array_element(x,label="nir")
    ndvi = (b8-b4)/(b8+b4)
    return ndvi

s2_ndvi = s2_datacube.reduce_dimension(dimension="band",reducer=labeled_ndvi)

s2_ndvi = s2_ndvi.execute()

@LukeWeidenwalker
Copy link
Contributor

Thanks for this MIchele! Just a heads-up, I didn't get around to look at this yet and am on holiday from tomorrow until Monday - I'll have a look next week though!

Copy link
Contributor

@LukeWeidenwalker LukeWeidenwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a first look now - thanks for looking into this!
The general approach of just passing labels through to child processes looks fine to me. I'd recommend adding another reserved parameter to the list in https://github.com/Open-EO/openeo-processes-dask/blob/main/openeo_processes_dask/process_implementations/core.py#L71C1-L72C1. This removes the parameter if the subprocess can't do anything with it and we shouldn't need to touch all the math processes. Wdyt?

@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 83.20%. Comparing base (50786cc) to head (34665f3).

Files Patch % Lines
...o_processes_dask/process_implementations/arrays.py 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
- Coverage   83.25%   83.20%   -0.06%     
==========================================
  Files          29       29              
  Lines        1529     1536       +7     
==========================================
+ Hits         1273     1278       +5     
- Misses        256      258       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@clausmichele
Copy link
Member Author

@LukeWeidenwalker I followed your suggestion, it seems to work fine.
I also added a simple test based on array_element + label

@clausmichele clausmichele changed the title Draft for labelled arrays labelled arrays Oct 16, 2023
@clausmichele
Copy link
Member Author

@ValentinaHutter @GeraldIr it would be good if you could review this and merge it!

Copy link
Member

@GeraldIr GeraldIr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bschumac bschumac removed the request for review from LukeWeidenwalker December 6, 2023 14:24
@clausmichele
Copy link
Member Author

@ValentinaHutter @GeraldIr please have a look again at this PR so that it can be merged.

@clausmichele clausmichele mentioned this pull request Feb 13, 2024
3 tasks
@ValentinaHutter ValentinaHutter merged commit 365ae22 into Open-EO:main Feb 26, 2024
3 of 5 checks passed
@clausmichele clausmichele deleted the labelled_arrays branch February 19, 2025 13:38
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 this pull request may close these issues.

5 participants