Skip to content

Commit

Permalink
S2 timescan (#140)
Browse files Browse the repository at this point in the history
* bug fixes for GRASS semantic labels
* adjust apply process
* flake8 fixes
  • Loading branch information
metzm authored Mar 4, 2022
1 parent f43cc2c commit 709787c
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 47 deletions.
39 changes: 25 additions & 14 deletions src/openeo_grass_gis_driver/actinia_processing/apply_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,30 @@ def create_process_chain_entry(input_object: DataObject, formula,

formula = formula.replace('data', input_object.grass_name())

pc = {"id": "t_rast_mapcalc_%i" % rn,
"module": "t.rast.mapcalc",
"inputs": [{"param": "expression",
"value": "%(formula)s" % {"formula": formula}},
{"param": "input",
"value": "%(input)s" % {"input": input_object.grass_name()}},
{"param": "output",
"value": output_object.grass_name()},
# the basename will always replace any individual
# raster map names from the input STRDS,
# but some basename is required.
{"param": "basename",
"value": output_object.name}]}
pc = []
p = {"id": "t_rast_oeapply_%i" % rn,
"module": "t.rast.oeapply",
"inputs": [{"param": "expression",
"value": "%(formula)s" % {"formula": formula}},
{"param": "input",
"value": "%(input)s" % {"input": input_object.grass_name()}},
{"param": "output",
"value": output_object.grass_name()},
# the basename will always replace any individual
# raster map names from the input STRDS,
# but some basename is required.
{"param": "basename",
"value": output_object.name}]}

pc.append(p)

p = {"id": "t_info_%i" % rn,
"module": "t.info",
"inputs": [{"param": "input", "value": output_object.grass_name()},
{"param": "type", "value": "strds"}],
"flags": 'g'}

pc.append(p)

return pc

Expand Down Expand Up @@ -234,7 +245,7 @@ def get_process_list(node: Node):
formula,
operators,
output_object)
process_list.append(pc)
process_list.extend(pc)

return output_objects, process_list

Expand Down
35 changes: 23 additions & 12 deletions src/openeo_grass_gis_driver/actinia_processing/mask_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,31 @@ def create_process_chain_entry(
if mask_value == "null":
mask_value = "null()"

pc = {"id": "t_rast_mask_%i" % rn,
"module": "t.rast.mask",
"inputs": [{"param": "input",
"value": input_object.grass_name()},
{"param": "mask",
pc = []

p = {"id": "t_rast_mask_%i" % rn,
"module": "t.rast.mask",
"inputs": [{"param": "input",
"value": input_object.grass_name()},
{"param": "mask",
"value": mask_object.grass_name()},
{"param": "basename",
{"param": "basename",
"value": output_object.name},
{"param": "output",
{"param": "output",
"value": output_object.grass_name()},
{"param": "value",
"value": mask_value},
],
"flags": "i"}
{"param": "value",
"value": mask_value}],
"flags": "i"}

pc.append(p)

p = {"id": "t_info_%i" % rn,
"module": "t.info",
"inputs": [{"param": "input", "value": output_object.grass_name()},
{"param": "type", "value": "strds"}],
"flags": 'g'}

pc.append(p)

return pc

Expand Down Expand Up @@ -161,7 +172,7 @@ def get_process_list(node: Node) -> Tuple[list, list]:
mask_object,
mask_value,
output_object)
process_list.append(pc)
process_list.extend(pc)

return output_objects, process_list

Expand Down
23 changes: 16 additions & 7 deletions src/openeo_grass_gis_driver/actinia_processing/ndvi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ def create_process_chain_entry(input_time_series: DataObject,
{"param": "basename",
"value": output_time_series.name},
{"param": "output",
"value": output_time_series.grass_name()}]},
{"id": "t_rast_color_%i" % rn,
"module": "t.rast.colors",
"inputs": [{"param": "input",
"value": output_time_series.grass_name()},
{"param": "color",
"value": "ndvi"}]}]
"value": output_time_series.grass_name()}]}]
else:
pc = [
{"id": "t_rast_ndvi_%i" % rn,
Expand All @@ -143,6 +137,21 @@ def create_process_chain_entry(input_time_series: DataObject,
{"param": "color",
"value": "ndvi"}]}]

if target_band is not None:
p = {"id": "t_info_%i" % rn,
"module": "t.info",
"inputs": [{"param": "input", "value": input_time_series.grass_name()},
{"param": "type", "value": "strds"}],
"flags": 'g'}
else:
p = {"id": "t_info_%i" % rn,
"module": "t.info",
"inputs": [{"param": "input", "value": output_time_series.grass_name()},
{"param": "type", "value": "strds"}],
"flags": 'g'}

pc.append(p)

return pc


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,34 @@ def create__process_chain_entry(
# bbox
rn = randint(0, 1000000)

# TODO: do not create a new STRDS
# only update labels in the input STRDS ?

pc = []
# source can be null
if source:
pc = {
"id": "t_rast_renamebands_%i" %
rn, "module": "t.rast.renamebands", "inputs": [
{
"param": "input", "value": input_object.grass_name()}, {
"param": "target", "value": (',').join(target)}, {
"param": "source", "value": (',').join(source)}, {
"param": "output", "value": output_object.grass_name()}]}
p = {"id": "t_rast_renamelabels_%i" % rn,
"module": "t.rast.renamelabels",
"inputs": [{"param": "input", "value": input_object.grass_name()},
{"param": "new", "value": (',').join(target)},
{"param": "old", "value": (',').join(source)},
{"param": "output", "value": output_object.grass_name()}]}
else:
pc = {"id": "t_rast_renamebands_%i" % rn,
"module": "t.rast.renamebands",
"inputs": [{"param": "input", "value": input_object.grass_name()},
{"param": "target", "value": (',').join(target)},
{"param": "output", "value": output_object.grass_name()}]}
p = {"id": "t_rast_renamelabels_%i" % rn,
"module": "t.rast.renamelabels",
"inputs": [{"param": "input", "value": input_object.grass_name()},
{"param": "new", "value": (',').join(target)},
{"param": "output", "value": output_object.grass_name()}]}

pc.append(p)

p = {"id": "t_info_%i" % rn,
"module": "t.info",
"inputs": [{"param": "input", "value": output_object.grass_name()},
{"param": "type", "value": "strds"}],
"flags": 'g'}

pc.append(p)

return pc

Expand Down Expand Up @@ -189,7 +201,7 @@ def get_process_list(node: Node):
target=target,
source=source,
output_object=output_object)
process_list.append(pc)
process_list.extend(pc)

return output_objects, process_list

Expand Down

0 comments on commit 709787c

Please sign in to comment.