def build_rcm(num_lev=30, water_depth=2.5): # Temperatures in a single column state = climlab.column_state(num_lev=num_lev, water_depth=water_depth) # Initialize a nearly dry column (small background stratospheric humidity) state['q'] = np.ones_like(state.Tatm) * 5.E-6 # ASYNCHRONOUS COUPLING -- the radiation uses a much longer timestep short_timestep = climlab.constants.seconds_per_hour # Radiation coupled to water vapor rad = climlab.radiation.RRTMG(name='Radiation', state=state, specific_humidity=state.q, albedo=0.2, timestep=24*short_timestep) # Convection scheme -- water vapor is a state variable conv = climlab.convection.EmanuelConvection(name='Convection', state=state, timestep=short_timestep, ALPHA=0.1,) # Surface heat flux processes shf = climlab.surface.SensibleHeatFlux(name='SHF', state=state, Cd=0.5E-3, U=10., timestep=short_timestep) lhf = climlab.surface.LatentHeatFlux(name='LHF', state=state, Cd=0.5E-3, U=10., timestep=short_timestep) # Couple all the submodels together turb = climlab.couple([shf,lhf], name='Turbulent') model = climlab.couple([rad, conv, turb], name='RadiativeConvectiveModel') for proc in [rad, conv, shf, lhf]: model.add_subprocess(proc.name, proc) return model
def test_radiative_forcing(): '''Run a single-column radiative-convective model with RRTMG radiation out to equilibrium. Clone the model, double CO2 and measure the instantaneous change in TOA flux. It should be positive net downward flux.''' # State variables (Air and surface temperature) state = climlab.column_state(num_lev=30, water_depth=1.) # Fixed relative humidity h2o = climlab.radiation.ManabeWaterVapor(name='WaterVapor', state=state) # Couple water vapor to radiation # Set icld=0 for clear-sky only (no need to call cloud overlap routine) rad = climlab.radiation.RRTMG(name='Radiation', state=state, specific_humidity=h2o.q, icld=0) # Convective adjustment conv = climlab.convection.ConvectiveAdjustment(name='Convection', state=state, adj_lapse_rate=6.5) # Couple everything together rcm = climlab.couple([rad, h2o, conv], name='Radiative-Convective Model') rcm.integrate_years(5.) assert np.abs(rcm.ASR - rcm.OLR) < 0.1 # close to energy balance rcm2 = climlab.process_like(rcm) rcm2.subprocess['Radiation'].absorber_vmr['CO2'] *= 2. rcm2.compute_diagnostics() assert (rcm2.ASR - rcm2.OLR) > 1. # positive radiative forcing # Test the xarray interface to_xarray(rcm2)
def test_radiative_forcing(): '''Run a single-column radiative-convective model with RRTMG radiation out to equilibrium. Clone the model, double CO2 and measure the instantaneous change in TOA flux. It should be positive net downward flux.''' # State variables (Air and surface temperature) state = climlab.column_state(num_lev=30, water_depth=1.) # Fixed relative humidity h2o = climlab.radiation.ManabeWaterVapor(name='WaterVapor', state=state) # Couple water vapor to radiation # Set icld=0 for clear-sky only (no need to call cloud overlap routine) rad = climlab.radiation.RRTMG(name='Radiation', state=state, specific_humidity=h2o.q, icld=0) # Convective adjustment conv = climlab.convection.ConvectiveAdjustment(name='Convection', state=state, adj_lapse_rate=6.5) # Couple everything together rcm = climlab.couple([rad,h2o,conv], name='Radiative-Convective Model') rcm.integrate_years(5.) assert np.abs(rcm.ASR - rcm.OLR) < 0.1 # close to energy balance rcm2 = climlab.process_like(rcm) rcm2.subprocess['Radiation'].absorber_vmr['CO2'] *= 2. rcm2.compute_diagnostics() assert (rcm2.ASR - rcm2.OLR) > 1. # positive radiative forcing # Test the xarray interface to_xarray(rcm2)
def rcm(): # initial state (temperatures) state = climlab.column_state(num_lev=40, num_lat=1, water_depth=5.) ## Create individual physical process models: # fixed relative humidity h2o = climlab.radiation.ManabeWaterVapor(state=state, name='H2O') # Hard convective adjustment convadj = climlab.convection.ConvectiveAdjustment(state=state, name='ConvectiveAdjustment', adj_lapse_rate=6.5) # RRTMG radiation with default parameters and interactive water vapor rad = climlab.radiation.RRTMG(state=state, albedo=0.2, specific_humidity=h2o.q, name='Radiation') # Couple the models rcm = climlab.couple([h2o,convadj,rad], name='RCM') return rcm
def rcm(): # initial state (temperatures) state = climlab.column_state(num_lev=40, num_lat=1, water_depth=5.) ## Create individual physical process models: # fixed relative humidity h2o = climlab.radiation.ManabeWaterVapor(state=state, name='H2O') # Hard convective adjustment convadj = climlab.convection.ConvectiveAdjustment(state=state, name='ConvectiveAdjustment', adj_lapse_rate=6.5) # RRTMG radiation with default parameters and interactive water vapor rad = climlab.radiation.RRTMG(state=state, albedo=0.2, specific_humidity=h2o.q, name='Radiation') # Couple the models rcm = climlab.couple([h2o,convadj,rad], name='RCM') return rcm