Skip to content

Commit

Permalink
Issue #346 port linear_scale_range to ProcessArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Feb 4, 2025
1 parent 5a2d8b9 commit e9f6983
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,20 +1670,17 @@ def run_udf(args: dict, env: EvalEnv):


@process
def linear_scale_range(args: dict, env: EvalEnv) -> DriverDataCube:
image_collection = extract_arg(args, 'x')

inputMin = extract_arg(args, "inputMin")
inputMax = extract_arg(args, "inputMax")
outputMax = args.get("outputMax", 1.0)
outputMin = args.get("outputMin", 0.0)
if not isinstance(image_collection, DriverDataCube):
raise ProcessParameterInvalidException(
parameter="data", process="linear_scale_range",
reason=f"Invalid data type {type(image_collection)!r} expected raster-cube."
)

return image_collection.linear_scale_range(inputMin, inputMax, outputMin, outputMax)
def linear_scale_range(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
# TODO: eliminate this top-level linear_scale_range process implementation (should be used as `apply` callback)
_log.warning("DEPRECATED: linear_scale_range usage directly on cube is deprecated/non-standard.")
cube: DriverDataCube = args.get_required("x", expected_type=DriverDataCube)
# Note: non-standard camelCase parameter names (https://github.com/Open-EO/openeo-processes/issues/302)
input_min = args.get_required("inputMin")
input_max = args.get_required("inputMax")
output_min = args.get_optional("outputMin", default=0.0)
output_max = args.get_optional("outputMax", default=1.0)
# TODO linear_scale_range is defined on GeopysparkDataCube, but not on DriverDataCube
return cube.linear_scale_range(input_min, input_max, output_min, output_max)


@process
Expand Down

0 comments on commit e9f6983

Please sign in to comment.