Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ dev = [
"pre-commit>=4.0.0",
"ipython>=9.11.0",
"pytest>=9.0.2",
"pooch>=1.9.0",
]
test = [
"mxalign",
"pooch",
]
8 changes: 8 additions & 0 deletions src/mlwp_data_loaders/loaders/harp/obstable.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def load_dataset(
altitude=("code", alt_values),
)

ds.coords["valid_time"].attrs["standard_name"] = "time"
ds.coords["latitude"].attrs.update(
{"standard_name": "latitude", "units": "degrees_north"}
)
ds.coords["longitude"].attrs.update(
{"standard_name": "longitude", "units": "degrees_east"}
)

return ds.rename_dims({"code": "point_index"}).transpose(
"valid_time", "point_index"
)
54 changes: 54 additions & 0 deletions tests/test_harp_obstable_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Integration tests for the built-in ``harp.obstable`` loader."""

from __future__ import annotations

import pooch
import pytest
from mlwp_data_specs import validate_dataset

from mlwp_data_loaders.api import load_dataset
from mlwp_data_loaders.core import get_dataset_traits_from_loader
from mlwp_data_loaders.mxalign_api import validate_dataset_with_mxalign

HARP_DATA_URL = "https://raw.githubusercontent.com/harphub/harpData/master/inst/OBSTABLE/OBSTABLE_2019.sqlite"
HARP_DATA_HASH = "bdab991c287a41871488456d1a9d697942aa3a612800a88264defa312a9d637b"
LOADER = "mlwp_data_loaders.loaders.harp.obstable"


@pytest.fixture(scope="module")
def obstable_path() -> str:
"""Download and cache the test SQLite dataset."""
return pooch.retrieve(
url=HARP_DATA_URL,
known_hash=HARP_DATA_HASH,
)


def test_load_dataset_opens_harp_obstable(obstable_path: str) -> None:
"""The harp.obstable loader can open and validate the sample SQLite file."""
ds = load_dataset(
obstable_path,
loader=LOADER,
)

traits = get_dataset_traits_from_loader(LOADER)

report_mxalign = validate_dataset_with_mxalign(
ds,
time=traits.get("time_profile"),
space=traits.get("space_profile"),
uncertainty=traits.get("uncertainty_profile"),
)
if report_mxalign.has_fails():
report_mxalign.console_print()
assert not report_mxalign.has_fails()

report_specs = validate_dataset(
ds,
time=traits.get("time_profile"),
space=traits.get("space_profile"),
uncertainty=traits.get("uncertainty_profile"),
)
if report_specs.has_fails():
report_specs.console_print()
assert not report_specs.has_fails()
22 changes: 21 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading