Skip to content

Commit

Permalink
Add more datacube tests, add int datacube example
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Dec 13, 2023
1 parent 5e3ce04 commit 610bc69
Show file tree
Hide file tree
Showing 6 changed files with 345 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ This folder contains test cases for the openEO processes.
- [x] and
- [ ] anomaly
- [x] any
- [ ] apply
- [ ] apply_dimension
- [x] apply*
- [x] apply_dimension*
- [ ] apply_kernel
- [ ] apply_neighborhood
- [ ] apply_polygon (experimental)
Expand Down Expand Up @@ -107,7 +107,7 @@ This folder contains test cases for the openEO processes.
- [x] product
- [x] quantiles
- [x] rearrange*
- [ ] reduce_dimension
- [x] reduce_dimension*
- [ ] reduce_spatial (experimental)
- [ ] rename_dimension
- [ ] rename_labels
Expand Down
157 changes: 156 additions & 1 deletion tests/apply.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"level": "L1",
"tests": [
{
// single math process
"required": [
"add"
],
"arguments": {
"data": {
"$ref": "assets/xyt-minimal.json5"
"$ref": "assets/xyt-minimal-float.json5"
},
"process": {
"process_graph": {
Expand Down Expand Up @@ -62,6 +63,160 @@
]
]
}
},
{
// multiple processes with a data type change
"required": [
"lt",
"gt",
"or"
],
"arguments": {
"data": {
"$ref": "assets/xyt-minimal-float.json5"
},
"process": {
"process_graph": {
"lt": {
"process_id": "lt",
"arguments": {
"x": {
"from_argument": "x"
},
"y": -50
}
},
"gt": {
"process_id": "gt",
"arguments": {
"x": {
"from_argument": "x"
},
"y": 50
}
},
"or": {
"process_id": "or",
"arguments": {
"x": {
"from_node": "lt"
},
"y": {
"from_node": "gt"
}
},
"result": true
}
}
}
},
"returns": {
"type": "datacube",
"nodata": NaN,
"dimensions": [
{
"name": "t",
"type": "temporal",
"values": ["2020-06-01T00:00:00Z", "2020-06-03T00:00:00Z"]
},
{
"name": "y",
"type": "spatial",
"axis": "y",
"values": [5757495.0, 5757485.0, 5757475.0],
"reference_system": "EPSG:25832"
},
{
"name": "x",
"type": "spatial",
"axis": "x",
"values": [404835.0, 404845.0, 404855.0, 404865.0],
"reference_system": "EPSG:25832"
}
],
"data": [
[
[false, true, false, true],
[false, false, false, false],
[true, false, false, true]
],
[
[true, false, true, false],
[false, true, true, true],
[false, false, NaN, false]
]
]
}
},
{
// math on integers
"required": [
"multiply"
],
"arguments": {
"data": {
"$ref": "assets/xyb-minimal-int.json5"
},
"process": {
"process_graph": {
"add": {
"process_id": "multiply",
"arguments": {
"x": {
"from_parameter": "x"
},
"y": {
"from_parameter": "context"
}
},
"result": true
}
}
},
"context": 10
},
"returns": {
"type": "datacube",
"nodata": 0,
"dimensions": [
{
"name": "bands",
"type": "bands",
"values": ["red", "green", "blue"]
},
{
"name": "y",
"type": "spatial",
"axis": "y",
"values": [5757495.0, 5757485.0, 5757475.0],
"reference_system": "EPSG:25832"
},
{
"name": "x",
"type": "spatial",
"axis": "x",
"values": [404835.0, 404845.0, 404855.0, 404865.0],
"reference_system": "EPSG:25832"
}
],
"data": [
[
[1720, 470, 1170, 1920],
[670, 2510, 1950, 1030],
[90, 2110, 0, 2420]
],
[
[360, 870, 700, 2160],
[880, 1400, 580, 1930],
[2300, 390, 0, 870]
],
[
[1740, 880, 810, 1650],
[250, 770, 720, 90],
[1480, 1150, 0, 2080]
]
]
}
}
]
}
69 changes: 68 additions & 1 deletion tests/apply_dimension.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"arguments": {
"data": {
"$ref": "assets/xyt-minimal.json5"
"$ref": "assets/xyt-minimal-float.json5"
},
"process": {
"process_graph": {
Expand Down Expand Up @@ -62,6 +62,73 @@
]
]
}
},
{
"required": [
"quantiles"
],
"arguments": {
"data": {
"$ref": "assets/xyb-minimal-int.json5"
},
"process": {
"process_graph": {
"quantiles": {
"process_id": "quantiles",
"arguments": {
"data": {
"from_parameter": "data"
}
},
"result": true
}
}
},
"dimension": "bands",
"target_dimension": "quantiles",
},
"returns": {
"type": "datacube",
"nodata": NaN,
"dimensions": [
{
"name": "quantiles",
"type": "other",
"values": [0, 1, 2]
},
{
"name": "y",
"type": "spatial",
"axis": "y",
"values": [5757495.0, 5757485.0, 5757475.0],
"reference_system": "EPSG:25832"
},
{
"name": "x",
"type": "spatial",
"axis": "x",
"values": [404835.0, 404845.0, 404855.0, 404865.0],
"reference_system": "EPSG:25832"
}
],
"data": [
[
[172.0, 87.0, 81.0, 192.0],
[67.0, 140.0, 72.0, 103.0],
[148.0, 115.0, NaN, 208.0]
],
[
[173.0, 87.5, 99.0, 204.0],
[77.5, 195.5, 133.5, 148.0],
[189.0, 163.0, NaN, 225.0]
],
[
[173.6, 87.8, 109.8, 211.2],
[83.8, 228.8, 170.4, 175.0],
[213.6, 191.8, NaN, 235.2]
]
]
}
}
]
}
42 changes: 42 additions & 0 deletions tests/assets/xyb-minimal-int.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "datacube",
"nodata": 0,
"dimensions": [
{
"name": "bands",
"type": "bands",
"values": ["red", "green", "blue"]
},
{
"name": "y",
"type": "spatial",
"axis": "y",
"values": [5757495.0, 5757485.0, 5757475.0],
"reference_system": "EPSG:25832"
},
{
"name": "x",
"type": "spatial",
"axis": "x",
"values": [404835.0, 404845.0, 404855.0, 404865.0],
"reference_system": "EPSG:25832"
}
],
"data": [
[
[172, 47, 117, 192],
[67, 251, 195, 103],
[9, 211, 0, 242]
],
[
[36, 87, 70, 216],
[88, 140, 58, 193],
[230, 39, 0, 87]
],
[
[174, 88, 81, 165],
[25, 77, 72, 9],
[148, 115, 0, 208]
]
]
}
File renamed without changes.
Loading

0 comments on commit 610bc69

Please sign in to comment.