Skip to content

Commit

Permalink
Addressed PR change requests from Victor
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinBabe committed Jun 19, 2024
1 parent 57863a2 commit dd6c557
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/openeo_gfmap/features/feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ def apply_feature_extractor_local(
dependencies = feature_extractor.dependencies()

if len(dependencies) > 0:
print(
"WARNING: Running UDFs locally with pip dependencies is not supported yet, "
feature_extractor.logger.warning(
"Running UDFs locally with pip dependencies is not supported yet, "
"dependencies will not be installed."
)

Expand Down
1 change: 0 additions & 1 deletion src/openeo_gfmap/fetching/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def _load_collection_hybrid(
bands=bands,
properties=properties,
)
print(bands)
cube = cube.rename_labels(dimension="bands", target=bands)
return cube

Expand Down
2 changes: 1 addition & 1 deletion src/openeo_gfmap/fetching/meteo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def stac_fetcher(
**params,
)

if isinstance(spatial_extent, GeoJSON):
if isinstance(spatial_extent, GeoJSON) and fetch_type == FetchType.POLYGON:
cube = cube.filter_spatial(spatial_extent)

return cube
Expand Down
4 changes: 2 additions & 2 deletions src/openeo_gfmap/inference/model_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def apply_model_inference_local(
dependencies = model_inference.dependencies()

if len(dependencies) > 0:
print(
"WARNING: Running UDFs locally with pip dependencies is not supported yet, "
model_inference.logger.warning(
"Running UDFs locally with pip dependencies is not supported yet, "
"dependencies will not be installed."
)

Expand Down
20 changes: 0 additions & 20 deletions src/openeo_gfmap/preprocessing/meteo.py

This file was deleted.

31 changes: 31 additions & 0 deletions src/openeo_gfmap/preprocessing/scaling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Scaling and compressing methods for datacubes."""

import openeo


def compress_uint16(
cube: openeo.DataCube, alpha: float = 1.0, beta: float = 0.0
) -> openeo.DataCube:
"""Scales the data linearly using the formula `output = (input * a) + b` and compresses values
from float32 to uint16 for memory optimization.
Parameters
----------
cube : openeo.DataCube
The input datacube to compress, only meteo data should be present.
alpha : float, optional (default=1.0)
The scaling factor. Values in the input datacube are multiplied by this coefficient.
beta : float, optional (default=0.0)
The offset. Values in the input datacube are added by this value.
Returns
-------
cube : openeo.DataCube
The datacube with the data linearly scaled and compressed to uint16 and rescaled frome.
"""
if (
alpha != 1.0 or beta != 0.0
): # Avoid adding a node in the computing graph if scaling is not necessary
cube = (cube * alpha) + beta

return cube.linear_scale_range(0, 65534, 0, 65534)

0 comments on commit dd6c557

Please sign in to comment.