-
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.
Merge pull request #401 from DHI/netcdf-3d
Support for 3d via xarray (NetCDF etc)
- Loading branch information
Showing
6 changed files
with
67 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import modelskill as ms | ||
import pytest | ||
import xarray as xr | ||
|
||
def test_extract_point_from_3d(): | ||
mr = ms.GridModelResult( | ||
"tests/testdata/cmems_mod_med_phy-sal_anfc_4.2km-3D_PT1H-m_1705916517624.nc", | ||
item="so", | ||
name="MedSea", | ||
) | ||
|
||
point_ds = xr.open_dataset("tests/testdata/aegean_sea_salinity_ts.nc") | ||
|
||
# TODO use x,y,z without explicitly setting them (NetCDF has them as coordinates) | ||
obs = ms.PointObservation( | ||
point_ds, | ||
x=float(point_ds.longitude), | ||
y=float(point_ds.latitude), | ||
z=float(point_ds.depth), | ||
item="so", | ||
) | ||
|
||
cmp = ms.match(obs=obs, mod=mr, spatial_method="nearest") | ||
assert cmp.quantity.name == "Salinity" | ||
assert cmp.quantity.unit == "0.001" | ||
|
||
sc = cmp.score() | ||
|
||
# "Observed" data is extracted from the 3D model result, so the score should be 0.0 | ||
assert sc["MedSea"] == pytest.approx(0.0) |
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
Binary file not shown.
Binary file added
BIN
+584 KB
tests/testdata/cmems_mod_med_phy-sal_anfc_4.2km-3D_PT1H-m_1705916517624.nc
Binary file not shown.