Skip to content

Commit

Permalink
Update processes to latest version, implement inspect #81, e, pi and nan
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jan 23, 2024
1 parent c145dc0 commit cec7da5
Show file tree
Hide file tree
Showing 88 changed files with 2,831 additions and 2,663 deletions.
18 changes: 10 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

[*.{js,json,yml}]
[*]
charset = utf-8
end_of_line = crlf
indent_style = tabs
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yaml,yml}]
charset = utf-8
end_of_line = crlf
[*.js]
indent_style = tabs
indent_size = 2

[*.{yaml,yml,json}]
indent_style = spaces
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[src/processes/*.json]
indent_style = spaces
indent_size = 4
2 changes: 1 addition & 1 deletion src/processes/absolute.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "absolute",
"summary": "Absolute value",
"description": "Computes the absolute value of a real number `x`, which is the \"unsigned\" portion of x and often denoted as *|x|*.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
"description": "Computes the absolute value of a real number `x`, which is the \"unsigned\" portion of `x` and often denoted as *|x|*.\n\nThe no-data value `null` is passed through and therefore gets propagated.",
"categories": [
"math"
],
Expand Down
2 changes: 1 addition & 1 deletion src/processes/add.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "add",
"summary": "Addition of two numbers",
"description": "Sums up the two numbers `x` and `y` (*x + y*) and returns the computed sum.\n\nNo-data values are taken into account so that `null` is returned if any element is such a value.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it.",
"description": "Sums up the two numbers `x` and `y` (*`x + y`*) and returns the computed sum.\n\nNo-data values are taken into account so that `null` is returned if any element is such a value.\n\nThe computations follow [IEEE Standard 754](https://ieeexplore.ieee.org/document/8766229) whenever the processing environment supports it.",
"categories": [
"math"
],
Expand Down
7 changes: 4 additions & 3 deletions src/processes/add_dimension.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "add_dimension",
"summary": "Add a new dimension",
"description": "Adds a new named dimension to the data cube.\n\nAfterwards, the dimension can be referenced with the specified `name`. If a dimension with the specified name exists, the process fails with a `DimensionExists` error. The dimension label of the dimension is set to the specified `label`.",
"description": "Adds a new named dimension to the data cube.\n\nAfterwards, the dimension can be referred to with the specified `name`. If a dimension with the specified name exists, the process fails with a `DimensionExists` exception. The dimension label of the dimension is set to the specified `label`.",
"categories": [
"cubes"
],
Expand Down Expand Up @@ -39,9 +39,10 @@
"schema": {
"type": "string",
"enum": [
"bands",
"geometry",
"spatial",
"temporal",
"bands",
"other"
]
},
Expand All @@ -61,4 +62,4 @@
"message": "A dimension with the specified name already exists."
}
}
}
}
112 changes: 0 additions & 112 deletions src/processes/aggregate_temporal_frequency.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import GeeProcess from '../processgraph/process.js';
import Commons from '../processgraph/commons.js';

export default class aggregate_temporal_frequency extends GeeProcess {
export default class aggregate_temporal_period extends GeeProcess {

reduce(node, imageCollection) {
const callback = node.getCallback('reducer');
Expand All @@ -25,10 +25,10 @@ export default class aggregate_temporal_frequency extends GeeProcess {
const ee = node.ee;
// STEP 1: Get parameters and set some variables
const dc = node.getDataCube('data');
const frequency = node.getArgument('frequency');
const period = node.getArgument('period');

// STEP 2: prepare image collection with aggregation label
const images = Commons.setAggregationLabels(node, dc.imageCollection(), frequency);
const images = Commons.setAggregationLabels(node, dc.imageCollection(), period);

// STEP 3: aggregate based on aggregation label

Expand Down
115 changes: 115 additions & 0 deletions src/processes/aggregate_temporal_period.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"id": "aggregate_temporal_period",
"summary": "Temporal aggregations based on calendar hierarchies",
"description": "Computes a temporal aggregation based on calendar hierarchies such as years, months or seasons. For other calendar hierarchies ``aggregate_temporal()`` can be used.\n\nFor each interval, all data along the dimension will be passed through the reducer.\n\nIf the dimension is not set or is set to `null`, the data cube is expected to only have one temporal dimension.",
"categories": [
"aggregate",
"climatology",
"cubes"
],
"parameters": [
{
"name": "data",
"description": "The source data cube.",
"schema": {
"type": "object",
"subtype": "raster-cube"
}
},
{
"name": "period",
"description": "The time intervals to aggregate. The following pre-defined values are available:\n\n* `hour`: Hour of the day\n* `day`: Day of the year\n* `week`: Week of the year\n* `dekad`: Ten day periods, counted per year with three periods per month (day 1 - 10, 11 - 20 and 21 - end of month). The third dekad of the month can range from 8 to 11 days. For example, the third dekad of a year spans from January 21 till January 31 (11 days), the fourth dekad spans from February 1 till February 10 (10 days) and the sixth dekad spans from February 21 till February 28 or February 29 in a leap year (8 or 9 days respectively).\n* `month`: Month of the year\n* `season`: Three month periods of the calendar seasons (December - February, March - May, June - August, September - November).\n* `tropical-season`: Six month periods of the tropical seasons (November - April, May - October).\n* `year`: Proleptic years\n* `decade`: Ten year periods ([0-to-9 decade](https://en.wikipedia.org/wiki/Decade#0-to-9_decade)), from a year ending in a 0 to the next year ending in a 9.\n* `decade-ad`: Ten year periods ([1-to-0 decade](https://en.wikipedia.org/wiki/Decade#1-to-0_decade)) better aligned with the anno Domini (AD) calendar era, from a year ending in a 1 to the next year ending in a 0.",
"schema": {
"type": "string",
"enum": [
"hour",
"day",
"week",
"month",
"season",
"tropical-season",
"year"
]
}
},
{
"name": "reducer",
"description": "A reducer to be applied for the values contained in each period. A reducer is a single process such as ``mean()`` or a set of processes, which computes a single value for a list of values, see the category 'reducer' for such processes. Periods may not contain any values, which for most reducers leads to no-data (`null`) values by default.",
"schema": {
"type": "object",
"subtype": "process-graph",
"parameters": [
{
"name": "data",
"description": "A labeled array with elements of any type. If there's no data for the period, the array is empty.",
"schema": {
"type": "array",
"subtype": "labeled-array",
"items": {
"description": "Any data type."
}
}
},
{
"name": "context",
"description": "Additional data passed by the user.",
"schema": {
"description": "Any data type."
},
"optional": true,
"default": null
}
],
"returns": {
"description": "The value to be set in the new data cube.",
"schema": {
"description": "Any data type."
}
}
}
},
{
"name": "dimension",
"description": "The name of the temporal dimension for aggregation. All data along the dimension is passed through the specified reducer. If the dimension is not set or set to `null`, the source data cube is expected to only have one temporal dimension. Fails with a `TooManyDimensions` exception if it has more dimensions. Fails with a `DimensionNotAvailable` exception if the specified dimension does not exist.",
"schema": {
"type": [
"string",
"null"
]
},
"optional": true,
"default": null
},
{
"name": "context",
"description": "Additional data to be passed to the reducer.",
"schema": {
"description": "Any data type."
},
"optional": true,
"default": null
}
],
"returns": {
"description": "A new data cube with the same dimensions. The dimension properties (name, type, labels, reference system and resolution) remain unchanged, except for the resolution and dimension labels of the given temporal dimension. The specified temporal dimension has the following dimension labels (`YYYY` = four-digit year, `MM` = two-digit month, `DD` two-digit day of month):\n\n* `hour`: `YYYY-MM-DD-00` - `YYYY-MM-DD-23`\n* `day`: `YYYY-001` - `YYYY-365`\n* `week`: `YYYY-01` - `YYYY-52`\n* `dekad`: `YYYY-00` - `YYYY-36`\n* `month`: `YYYY-01` - `YYYY-12`\n* `season`: `YYYY-djf` (December - February), `YYYY-mam` (March - May), `YYYY-jja` (June - August), `YYYY-son` (September - November).\n* `tropical-season`: `YYYY-ndjfma` (November - April), `YYYY-mjjaso` (May - October).\n* `year`: `YYYY`\n* `decade`: `YYY0`\n* `decade-ad`: `YYY1`\n\nThe dimension labels in the new data cube are complete for the whole extent of the source data cube. For example, if `period` is set to `day` and the source data cube has two dimension labels at the beginning of the year (`2020-01-01`) and the end of a year (`2020-12-31`), the process returns a data cube with 365 dimension labels (`2020-001`, `2020-002`, ..., `2020-365`). In contrast, if `period` is set to `day` and the source data cube has just one dimension label `2020-01-05`, the process returns a data cube with just a single dimension label (`2020-005`).",
"schema": {
"type": "object",
"subtype": "raster-cube"
}
},
"exceptions": {
"TooManyDimensions": {
"message": "The data cube contains multiple temporal dimensions. The parameter `dimension` must be specified."
},
"DimensionNotAvailable": {
"message": "A dimension with the specified name does not exist or no temporal dimension is available."
}
},
"links": [
{
"href": "https://openeo.org/documentation/1.0/datacubes.html#aggregate",
"rel": "about",
"title": "Aggregation explained in the openEO documentation"
}
]
}
4 changes: 2 additions & 2 deletions src/processes/anomaly.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default class anomaly extends GeeProcess {
const normalsLabels = node.ee.List(normalsDataCube.dimT().getValues());
const normalsCollection = normalsDataCube.imageCollection();
const normals = normalsCollection.toList(normalsCollection.size());
const frequency = node.getArgument('frequency');
const period = node.getArgument('period');

let images = Commons.setAggregationLabels(node, dc.imageCollection(), frequency);
let images = Commons.setAggregationLabels(node, dc.imageCollection(), period);
images = images.map(image => {
const label = image.get('label');
const normal = normals.get(normalsLabels.indexOf(label));
Expand Down
Loading

0 comments on commit cec7da5

Please sign in to comment.