Skip to content

Commit

Permalink
Merge pull request #19 from andypbarrett/test_run_model
Browse files Browse the repository at this point in the history
Test run model
  • Loading branch information
andypbarrett authored Jul 10, 2023
2 parents d7f79bf + 0f4fb25 commit 054731d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion seaicert/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def calculate_flux_and_par(
model.snow_depth = snow_depth
model.surface_air_temperature = skin_temperature
model.ground_temperature = skin_temperature
model.pond_depth = 0.
model.pond_depth = pond_depth

model.run()

Expand Down
32 changes: 32 additions & 0 deletions tests/test_run_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Tests for run_model"""

import datetime as dt
import numpy as np

from seaicert.model import run_model

# Define inputs to match default inputs
latitude = 80.0
thisdatetime = dt.datetime(2023, 5, 20, 11, 26, 53, 232000)
ice_thickness = 1.5
snow_depth = 0.0
skin_temperature = 273.16
pond_depth = 0.5
sea_ice_concentration = 1.
pond_fraction = 1.
expected_albedo = 0.14001
expected_surface_flux = 179.19
expected_ocean_flux = 27.57
expected_transmittance = 0.1538

def test_default_run():
"""Tests default inputs"""
result = run_model(latitude, thisdatetime,
ice_thickness, snow_depth,
skin_temperature,
sea_ice_concentration,
pond_depth, pond_fraction)
expected = np.array([expected_albedo, expected_surface_flux,
expected_ocean_flux, expected_transmittance])
result = np.concatenate(result)
assert np.allclose(result, expected, atol=1e-2)

0 comments on commit 054731d

Please sign in to comment.