Skip to content

Commit

Permalink
Reimplement math processes #34 #35, add sgn, improve ComputedObject h…
Browse files Browse the repository at this point in the history
…andling
  • Loading branch information
m-mohr committed Jan 25, 2024
1 parent f608d82 commit e741b88
Show file tree
Hide file tree
Showing 43 changed files with 538 additions and 313 deletions.
143 changes: 71 additions & 72 deletions process_status.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,77 @@
# Process implementation status

The following processes have a fully GEE-based implementation:
The following processes have a fully GEE-based implementation or are not relevant for GEE directly:

- [x] absolute
- [x] add
- [x] add_dimension
- [ ] aggregate_temporal_period
- [ ] anomaly
- [x] apply
- [x] arccos
- [x] arcosh
- [ ] array_element
- [x] arsinh
- [x] arcsin
- [x] artanh
- [x] arctan
- [x] ceil
- [ ] climatological_normal
- [x] clip
- [x] cos
- [x] cosh
- [x] create_cube
- [ ] dimension_labels
- [x] divide
- [ ] drop_dimension
- [x] e
- [x] exp
- [ ] filter_bands
- [ ] filter_bbox
- [ ] filter_spatial
- [ ] filter_temporal
- [ ] first
- [x] floor
- [x] if
- [x] inspect
- [x] int
- [x] linear_scale_range
- [x] ln
- [ ] load_collection
- [x] log
- [ ] mask
- [ ] mean
- [ ] median
- [ ] merge_cubes
- [ ] min
- [x] multiply
- [x] nan
- [x] normalized_difference
- [x] pi
- [x] power
- [ ] product
- [ ] reduce_dimension
- [x] rename_dimension
- [ ] rename_labels
- [x] round
- [ ] save_result
- [ ] sd
- [x] sgn
- [x] sin
- [x] sinh
- [x] sqrt
- [x] subtract
- [ ] sum
- [x] tan
- [x] tanh
- [x] text_begins
- [x] text_concat
- [x] text_contains
- [x] text_ends


- [ ] variance

# OUTDATED: openEO v1.0.0 process status

- Mapping from an array to an image collection (preserve metadata) (important for e.g. sort)
- Properly read the default values from the JSON files
## Aggregate & Resample
- [ ] aggregate_spatial
* convert GeoJson geometry to GEE geometry
Expand Down Expand Up @@ -48,42 +104,42 @@ The following processes have a fully GEE-based implementation:
* process is missing in GEE
* one could only do it for JS arrays
- [ ] array_labels
- [ ] count
- [ ] count
* could be theoretically implemented with existing processes:
* `ee.ImageCollection.count()` or `sum()` as a reducer (mask needed)
* `ee.Image.updateMask(mask)`
* `ee.Image.updateMask(mask)`
- [X] first
* Only available as simple reducer
* implementation for arrays needed
- [X] last
* Only available as simple reducer
* implementation for arrays needed
- [ ] order
* process is missing in GEE
* process is missing in GEE
* maybe conversion to array?
* one could only do it for JS arrays
- [ ] rearrange
* process is missing in GEE
* maybe conversion to array?
* one could only do it for JS arrays
- [ ] sort
* conversion to array necessary.
* conversion to array necessary.
## Comparison
- [ ] between
* conversion to array necessary
* could be used by taking a chained process call into account
- [ ] eq
* conversion to array necessary
- [ ] neq
* conversion to array necessary.
- [ ] gt
* conversion to array necessary.
* conversion to array necessary.
- [ ] gt
* conversion to array necessary.
- [ ] lt
* conversion to array necessary.
* conversion to array necessary.
- [ ] gte
* conversion to array necessary.
* conversion to array necessary.
- [ ] lte
* conversion to array necessary.
* conversion to array necessary.
- [ ] is_nan
* one could only do it for numbers
* process is missing in GEE
Expand All @@ -93,15 +149,10 @@ The following processes have a fully GEE-based implementation:
- [ ] is_valid
* one could only do it for numbers
* process is missing in GEE
- [X] if
* usage of `ee.Algorithms.If()` missing, only JS supported atm
# Cubes
- [X] add_dimension
- [X] apply
- [ ] apply_dimension
- [ ] apply_kernel
* `ee.Image.convolve(kernel)` with `ee.Kernel..` could be used
- [X] create_raster_cube
- [X] dimension_labels
- [X] drop_dimension
- [ ] filter_labels
Expand All @@ -119,8 +170,6 @@ The following processes have a fully GEE-based implementation:
* filter metadata by properties is missing
* usage of common_bands metadata is missing
* bbox WKT implementation missing
- [ ] load_result
- [ ] load_uploaded_files
- [X] merge_cubes
* overlap resolver is missing
- [X] reduce_dimension
Expand All @@ -129,13 +178,6 @@ The following processes have a fully GEE-based implementation:
- [X] save_result
- [ ] trim_cube
* is not possible to be implemented at the moment
# Development
- [ ] debug
# Import
- [ ] run_udf
* is not possible to be implemented at the moment
- [ ] run_udf_externally
* is not possible to be implemented at the moment
# Logic
- [ ] all
* one could only do it for JS arrays
Expand All @@ -162,64 +204,21 @@ The following processes have a fully GEE-based implementation:
* create `ee.Array` mask from the polygon in JS
* then apply it in `ee.Image.arrayMask`
# Math
- [X] absolute
- [X] add
- [X] clip
- [X] divide
- [ ] extrema
* multiple return values need to be handled
- [X] int
- [X] linear_scale_range
- [X] max
- [X] mean
- [X] median
- [X] min
- [ ] mod
* available for arrays and numbers
- [X] multiply
- [X] power
- [X] product
- [ ] quantiles
* multiple return values need to be handled
- [X] sd
- [ ] sgn
- [X] sqrt
- [X] subtract
- [X] sum
- [X] variance
- [ ] cummax
* process accum for arrays and reducer max
* complex apply could do the main work
- [ ] cummin
* process accum for arrays and reducer min
* complex apply could do the main work
- [ ] cumsum
* process accum for arrays and reducer sum (default)
* complex apply could do the main work
- [ ] cumproduct
* process accum for arrays and reducer product
* complex apply could do the main work
- [X] exp
- [X] ln
- [X] log
- [X] normalized_difference
- [ ] ndvi
- [X] floor
- [X] ceil
- [X] int
- [X] round
- [X] cos
- [X] sin
- [X] tan
- [X] cosh
- [X] sinh
- [X] tanh
- [X] arccos
- [X] arcsin
- [X] arctan
- [X] arcosh
- [X] arsinh
- [X] artanh
- [ ] arctan2
* needs 2 arrays, i.e. it needs a complex apply

4 changes: 2 additions & 2 deletions src/processes/absolute.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class absolute extends GeeProcess {

executeSync(node) {
return Commons.applyInCallback(node, image => image.abs());
return GeeUtils.applyNumFunction(node, data => data.abs());
}

}
7 changes: 2 additions & 5 deletions src/processes/add.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class add extends GeeProcess {

executeSync(node) {
return Commons.reduceBinaryInCallback(
node,
(a, b) => a.add(b)
);
return GeeUtils.applyBinaryNumFunction(node, (x, y) => x.add(y));
}

}
12 changes: 5 additions & 7 deletions src/processes/add_dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import GeeProcess from '../processgraph/process.js';
export default class add_dimension extends GeeProcess {

executeSync(node) {
const dc = node.getDataCube("data");
const dc = node.getDataCube('data');
const name = node.getArgument('name');
const label = node.getArgument('label');
const type = node.getArgument("type");
const type = node.getArgument('type');

if (dc.hasDimension(name)) {
throw new Errors.DimensionExists({
Expand All @@ -16,13 +16,11 @@ export default class add_dimension extends GeeProcess {
});
}

const dimension = dc.addDimension(name, type);
// We can't add x and y spatial dimensions.
const axis = (type === 'spatial') ? 'z' : null;
const dimension = dc.addDimension(name, type, axis);
dimension.addValue(label);

// Todo processes: A Number value for label causes problems
if (!Number.isInteger(label)) {
dc.renameLabels(dimension, [label], ["#"]);
}
return dc;
}

Expand Down
9 changes: 3 additions & 6 deletions src/processes/add_dimension.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@
},
{
"name": "type",
"description": "The type of dimension, defaults to `other`.",
"description": "The type of dimension.\n\nIf the type is `spatial`, the axis is always `z`, spatial dimensions for `x` and `y` can't be added through this process.",
"schema": {
"type": "string",
"enum": [
"bands",
"geometry",
"spatial",
"temporal",
"other"
"temporal"
]
},
"default": "other",
"optional": true
}
}
],
"returns": {
Expand Down
4 changes: 2 additions & 2 deletions src/processes/arccos.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class arccos extends GeeProcess {

executeSync(node) {
return Commons.applyInCallback(node, image => image.acos());
return GeeUtils.applyNumFunction(node, data => data.acos());
}

}
15 changes: 3 additions & 12 deletions src/processes/arcosh.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class arcosh extends GeeProcess {

executeSync(node) {
return Commons.applyInCallback(
node,
image => {
// Using arcosh formula for calculation (see wikipedia)
let img_p2 = image.pow(2);
img_p2 = img_p2.subtract(1);
img_p2 = img_p2.sqrt();
const result = image.add(img_p2);
return result.log();
}
);
// Using arcosh formula for calculation (see wikipedia)
return GeeUtils.applyNumFunction(node, data => data.add(data.pow(2).subtract(1).sqrt()).log());
}

}
4 changes: 2 additions & 2 deletions src/processes/arcsin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class arcsin extends GeeProcess {

executeSync(node) {
return Commons.applyInCallback(node, image => image.asin());
return GeeUtils.applyNumFunction(node, data => data.asin());
}

}
4 changes: 2 additions & 2 deletions src/processes/arctan.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';
import GeeUtils from '../processgraph/utils.js';

export default class arctan extends GeeProcess {

executeSync(node) {
return Commons.applyInCallback(node, image => image.atan());
return GeeUtils.applyNumFunction(node, data => data.atan());
}

}
Loading

0 comments on commit e741b88

Please sign in to comment.