Skip to content

Commit

Permalink
test forecast values change over time
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 19, 2024
1 parent 980546b commit 54ac9c1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/msise00/tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
import pytest
import xarray
import xarray.tests
import xarray.testing
import importlib.resources

import msise00
Expand All @@ -29,7 +29,7 @@ def test_one_alt_one_time():
dat_mod = msise00.run(time, altkm, lat, lon).squeeze()
except ConnectionError:
pytest.skip("unable to download RecentIndices.txt")
xarray.tests.assert_allclose(ref, dat_mod)
xarray.testing.assert_allclose(ref, dat_mod)


def test_script(tmp_path):
Expand All @@ -44,4 +44,4 @@ def test_script(tmp_path):
subprocess.check_call(cmd)

dat = xarray.open_dataset(fn)
xarray.tests.assert_allclose(ref, dat)
xarray.testing.assert_allclose(ref, dat)
15 changes: 3 additions & 12 deletions src/msise00/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_past():


def test_forecast():
t = datetime(2023, 3, 31, 12)
t = datetime(2029, 3, 31, 12)
altkm = 150.0
glat = 65.0
glon = -148.0
Expand All @@ -50,16 +50,7 @@ def test_forecast():
dims = list(atmos.dims)
assert ["time", "alt_km", "lat", "lon"] == dims

assert atmos["He"].item() == approx(4.3926901e12)
assert atmos["O"].item() == approx(4.5728936e15)
assert atmos["N2"].item() == approx(3.7001117e16)
assert atmos["O2"].item() == approx(8.1215314e15)
assert atmos["Ar"].item() == approx(3.3594181e14)
assert atmos["Total"].item() == approx(2.2950717e-09)
assert atmos["N"].item() == approx(2.155302e12)
assert atmos["AnomalousO"].item() == approx(8.7590428e-16)

assert atmos.species == ["He", "O", "N2", "O2", "Ar", "Total", "H", "N", "AnomalousO"]

assert atmos["Tn"].item() == approx(667.06, abs=0.01)
assert atmos["Texo"].item() == approx(922.28, abs=0.01)
assert atmos["Tn"].item() == approx(616.09, abs=0.1)
assert atmos["Texo"].item() == approx(769.82, abs=0.01)
6 changes: 3 additions & 3 deletions src/msise00/tests/test_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import subprocess
import pytest
import xarray
import xarray.tests
import xarray.testing
import msise00
import msise00.worldgrid

Expand All @@ -29,7 +29,7 @@ def test_one_loc_one_time(altkm, reffn):
dat_mod = msise00.run(time, altkm, lat, lon).squeeze()
except ConnectionError:
pytest.skip("unable to download RecentIndices.txt")
xarray.tests.assert_allclose(ref, dat_mod)
xarray.testing.assert_allclose(ref, dat_mod)


@pytest.mark.parametrize("altkm,reffn", [(100.0, "ref5.nc"), (200.0, "ref6.nc")])
Expand All @@ -45,4 +45,4 @@ def test_script(altkm, reffn, tmp_path):
subprocess.check_call(cmd)

dat = xarray.open_dataset(fn)
xarray.tests.assert_allclose(ref, dat)
xarray.testing.assert_allclose(ref, dat)
6 changes: 3 additions & 3 deletions src/msise00/tests/test_time_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import subprocess
import pytest
import xarray
import xarray.tests
import xarray.testing
import msise00
import msise00.worldgrid

Expand All @@ -28,7 +28,7 @@ def test_multiple_time():
dat_mod = msise00.run(time, altkm, lat, lon).squeeze()
except ConnectionError:
pytest.skip("unable to download RecentIndices.txt")
xarray.tests.assert_allclose(ref, dat_mod)
xarray.testing.assert_allclose(ref, dat_mod)


def test_script(tmp_path):
Expand All @@ -43,4 +43,4 @@ def test_script(tmp_path):
subprocess.check_call(cmd)

dat = xarray.open_dataset(fn)
xarray.tests.assert_allclose(ref, dat)
xarray.testing.assert_allclose(ref, dat)

0 comments on commit 54ac9c1

Please sign in to comment.