Skip to content

Commit

Permalink
Merge pull request #89 from openEOPlatform/feature/save-datacube-meta…
Browse files Browse the repository at this point in the history
…data

save datacube metadata to evalscript's  userdata output
  • Loading branch information
zcernigoj authored Sep 21, 2023
2 parents 032ef99 + caab9d4 commit 2d5b98c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pg_to_evalscript/evalscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,31 @@ def write(self):
{self.write_ndarray_definition()}
{self.write_datacube_definition()}
{newline.join([node.write_function() for node in self.nodes])}
// this var gets metadata about the dimensions of the datacube for postprocessing
// it is saved as userdata.json
let forUserData = {{}};
function evaluatePixel(samples, scenes) {{
{self.write_datacube_creation()}
{(newline + tab).join([node.write_call() for node in self.nodes])}
forUserData = {{
outputDimensions: {self.write_output_variable()}.dimensions,
outputDatacubeMetadata: {{
shape: {self.write_output_variable()}.data.shape,
stride: {self.write_output_variable()}.data.stride,
offset: {self.write_output_variable()}.data.offset
}}
}}
const finalOutput = {self.write_output_variable()}{".encodeData()" if self.encode_result else '.flattenToArray()'}
return Array.isArray(finalOutput) ? finalOutput : [finalOutput];
}}
function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {{
outputMetadata.userData = forUserData;
}}
"""

def write_datacube_definition(self):
Expand Down

0 comments on commit 2d5b98c

Please sign in to comment.