-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #573 metadata_from_stac: add support for "item_assets"
- Loading branch information
Showing
7 changed files
with
228 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Utilities for testing | ||
""" | ||
|
||
import json | ||
from pathlib import Path | ||
from typing import Callable, Optional, Union | ||
|
||
|
||
class TestDataLoader: | ||
""" | ||
Helper to resolve paths to test data files, loadt them as JSON, and optionally preprocess them. | ||
It's recommended to set this up as a fixture in your test suite, | ||
e.g. from conftest.py: | ||
@pytest.fixture | ||
def test_data() -> TestDataLoader: | ||
return TestDataLoader(root=Path(__file__).parent / "data") | ||
""" | ||
|
||
def __init__(self, root: Union[str, Path]): | ||
self.data_root = Path(root) | ||
|
||
def get_path(self, filename: Union[str, Path]) -> Path: | ||
"""Get absolute path to a test data file""" | ||
return self.data_root / filename | ||
|
||
def load_json(self, filename: Union[str, Path], preprocess: Optional[Callable[[str], str]] = None) -> dict: | ||
"""Parse data from JSON file""" | ||
data = self.get_path(filename).read_text(encoding="utf8") | ||
if preprocess: | ||
data = preprocess(data) | ||
return json.loads(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"type": "Collection", | ||
"id": "agera5_daily", | ||
"stac_version": "1.0.0", | ||
"description": "ERA5", | ||
"links": [ | ||
{ | ||
"rel": "self", | ||
"type": "application/json", | ||
"href": "https://stac.test/collections/agera5_daily" | ||
} | ||
], | ||
"stac_extensions": [ | ||
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", | ||
"https://stac-extensions.github.io/eo/v1.1.0/schema.json" | ||
], | ||
"item_assets": { | ||
"2m_temperature_min": { | ||
"type": "image/tiff; application=geotiff", | ||
"title": "2m temperature min 24h", | ||
"eo:bands": [ | ||
{ | ||
"name": "2m_temperature_min", | ||
"description": "temperature 2m above ground (Kelvin)" | ||
} | ||
] | ||
}, | ||
"2m_temperature_max": { | ||
"type": "image/tiff; application=geotiff", | ||
"eo:bands": [ | ||
{ | ||
"name": "2m_temperature_max", | ||
"description": "temperature 2m above ground (Kelvin)" | ||
} | ||
] | ||
}, | ||
"dewpoint_temperature_mean": { | ||
"type": "image/tiff; application=geotiff", | ||
"title": "2m dewpoint temperature", | ||
"eo:bands": [ | ||
{ | ||
"name": "dewpoint_temperature_mean", | ||
"description": "dewpoint temperature 2m above ground (Kelvin)" | ||
} | ||
] | ||
}, | ||
"vapour_pressure": { | ||
"eo:bands": [ | ||
{ | ||
"name": "vapour_pressure" | ||
} | ||
] | ||
} | ||
}, | ||
"title": "agERA5 data", | ||
"extent": { | ||
"spatial": { | ||
"bbox": [ | ||
[ | ||
-180, | ||
-90, | ||
180, | ||
90 | ||
] | ||
] | ||
}, | ||
"temporal": { | ||
"interval": [ | ||
[ | ||
"2010-01-01T00:00:00Z", | ||
"2024-06-12T00:00:00Z" | ||
] | ||
] | ||
} | ||
}, | ||
"keywords": [ | ||
"ERA5" | ||
], | ||
"summaries": {}, | ||
"assets": {}, | ||
"license": "proprietary" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters