-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal tests for CAM3 Radiation module.
- Loading branch information
1 parent
7ee2229
commit 65d399b
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
import climlab | ||
import pytest | ||
|
||
num_lev = 20 | ||
alb = 0.25 | ||
|
||
@pytest.fixture() | ||
def rcm(): | ||
# initial state (temperatures) | ||
state = climlab.column_state(num_lev=num_lev, num_lat=1, water_depth=5.) | ||
# Create a parent process | ||
rcm = climlab.TimeDependentProcess(state=state) | ||
## Create individual physical process models: | ||
# fixed relative humidity | ||
h2o = climlab.radiation.water_vapor.ManabeWaterVapor(state=state) | ||
# Hard convective adjustment | ||
convadj = climlab.convection.convadj.ConvectiveAdjustment(state=state, | ||
adj_lapse_rate=6.5) | ||
# CAM3 radiation with default parameters and interactive water vapor | ||
rad = climlab.radiation.CAM3Radiation(state=state, O3init=True, | ||
aldif=alb, aldir=alb, asdif=alb, asdir=alb) | ||
rad.q = h2o.q | ||
# Couple the models | ||
rcm.add_subprocess('Radiation', rad) | ||
rcm.add_subprocess('ConvectiveAdjustment', convadj) | ||
rcm.add_subprocess('H2O', h2o) | ||
# Make diagnostic water vapor field easy to access | ||
rcm.q = rcm.subprocess.H2O.q | ||
return rcm | ||
|
||
def test_model_creation(rcm): | ||
'''Just make sure we can create a model and have access to the Fortran object.''' | ||
assert len(rcm.Tatm)==num_lev | ||
assert (rcm.subprocess.Radiation.extension.get_nlev() == num_lev) | ||
|
||
def test_rce(rcm): | ||
'''Test a single-column radiative-convective model with CAM3 radiation and | ||
fixed relative humidity.''' | ||
rcm.step_forward() | ||
#rcm.integrate_years(5) | ||
#assert(np.isclose(rcm.Ts, )) |