Skip to content

Commit

Permalink
Merge pull request #5 from lawi119/integrate-kerchunk-indices
Browse files Browse the repository at this point in the history
updated to check a wave-fc file and check for valid kerchunk indices
  • Loading branch information
Tom Augspurger authored Nov 2, 2023
2 parents f134755 + 991b3c6 commit a85596d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 57 deletions.
10 changes: 9 additions & 1 deletion src/stactools/ecmwf_forecast/_kerchunk_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ def get_kerchunk_indices(part):
elif ((part.stream == "scwv") or (part.stream == "wave")) and (part.type == "fc"):
mzz = MultiZarrToZarr(out, concat_dims=["time"])

return compress_lat_lon(mzz.translate())
return convert_base64(compress_lat_lon(mzz.translate()))

def convert_base64(d):
for key in d['refs']:
if (('/0' in key) & ('.' not in key) & ('latitude' not in key) & ('longitude' not in key)):
if d['refs'][key][0:6]!='base64':
d['refs'][key] = (b"base64:" + base64.b64encode(d['refs'][key].encode())).decode()

return d


def compress_lat_lon(d):
Expand Down
14 changes: 8 additions & 6 deletions src/stactools/ecmwf_forecast/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_collection(
),
}
),
"index": pystac.extensions.item_assets.AssetDefinition(
"index": pystac.extensions.item_assets.AssetDefinition(
{
"type": NDJSON_MEDIA_TYPE,
"roles": ["index"],
Expand Down Expand Up @@ -369,10 +369,6 @@ def _create_item_from_parts(parts: list[Parts], split_by_step=False) -> Item:
fs = fsspec.filesystem("")
fs.clear_instance_cache()

# remove this once this has been tested for all 7 collections
if (part.stream == "wave") & (part.type == "fc"):
item.properties["kerchunk:indices"] = khf.get_kerchunk_indices(part)

if split_by_step:
item.properties["ecmwf:step"] = part.step
else:
Expand All @@ -386,12 +382,18 @@ def _create_item_from_parts(parts: list[Parts], split_by_step=False) -> Item:
if p.format == "grib2":
media_type = GRIB2_MEDIA_TYPE
roles = ["data"]
if ((p.stream == "wave") & (p.type == "fc")):
kerchunk_indices = khf.get_kerchunk_indices(p)
else:
kerchunk_indices = {}
elif p.format == "index":
media_type = NDJSON_MEDIA_TYPE
roles = ["index"]
kerchunk_indices = None
elif p.format == "bufr":
media_type = None
roles = ["data"]
kerchunk_indices = None
else:
raise ValueError(f"Bad extension: {p.format}")

Expand All @@ -401,7 +403,7 @@ def _create_item_from_parts(parts: list[Parts], split_by_step=False) -> Item:
p.filename,
media_type=media_type,
roles=roles,
extra_fields={"ecmwf:step": p.step} if not split_by_step else {},
extra_fields={"ecmwf:step": p.step, "kerchunk:indices": kerchunk_indices} if not split_by_step else {"kerchunk:indices": kerchunk_indices},
),
)

Expand Down
1 change: 1 addition & 0 deletions tests/blob_kerchunk_indices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": 1, "refs": {".zgroup": "{\"zarr_format\":2}", "time/.zarray": "{\n \"chunks\": [\n 1\n ],\n \"compressor\": null,\n \"dtype\": \"<i8\",\n \"fill_value\": null,\n \"filters\": null,\n \"order\": \"C\",\n \"shape\": [\n 1\n ],\n \"zarr_format\": 2\n}", "time/0": "base64:gHEwZQAAAAA=", "time/.zattrs": "{\n \"_ARRAY_DIMENSIONS\": [\n \"time\"\n ],\n \"calendar\": \"proleptic_gregorian\",\n \"long_name\": \"initial time of forecast\",\n \"standard_name\": \"forecast_reference_time\",\n \"units\": \"seconds since 1970-01-01T00:00:00\"\n}", ".zattrs": "{\"GRIB_centre\":\"ecmf\",\"GRIB_centreDescription\":\"European Centre for Medium-Range Weather Forecasts\",\"GRIB_edition\":2,\"GRIB_subCentre\":0,\"coordinates\":\"meanSea latitude longitude step time valid_time\",\"institution\":\"European Centre for Medium-Range Weather Forecasts\"}", "swh/.zarray": "{\"chunks\":[1,451,900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"dtype\":\"float64\",\"id\":\"grib\",\"var\":\"swh\"}],\"order\":\"C\",\"shape\":[1,451,900],\"zarr_format\":2}", "swh/.zattrs": "{\"GRIB_NV\":0,\"GRIB_Nx\":900,\"GRIB_Ny\":451,\"GRIB_cfName\":\"unknown\",\"GRIB_cfVarName\":\"swh\",\"GRIB_dataType\":\"fc\",\"GRIB_gridDefinitionDescription\":\"Latitude\\/longitude\",\"GRIB_gridType\":\"regular_ll\",\"GRIB_iDirectionIncrementInDegrees\":0.4,\"GRIB_iScansNegatively\":0,\"GRIB_jDirectionIncrementInDegrees\":0.4,\"GRIB_jPointsAreConsecutive\":0,\"GRIB_jScansPositively\":0,\"GRIB_latitudeOfFirstGridPointInDegrees\":90.0,\"GRIB_latitudeOfLastGridPointInDegrees\":-90.0,\"GRIB_longitudeOfFirstGridPointInDegrees\":180.0,\"GRIB_longitudeOfLastGridPointInDegrees\":179.6,\"GRIB_missingValue\":3.4028234663852886e+38,\"GRIB_name\":\"Significant height of combined wind waves and swell\",\"GRIB_numberOfPoints\":405900,\"GRIB_paramId\":140229,\"GRIB_shortName\":\"swh\",\"GRIB_stepType\":\"instant\",\"GRIB_stepUnits\":1,\"GRIB_typeOfLevel\":\"meanSea\",\"GRIB_units\":\"m\",\"_ARRAY_DIMENSIONS\":[\"time\",\"latitude\",\"longitude\"],\"long_name\":\"Significant height of combined wind waves and swell\",\"standard_name\":\"unknown\",\"units\":\"m\"}", "swh/0.0.0": ["https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2", 0, 322850], "meanSea/.zarray": "{\"chunks\":[1],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":null,\"order\":\"C\",\"shape\":[1],\"zarr_format\":2}", "meanSea/.zattrs": "{\"_ARRAY_DIMENSIONS\":[\"time\"]}", "meanSea/0": "base64:AAAAAAAAAAA=", "latitude/.zarray": "{\"chunks\":[451],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"id\": \"range\"}],\"order\":\"C\",\"shape\":[451],\"zarr_format\":2}", "latitude/0": "base64:AAAAAACAVkCamZmZmZlWwJqZmZmZmdm/", "latitude/.zattrs": "{\"_ARRAY_DIMENSIONS\":[\"latitude\"],\"long_name\":\"latitude\",\"standard_name\":\"latitude\",\"units\":\"degrees_north\"}", "longitude/.zarray": "{\"chunks\":[900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"id\": \"range\"}],\"order\":\"C\",\"shape\":[900],\"zarr_format\":2}", "longitude/0": "base64:AAAAAACAZsAAAAAAAIBmQJqZmZmZmdk/", "longitude/.zattrs": "{\"_ARRAY_DIMENSIONS\":[\"longitude\"],\"long_name\":\"longitude\",\"standard_name\":\"longitude\",\"units\":\"degrees_east\"}", "step/.zarray": "{\"chunks\":[1],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":null,\"order\":\"C\",\"shape\":[1],\"zarr_format\":2}", "step/.zattrs": "{\"_ARRAY_DIMENSIONS\":[\"time\"],\"long_name\":\"time since forecast_reference_time\",\"standard_name\":\"forecast_period\",\"units\":\"hours\"}", "step/0": "base64:AAAAAAAAAAA=", "valid_time/.zarray": "{\"chunks\":[1],\"compressor\":null,\"dtype\":\"<i8\",\"fill_value\":null,\"filters\":null,\"order\":\"C\",\"shape\":[1],\"zarr_format\":2}", "valid_time/.zattrs": "{\"_ARRAY_DIMENSIONS\":[\"time\"],\"calendar\":\"proleptic_gregorian\",\"long_name\":\"time\",\"standard_name\":\"time\",\"units\":\"seconds since 1970-01-01T00:00:00\"}", "valid_time/0": "base64:gHEwZQAAAAA=", "mwd/.zarray": "{\"chunks\":[1,451,900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"dtype\":\"float64\",\"id\":\"grib\",\"var\":\"mwd\"}],\"order\":\"C\",\"shape\":[1,451,900],\"zarr_format\":2}", "mwd/.zattrs": "{\"GRIB_NV\":0,\"GRIB_Nx\":900,\"GRIB_Ny\":451,\"GRIB_cfName\":\"unknown\",\"GRIB_cfVarName\":\"mwd\",\"GRIB_dataType\":\"fc\",\"GRIB_gridDefinitionDescription\":\"Latitude\\/longitude\",\"GRIB_gridType\":\"regular_ll\",\"GRIB_iDirectionIncrementInDegrees\":0.4,\"GRIB_iScansNegatively\":0,\"GRIB_jDirectionIncrementInDegrees\":0.4,\"GRIB_jPointsAreConsecutive\":0,\"GRIB_jScansPositively\":0,\"GRIB_latitudeOfFirstGridPointInDegrees\":90.0,\"GRIB_latitudeOfLastGridPointInDegrees\":-90.0,\"GRIB_longitudeOfFirstGridPointInDegrees\":180.0,\"GRIB_longitudeOfLastGridPointInDegrees\":179.6,\"GRIB_missingValue\":3.4028234663852886e+38,\"GRIB_name\":\"Mean wave direction\",\"GRIB_numberOfPoints\":405900,\"GRIB_paramId\":140230,\"GRIB_shortName\":\"mwd\",\"GRIB_stepType\":\"instant\",\"GRIB_stepUnits\":1,\"GRIB_typeOfLevel\":\"meanSea\",\"GRIB_units\":\"Degree true\",\"_ARRAY_DIMENSIONS\":[\"time\",\"latitude\",\"longitude\"],\"long_name\":\"Mean wave direction\",\"standard_name\":\"unknown\",\"units\":\"Degree true\"}", "mwd/0.0.0": ["https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2", 322850, 342261], "mwp/.zarray": "{\"chunks\":[1,451,900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"dtype\":\"float64\",\"id\":\"grib\",\"var\":\"mwp\"}],\"order\":\"C\",\"shape\":[1,451,900],\"zarr_format\":2}", "mwp/.zattrs": "{\"GRIB_NV\":0,\"GRIB_Nx\":900,\"GRIB_Ny\":451,\"GRIB_cfName\":\"unknown\",\"GRIB_cfVarName\":\"mwp\",\"GRIB_dataType\":\"fc\",\"GRIB_gridDefinitionDescription\":\"Latitude\\/longitude\",\"GRIB_gridType\":\"regular_ll\",\"GRIB_iDirectionIncrementInDegrees\":0.4,\"GRIB_iScansNegatively\":0,\"GRIB_jDirectionIncrementInDegrees\":0.4,\"GRIB_jPointsAreConsecutive\":0,\"GRIB_jScansPositively\":0,\"GRIB_latitudeOfFirstGridPointInDegrees\":90.0,\"GRIB_latitudeOfLastGridPointInDegrees\":-90.0,\"GRIB_longitudeOfFirstGridPointInDegrees\":180.0,\"GRIB_longitudeOfLastGridPointInDegrees\":179.6,\"GRIB_missingValue\":3.4028234663852886e+38,\"GRIB_name\":\"Mean wave period\",\"GRIB_numberOfPoints\":405900,\"GRIB_paramId\":140232,\"GRIB_shortName\":\"mwp\",\"GRIB_stepType\":\"instant\",\"GRIB_stepUnits\":1,\"GRIB_typeOfLevel\":\"meanSea\",\"GRIB_units\":\"s\",\"_ARRAY_DIMENSIONS\":[\"time\",\"latitude\",\"longitude\"],\"long_name\":\"Mean wave period\",\"standard_name\":\"unknown\",\"units\":\"s\"}", "mwp/0.0.0": ["https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2", 665111, 327350], "pp1d/.zarray": "{\"chunks\":[1,451,900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"dtype\":\"float64\",\"id\":\"grib\",\"var\":\"pp1d\"}],\"order\":\"C\",\"shape\":[1,451,900],\"zarr_format\":2}", "pp1d/.zattrs": "{\"GRIB_NV\":0,\"GRIB_Nx\":900,\"GRIB_Ny\":451,\"GRIB_cfName\":\"unknown\",\"GRIB_cfVarName\":\"pp1d\",\"GRIB_dataType\":\"fc\",\"GRIB_gridDefinitionDescription\":\"Latitude\\/longitude\",\"GRIB_gridType\":\"regular_ll\",\"GRIB_iDirectionIncrementInDegrees\":0.4,\"GRIB_iScansNegatively\":0,\"GRIB_jDirectionIncrementInDegrees\":0.4,\"GRIB_jPointsAreConsecutive\":0,\"GRIB_jScansPositively\":0,\"GRIB_latitudeOfFirstGridPointInDegrees\":90.0,\"GRIB_latitudeOfLastGridPointInDegrees\":-90.0,\"GRIB_longitudeOfFirstGridPointInDegrees\":180.0,\"GRIB_longitudeOfLastGridPointInDegrees\":179.6,\"GRIB_missingValue\":3.4028234663852886e+38,\"GRIB_name\":\"Peak wave period\",\"GRIB_numberOfPoints\":405900,\"GRIB_paramId\":140231,\"GRIB_shortName\":\"pp1d\",\"GRIB_stepType\":\"instant\",\"GRIB_stepUnits\":1,\"GRIB_typeOfLevel\":\"meanSea\",\"GRIB_units\":\"s\",\"_ARRAY_DIMENSIONS\":[\"time\",\"latitude\",\"longitude\"],\"long_name\":\"Peak wave period\",\"standard_name\":\"unknown\",\"units\":\"s\"}", "pp1d/0.0.0": ["https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2", 992461, 340620], "mp2/.zarray": "{\"chunks\":[1,451,900],\"compressor\":null,\"dtype\":\"<f8\",\"fill_value\":null,\"filters\":[{\"dtype\":\"float64\",\"id\":\"grib\",\"var\":\"mp2\"}],\"order\":\"C\",\"shape\":[1,451,900],\"zarr_format\":2}", "mp2/.zattrs": "{\"GRIB_NV\":0,\"GRIB_Nx\":900,\"GRIB_Ny\":451,\"GRIB_cfName\":\"unknown\",\"GRIB_cfVarName\":\"mp2\",\"GRIB_dataType\":\"fc\",\"GRIB_gridDefinitionDescription\":\"Latitude\\/longitude\",\"GRIB_gridType\":\"regular_ll\",\"GRIB_iDirectionIncrementInDegrees\":0.4,\"GRIB_iScansNegatively\":0,\"GRIB_jDirectionIncrementInDegrees\":0.4,\"GRIB_jPointsAreConsecutive\":0,\"GRIB_jScansPositively\":0,\"GRIB_latitudeOfFirstGridPointInDegrees\":90.0,\"GRIB_latitudeOfLastGridPointInDegrees\":-90.0,\"GRIB_longitudeOfFirstGridPointInDegrees\":180.0,\"GRIB_longitudeOfLastGridPointInDegrees\":179.6,\"GRIB_missingValue\":3.4028234663852886e+38,\"GRIB_name\":\"Mean zero-crossing wave period\",\"GRIB_numberOfPoints\":405900,\"GRIB_paramId\":140221,\"GRIB_shortName\":\"mp2\",\"GRIB_stepType\":\"instant\",\"GRIB_stepUnits\":1,\"GRIB_typeOfLevel\":\"meanSea\",\"GRIB_units\":\"s\",\"_ARRAY_DIMENSIONS\":[\"time\",\"latitude\",\"longitude\"],\"long_name\":\"Mean zero-crossing wave period\",\"standard_name\":\"unknown\",\"units\":\"s\"}", "mp2/0.0.0": ["https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2", 1333081, 354874]}}
114 changes: 64 additions & 50 deletions tests/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
import pytest

from stactools.ecmwf_forecast import stac
import json
import os
import urllib.request

blob_file = ("https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/"
"0p4-beta/wave/20231019000000-0h-wave-fc.grib2")
local_files = ["20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-3h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-3h-wave-fc.index",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.index"]
for i, local_file in enumerate(local_files):
if not os.path.exists(local_file):
if i==1:
os.makedirs(local_file.split('.')[0], exist_ok=True)
urllib.request.urlretrieve(blob_file, local_file)


def test_create_collection():
Expand All @@ -21,61 +37,61 @@ def test_create_collection():
@pytest.mark.parametrize(
"filename",
[
"20220202000000-0h-enfo-ef.grib2",
"20220202/00z/0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2",
(
"https://ai4edataeuwest.blob.core.windows.net/ecmwf/20220202/00z/"
"0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2"
),
"20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2",
("https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/"
"0p4-beta/wave/20231019000000-0h-wave-fc.grib2"),
],
)
def test_create_items(filename):
item = stac.create_item_from_representative_asset(filename)
assert item.id == "ecmwf-2022-02-02T00-enfo-ef"
assert len(item.assets) == 170
item = stac.create_item([filename])

assert item.id == "ecmwf-2023-10-19T00-wave-fc"
assert len(item.assets) == 1
assert item.bbox == [-180.0, -90.0, 180.0, 90.0]
assert item.properties["ecmwf:stream"] == "enfo"
assert item.properties["ecmwf:type"] == "ef"
assert item.properties["start_datetime"] == "2022-02-02T00:00:00Z"
assert item.properties["end_datetime"] == "2022-02-17T00:00:00Z"


assert item.properties["ecmwf:stream"] == "wave"
assert item.properties["ecmwf:type"] == "fc"
assert item.properties["ecmwf:forecast_datetime"] == "2023-10-19T00:00:00Z"
assert item.properties[
"ecmwf:reference_datetime"] == "2023-10-19T00:00:00Z"
if filename.startswith("https://ai4edataeuwest.blob.core.windows.net/"):
with open("tests/blob_kerchunk_indices.json") as jsonfile:
kerchunk_indices = json.load(jsonfile)
assert item.assets["0h-grib2"].to_dict()["kerchunk:indices"] == kerchunk_indices


@pytest.mark.parametrize(
"filename",
[
"20220202000000-0h-enfo-ef.grib2",
"20220202/00z/0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2",
(
"https://ai4edataeuwest.blob.core.windows.net/ecmwf/20220202/00z/"
"0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2"
),
"20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2",
("https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/"
"0p4-beta/wave/20231019000000-0h-wave-fc.grib2"),
],
)
def test_parts(filename):
result = stac.Parts.from_filename(filename)
assert result.reference_datetime == datetime.datetime(2022, 2, 2)
assert result.stream == "enfo"
assert result.reference_datetime == datetime.datetime(2023, 10, 19)
assert result.stream == "wave"
assert result.step == "0h"
assert result.type == "ef"
assert result.type == "fc"
assert result.format == "grib2"
assert result.filename == filename
assert result.name == "20220202000000-0h-enfo-ef.grib2"
assert result.item_id == "ecmwf-2022-02-02T00-enfo-ef"
assert result.name == "20231019000000-0h-wave-fc.grib2"
assert result.item_id == "ecmwf-2023-10-19T00-wave-fc"
assert result.asset_id == "0h-grib2"
if not filename.startswith("20220202000000-0h"):
if not filename.startswith("20231019000000-0h"):
assert result.filename != result.name
assert result.prefix == filename.rsplit("/", 1)[0] + "/"


@pytest.mark.parametrize(
"filename",
[
"20220202000000-0h-enfo-ef.grib2",
"20220202/00z/0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2",
(
"https://ai4edataeuwest.blob.core.windows.net/ecmwf/20220202/00z/"
"0p4-beta/enfo/20220202000000-0h-enfo-ef.grib2"
),
"20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2",
("https://ai4edataeuwest.blob.core.windows.net/ecmwf/20231019/00z/"
"0p4-beta/wave/20231019000000-0h-wave-fc.grib2"),
],
)
def test_list_sibling_assets(filename):
Expand All @@ -94,10 +110,10 @@ def test_list_sibling_assets(filename):

def test_split_by_parts():
files = [
"ecmwf/20220222/00z/0p4-beta/enfo/20220222000000-0h-enfo-ef.grib2",
"ecmwf/20220222/00z/0p4-beta/enfo/20220222000000-0h-enfo-ef.index",
"ecmwf/20220222/00z/0p4-beta/enfo/20220222000000-3h-enfo-ef.grib2",
"ecmwf/20220222/00z/0p4-beta/enfo/20220222000000-3h-enfo-ef.index",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-0h-wave-fc.index",
"20231019/00z/0p4-beta/wave/20231019000000-3h-wave-fc.grib2",
"20231019/00z/0p4-beta/wave/20231019000000-3h-wave-fc.index",
]

stac.create_item(files)
Expand All @@ -106,27 +122,25 @@ def test_split_by_parts():
stac.create_item(files, split_by_step=True)

i0, i1 = stac.create_item(files[:2], split_by_step=True), stac.create_item(
files[2:], split_by_step=True
)
files[2:], split_by_step=True)
assert i0.properties["ecmwf:step"] == "0h"
assert i1.properties["ecmwf:step"] == "3h"
assert i0.assets["data"].extra_fields == {}
assert i1.datetime == datetime.datetime(2022, 2, 22, 3)
#assert i0.assets["data"].extra_fields == {}
assert i1.datetime == datetime.datetime(2023, 10, 19, 3)
assert i1.id.endswith("3h")



def test_item_assets():
collection = stac.create_collection()
assert collection.extra_fields["item_assets"]["data"]["roles"] == ["data"]
assert (
collection.extra_fields["item_assets"]["data"]["type"]
== "application/wmo-GRIB2"
)
assert collection.extra_fields["item_assets"]["index"]["roles"] == ["index"]
assert (
collection.extra_fields["item_assets"]["index"]["type"]
== "application/x-ndjson"
)
assert (collection.extra_fields["item_assets"]["data"]["type"] ==
"application/wmo-GRIB2")
assert collection.extra_fields["item_assets"]["index"]["roles"] == [
"index"
]
assert (collection.extra_fields["item_assets"]["index"]["type"] ==
"application/x-ndjson")

# assert collection.extra_fields["item_assets"]["index"] == {
# "roles": ["index"],
Expand Down

0 comments on commit a85596d

Please sign in to comment.