-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #493 from DHI/Feature-489-add-toy-data
Feature: add toy data
Showing
9 changed files
with
877 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
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,53 @@ | ||
""" | ||
Toy datasets for testing and demonstration purposes | ||
Examples | ||
-------- | ||
```{python} | ||
>>> import modelskill as ms | ||
>>> cc = ms.data.vistula() | ||
>>> cc | ||
``` | ||
```{python} | ||
>>> cc = ms.data.oresund() | ||
>>> cc | ||
``` | ||
""" | ||
|
||
from importlib.resources import files | ||
|
||
import modelskill as ms | ||
from ..comparison import ComparerCollection | ||
|
||
|
||
def vistula() -> ComparerCollection: | ||
"""5-year daily discharge data for Vistula catchment, Poland | ||
Contains discharge data for 8 stations along the Vistula river | ||
compared with two hydrological models "sim1" and "sim2". | ||
The dataset additionally contains precipitation data as aux data | ||
and metadata about the river and the catchment area in the attrs dictionary. | ||
Returns | ||
------- | ||
ComparerCollection | ||
""" | ||
fn = str(files("modelskill.data") / "vistula.msk") | ||
return ms.load(fn) | ||
|
||
|
||
def oresund() -> ComparerCollection: | ||
"""Oresund water level data for Jan-June 2022 compared with MIKE21 model | ||
Contains water level data for 7 stations along the Oresund strait with | ||
metadata about the country in the attrs dictionary. | ||
The dataset contains additional ERA5 wind-components U10 and V10 aux data. | ||
Returns | ||
------- | ||
ComparerCollection | ||
""" | ||
fn = str(files("modelskill.data") / "oresund.msk") | ||
return ms.load(fn) |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,52 @@ | ||
import os | ||
|
||
import pytest | ||
import modelskill as ms | ||
|
||
|
||
@pytest.fixture | ||
def change_test_directory(tmp_path): | ||
original_directory = os.getcwd() | ||
os.chdir(tmp_path) | ||
yield tmp_path | ||
os.chdir(original_directory) | ||
|
||
|
||
def test_load_vistula(change_test_directory): | ||
cc = ms.data.vistula() | ||
assert isinstance(cc, ms.ComparerCollection) | ||
assert len(cc) == 8 | ||
assert cc.mod_names == ["sim1", "sim2"] | ||
assert cc[0].name == "Tczew" | ||
assert cc[-1].n_points == 1827 | ||
assert cc[-1].y == 52.94889 | ||
|
||
assert cc[0].quantity.name == "Discharge" | ||
assert cc[0].quantity.unit == "m3/s" | ||
|
||
assert cc.aux_names == ["Precipitation"] | ||
assert float(cc[1].data.Precipitation[0]) == pytest.approx(1.18) | ||
assert cc[0].attrs["River"] == "Vistula" | ||
assert cc[0].attrs["Area"] == 193922.9 | ||
|
||
assert cc[1].raw_mod_data["sim2"].n_points == 1827 | ||
assert isinstance(cc[0].raw_mod_data["sim1"], ms.PointModelResult) | ||
|
||
|
||
def test_load_oresund(change_test_directory): | ||
cc = ms.data.oresund() | ||
assert isinstance(cc, ms.ComparerCollection) | ||
assert len(cc) == 7 | ||
assert cc.mod_names == ["MIKE21"] | ||
assert cc[-1].name == "Vedbaek" | ||
assert cc[0].n_points == 8422 | ||
assert cc[0].x == pytest.approx(12.7117) | ||
|
||
assert cc[0].quantity.name == "Surface Elevation" | ||
assert cc[0].quantity.unit == "meter" | ||
|
||
assert cc.aux_names == ["U10", "V10"] | ||
assert cc[-1].attrs["Country"] == "DK" | ||
|
||
assert cc[1].raw_mod_data["MIKE21"].n_points == 4344 | ||
assert isinstance(cc[0].raw_mod_data["MIKE21"], ms.PointModelResult) |