Skip to content

Commit

Permalink
update examples, schema and tests with scaling definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Oct 31, 2024
1 parent a65be79 commit 0c73c39
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 110 deletions.
17 changes: 14 additions & 3 deletions examples/item_eo_and_raster_bands.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,59 +96,70 @@
],
"data_type": "float32"
},
"norm_by_channel": true,
"norm_type": "z-score",
"resize_type": null,
"statistics": [
"scaling": [
{
"type": "z-score",
"mean": 1354.40546513,
"stddev": 245.71762908
},
{
"type": "z-score",
"mean": 1118.24399958,
"stddev": 333.00778264
},
{
"type": "z-score",
"mean": 1042.92983953,
"stddev": 395.09249139
},
{
"type": "z-score",
"mean": 947.62620298,
"stddev": 593.75055589
},
{
"type": "z-score",
"mean": 1199.47283961,
"stddev": 566.4170017
},
{
"type": "z-score",
"mean": 1999.79090914,
"stddev": 861.18399006
},
{
"type": "z-score",
"mean": 2369.22292565,
"stddev": 1086.63139075
},
{
"type": "z-score",
"mean": 2296.82608323,
"stddev": 1117.98170791
},
{
"type": "z-score",
"mean": 732.08340178,
"stddev": 404.91978886
},
{
"type": "z-score",
"mean": 12.11327804,
"stddev": 4.77584468
},
{
"type": "z-score",
"mean": 1819.01027855,
"stddev": 1002.58768311
},
{
"type": "z-score",
"mean": 1118.92391149,
"stddev": 761.30323499
},
{
"type": "z-score",
"mean": 2594.14080798,
"stddev": 1231.58581042
}
Expand Down
16 changes: 14 additions & 2 deletions examples/item_eo_bands.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,58 +98,70 @@
"data_type": "float32"
},
"norm_by_channel": true,
"norm_type": "z-score",
"resize_type": null,
"statistics": [
"scaling": [
{
"type": "z-score",
"mean": 1354.40546513,
"stddev": 245.71762908
},
{
"type": "z-score",
"mean": 1118.24399958,
"stddev": 333.00778264
},
{
"type": "z-score",
"mean": 1042.92983953,
"stddev": 395.09249139
},
{
"type": "z-score",
"mean": 947.62620298,
"stddev": 593.75055589
},
{
"type": "z-score",
"mean": 1199.47283961,
"stddev": 566.4170017
},
{
"type": "z-score",
"mean": 1999.79090914,
"stddev": 861.18399006
},
{
"type": "z-score",
"mean": 2369.22292565,
"stddev": 1086.63139075
},
{
"type": "z-score",
"mean": 2296.82608323,
"stddev": 1117.98170791
},
{
"type": "z-score",
"mean": 732.08340178,
"stddev": 404.91978886
},
{
"type": "z-score",
"mean": 12.11327804,
"stddev": 4.77584468
},
{
"type": "z-score",
"mean": 1819.01027855,
"stddev": 1002.58768311
},
{
"type": "z-score",
"mean": 1118.92391149,
"stddev": 761.30323499
},
{
"type": "z-score",
"mean": 2594.14080798,
"stddev": 1231.58581042
}
Expand Down
17 changes: 14 additions & 3 deletions examples/item_eo_bands_summarized.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,59 +97,70 @@
],
"data_type": "float32"
},
"norm_by_channel": true,
"norm_type": "z-score",
"resize_type": null,
"statistics": [
"scaling": [
{
"type": "z-score",
"mean": 1354.40546513,
"stddev": 245.71762908
},
{
"type": "z-score",
"mean": 1118.24399958,
"stddev": 333.00778264
},
{
"type": "z-score",
"mean": 1042.92983953,
"stddev": 395.09249139
},
{
"type": "z-score",
"mean": 947.62620298,
"stddev": 593.75055589
},
{
"type": "z-score",
"mean": 1199.47283961,
"stddev": 566.4170017
},
{
"type": "z-score",
"mean": 1999.79090914,
"stddev": 861.18399006
},
{
"type": "z-score",
"mean": 2369.22292565,
"stddev": 1086.63139075
},
{
"type": "z-score",
"mean": 2296.82608323,
"stddev": 1117.98170791
},
{
"type": "z-score",
"mean": 732.08340178,
"stddev": 404.91978886
},
{
"type": "z-score",
"mean": 12.11327804,
"stddev": 4.77584468
},
{
"type": "z-score",
"mean": 1819.01027855,
"stddev": 1002.58768311
},
{
"type": "z-score",
"mean": 1118.92391149,
"stddev": 761.30323499
},
{
"type": "z-score",
"mean": 2594.14080798,
"stddev": 1231.58581042
}
Expand Down
3 changes: 1 addition & 2 deletions examples/item_multi_io.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@
],
"data_type": "uint16"
},
"norm_by_channel": false,
"norm_type": null,
"scaling": null,
"resize_type": null
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/item_raster_bands.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
],
"data_type": "float32"
},
"norm_type": null,
"scaling": null,
"resize_type": null,
"pre_processing_function": {
"format": "python",
Expand Down
99 changes: 1 addition & 98 deletions json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,7 @@
"mlm:input": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "#/$defs/ModelInput"
},
{
"$ref": "#/$defs/ModelInputNormTypeStatistics"
}
]
"$ref": "#/$defs/ModelInput"
}
},
"ModelInput": {
Expand Down Expand Up @@ -529,93 +522,11 @@
"resize_type": {
"$ref": "#/$defs/ResizeType"
},
"statistics": {
"$ref": "#/$defs/InputStatistics"
},
"pre_processing_function": {
"$ref": "#/$defs/ProcessingExpression"
}
}
},
"ModelInputNormTypeStatistics": {
"description": "Validates the corresponding statistics required for the specified normalization type.",
"allOf": [
{
"if": {
"type": "object",
"required": [
"norm_type"
],
"properties": {
"norm_type": {
"const": "min-max"
}
}
},
"then": {
"type": "object",
"required": [
"statistics"
],
"properties": {
"statistics": {
"allOf": [
{
"$ref": "#/$defs/InputStatistics"
},
{
"type": "array",
"items": {
"required": [
"minimum",
"maximum"
]
}
}
]
}
}
}
},
{
"if": {
"type": "object",
"required": [
"norm_type"
],
"properties": {
"norm_type": {
"const": "z-score"
}
}
},
"then": {
"type": "object",
"required": [
"statistics"
],
"properties": {
"statistics": {
"allOf": [
{
"$ref": "#/$defs/InputStatistics"
},
{
"type": "array",
"items": {
"required": [
"mean",
"stddev"
]
}
}
]
}
}
}
}
]
},
"mlm:output": {
"type": "array",
"items": {
Expand Down Expand Up @@ -921,14 +832,6 @@
}
]
},
"InputStatistics": {
"$comment": "MLM statistics for the specific input relevant for normalization for ML features.",
"type": "array",
"minItems": 1,
"items": {
"$ref": "https://stac-extensions.github.io/raster/v1.1.0/schema.json#/definitions/bands/items/properties/statistics"
}
},
"ProcessingExpression": {
"oneOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_mlm_no_input_allowed_but_explicit_empty_array_required(
], True),
],
)
def test_mlm_input_norm_type_statistics_combination(
def test_mlm_input_scaling_combination(
mlm_validator: STACValidator,
mlm_example: Dict[str, JSON],
test_scaling: List[Dict[str, Any]],
Expand Down

0 comments on commit 0c73c39

Please sign in to comment.