-
Notifications
You must be signed in to change notification settings - Fork 51
Support openeo.api.process.Parameter as resolution in DataCube.resamp… #898
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
VincentVerelst
wants to merge
6
commits into
master
Choose a base branch
from
897-resolution-parameter-resample-spatial
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+159
−9
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b4c3497
Support openeo.api.process.Parameter as resolution in DataCube.resamp…
VincentVerelst be0c986
Also support openeo.api.process.Parameter objects for the projection …
VincentVerelst c183ea1
Update CHANGELOG.md
VincentVerelst f38aabf
Merge remote-tracking branch 'origin/master' into 897-resolution-para…
VincentVerelst 24e663d
Merge branch '897-resolution-parameter-resample-spatial' of github.co…
VincentVerelst 2b1ca80
Update changelog
VincentVerelst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||
| import pystac.extensions.eo | ||||||
| import pystac.extensions.item_assets | ||||||
|
|
||||||
| from openeo.api.process import Parameter | ||||||
| from openeo.internal.jupyter import render_component | ||||||
| from openeo.util import Rfc3339, deep_get | ||||||
| from openeo.utils.normalize import normalize_resample_resolution, unique | ||||||
|
|
@@ -494,10 +495,14 @@ def drop_dimension(self, name: str = None) -> CubeMetadata: | |||||
|
|
||||||
| def resample_spatial( | ||||||
| self, | ||||||
| resolution: Union[float, Tuple[float, float], List[float]] = 0.0, | ||||||
| projection: Union[int, str, None] = None, | ||||||
| resolution: Union[float, Tuple[float, float], List[float], Parameter] = 0.0, | ||||||
| projection: Union[int, str, Parameter, None] = None, | ||||||
| ) -> CubeMetadata: | ||||||
| resolution = normalize_resample_resolution(resolution) | ||||||
| if isinstance(resolution, Parameter): | ||||||
| normalized_resolution = None, None | ||||||
| else: | ||||||
| normalized_resolution = normalize_resample_resolution(resolution) | ||||||
|
|
||||||
| if self._dimensions is None: | ||||||
| # Best-effort fallback to work with | ||||||
| dimensions = [ | ||||||
|
|
@@ -512,13 +517,14 @@ def resample_spatial( | |||||
| spatial_indices = [i for i, d in enumerate(dimensions) if isinstance(d, SpatialDimension)] | ||||||
| if len(spatial_indices) != 2: | ||||||
| raise MetadataException(f"Expected two spatial dimensions but found {spatial_indices=}") | ||||||
| assert len(resolution) == 2 | ||||||
| for i, r in zip(spatial_indices, resolution): | ||||||
|
|
||||||
| assert len(normalized_resolution) == 2 | ||||||
| for i, r in zip(spatial_indices, normalized_resolution): | ||||||
| dim: SpatialDimension = dimensions[i] | ||||||
| dimensions[i] = SpatialDimension( | ||||||
| name=dim.name, | ||||||
| extent=dim.extent, | ||||||
| crs=projection or dim.crs, | ||||||
| crs=None if isinstance(projection, Parameter) else projection or dim.crs, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to avoid confusion:
Suggested change
|
||||||
| step=r if r != 0.0 else dim.step, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this under "added" as this feels more like an added feature than a fixed bug
also: I think this added changelog entry is under the wrong version (0.50 has been released in the meantime)
I think you should merge master in this feature branch first