From a8b479ba249d2fdb864b29e27ac303c5aba35518 Mon Sep 17 00:00:00 2001 From: Brian Rose Date: Mon, 10 Jul 2023 10:45:23 -0400 Subject: [PATCH] New tests for EBM with diurnal cycle --- climlab/tests/test_domain2D.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/climlab/tests/test_domain2D.py b/climlab/tests/test_domain2D.py index 7c7bfda5..caa8c038 100644 --- a/climlab/tests/test_domain2D.py +++ b/climlab/tests/test_domain2D.py @@ -70,7 +70,7 @@ def test_diurnal_cycle(): state_daily = climlab.surface_state(num_lat=num_lat, water_depth=0.5) - deltat_daily = 3600.*24. + deltat_daily = 3600.*12. # 12 hour timestep olr_daily = climlab.radiation.AplusBT(name='OLR (daily)', state=state_daily, timestep=deltat_daily) @@ -88,8 +88,14 @@ def test_diurnal_cycle(): # zonal average diurnally-varying insolation should match daily mean insolation assert np.allclose(ebm.ASR.mean(axis=1), ebm_daily.ASR) - # Now we will check to see if the average ASR over one day at each point in longitude + # Now we will check to see if the average ASR over one day and all longitudes # is equal to ASR over a single one-day step in the daily insolation model - for model in [ebm, ebm_daily]: - model.integrate_days(1) - assert np.allclose(ebm.ti) # how do we access the time mean again? \ No newline at end of file + + # advance the daily model forward by half a day to align the calendars + ebm_daily.step_forward() + # and recalculate the diagnostics at the updated time + ebm_daily.compute_diagnostics() + # Now do one full day for the diurnal model + ebm.integrate_days(1.) + # Results should match within a small absolute tolerance in W/m2. + assert np.allclose(ebm.timeave['ASR'].mean(axis=1), ebm_daily.ASR, atol=0.05)