Пример #1
0
def sweep_down(model, dq, years, verbose=False):
    q = q_from_S0(model.subprocess['insolation'].S0)
    if verbose:
        print 'Starting sweep down from initial q = {}'.format(q)
    snowball = False
    last_stable_ice_edge = None
    previous_stable_ice_edge = None
    qlist = []
    ice_area_list = []
    while not snowball:
        qlist.append(q)
        model.subprocess['insolation'].S0 = S0_from_q(q)
        model.integrate_years(years, verbose=False)
        model.integrate_years(1., verbose=False)
        ice_area_list.append(model.timeave['ice_area'])
        if verbose:
            print 'q = {}'.format(q)
            print 'ice_area = {}'.format(model.timeave['ice_area'])
        if (model.timeave['ice_area'] == 1.):
            snowball = True
        else:
            try:
                previous_stable_ice_edge = climlab.process_like(
                    last_stable_ice_edge)
            except:
                pass
            last_stable_ice_edge = climlab.process_like(model)
            q -= dq
    if previous_stable_ice_edge is None:
        return ice_area_list, qlist, last_stable_ice_edge
    else:
        return ice_area_list, qlist, previous_stable_ice_edge
Пример #2
0
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)
Пример #3
0
def test_radiative_forcing():
    '''Run a single-column radiative-convective model with CAM3 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.)
    #  Parent model process
    rcm = climlab.TimeDependentProcess(state=state)
    #  Fixed relative humidity
    h2o = climlab.radiation.ManabeWaterVapor(state=state)
    #  Couple water vapor to radiation
    rad = climlab.radiation.RRTMG(state=state, h2ovmr=h2o.q)
    #  Convective adjustment
    conv = climlab.convection.ConvectiveAdjustment(state=state,
                                                   adj_lapse_rate=6.5)
    #  Couple everything together
    rcm.add_subprocess('Radiation', rad)
    rcm.add_subprocess('WaterVapor', h2o)
    rcm.add_subprocess('Convection', conv)

    rcm.integrate_years(5.)
    #assert np.abs(rcm.ASR - rcm.OLR) < 0.1  # close to energy balance
    #  There is currently a problem with energy conservation in the RRTM module, need to look into this.
    rcm2 = climlab.process_like(rcm)
    rcm2.subprocess['Radiation'].co2vmr *= 2.
    rcm2.compute_diagnostics()
Пример #4
0
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)
Пример #5
0
def test_re_radiative_forcing():
    state = climlab.column_state(num_lev=num_lev)
    rad = climlab.radiation.CAM3(state=state)
    rad.integrate_years(2)
    assert np.abs(rad.ASR - rad.OLR) < 0.1  # close to energy balance
    rad2 = climlab.process_like(rad)
    rad2.absorber_vmr['CO2'] *= 2.
    rad2.compute_diagnostics()
    assert (rad2.ASR - rad2.OLR) > 1.  # positive radiative forcing
Пример #6
0
def diffmodel(rcmodel):
    diffmodel = climlab.process_like(rcmodel)
    # meridional diffusivity in m**2/s
    K = 0.05 / diffmodel.Tatm.domain.heat_capacity[0] *  climlab.constants.a**2
    d = climlab.dynamics.MeridionalDiffusion(K=K,
                state={'Tatm': diffmodel.state['Tatm']},
                **diffmodel.param)
    diffmodel.add_subprocess('diffusion', d)
    return diffmodel
Пример #7
0
def test_re_radiative_forcing():
    state = climlab.column_state(num_lev=num_lev)
    rad = climlab.radiation.CAM3(state=state)
    rad.integrate_years(2)
    assert np.abs(rad.ASR - rad.OLR) < 0.1  # close to energy balance
    rad2 = climlab.process_like(rad)
    rad2.absorber_vmr['CO2'] *= 2.
    rad2.compute_diagnostics()
    assert (rad2.ASR - rad2.OLR) > 1.  # positive radiative forcing
Пример #8
0
def test_rce_radiative_forcing(rcm):
    '''Run a single-column radiative-convective model with CAM3 radiation
    out to equilibrium. Clone the model, double CO2 and measure the instantaneous
    change in TOA flux. It should be positive net downward flux.'''
    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
Пример #9
0
def diffmodel(rcmodel):
    diffmodel = climlab.process_like(rcmodel)
    # thermal diffusivity in W/m**2/degC
    D = 0.05
    # meridional diffusivity in 1/s
    K = D / diffmodel.Tatm.domain.heat_capacity[0]
    d = climlab.dynamics.diffusion.MeridionalDiffusion(K=K,
                state={'Tatm': diffmodel.state['Tatm']}, **diffmodel.param)
    diffmodel.add_subprocess('diffusion', d)
    return diffmodel
Пример #10
0
def test_rce_radiative_forcing(rcm):
    '''Run a single-column radiative-convective model with CAM3 radiation
    out to equilibrium. Clone the model, double CO2 and measure the instantaneous
    change in TOA flux. It should be positive net downward flux.'''
    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
Пример #11
0
def diffmodel(rcmodel):
    diffmodel = climlab.process_like(rcmodel)
    # thermal diffusivity in W/m**2/degC
    D = 0.05
    # meridional diffusivity in 1/s
    K = D / diffmodel.Tatm.domain.heat_capacity[0]
    d = climlab.dynamics.MeridionalDiffusion(
        K=K, state={'Tatm': diffmodel.state['Tatm']}, **diffmodel.param)
    diffmodel.add_subprocess('diffusion', d)
    return diffmodel
Пример #12
0
def test_external_tendency():
    """Check that we can add an externally defined tendency to a
    radiative-convective model."""
    model = climlab.GreyRadiationModel(num_lev=30)
    model2 = climlab.process_like(model)
    model.step_forward()
    ext = climlab.process.ExternalForcing(state=model2.state)
    temp_tend = 1E-5  # K/s
    ext.forcing_tendencies['Tatm'][:] = temp_tend
    model2.add_subprocess('External', ext)
    model2.step_forward()
    assert model.tendencies['Tatm'] + temp_tend == pytest.approx(model2.tendencies['Tatm'])
Пример #13
0
def diffmodel_surfflux(diffmodel):
    diffmodel_surfflux = climlab.process_like(diffmodel)
    # process models for surface heat fluxes
    shf = SensibleHeatFlux(state=diffmodel_surfflux.state, Cd=0.5E-3)
    lhf = LatentHeatFlux(state=diffmodel_surfflux, Cd=0.5E-3)
    # set the water vapor input field for LHF
    lhf.q = diffmodel_surfflux.q
    diffmodel_surfflux.add_subprocess('SHF', shf)
    diffmodel_surfflux.add_subprocess('LHF', lhf)
    #  Convective adjustment for atmosphere only
    diffmodel_surfflux.remove_subprocess('convective adjustment')
    conv = ConvectiveAdjustment(state={'Tatm':diffmodel_surfflux.state['Tatm']},
                                **diffmodel_surfflux.param)
    diffmodel_surfflux.add_subprocess('convective adjustment', conv)
    return diffmodel_surfflux
Пример #14
0
def diffmodel_surfflux(diffmodel):
    '''Explicit surface sensible and latent heat fluxes.'''
    diffmodel_surfflux = climlab.process_like(diffmodel)
    # process models for surface heat fluxes
    shf = climlab.surface.SensibleHeatFlux(state=diffmodel_surfflux.state, Cd=0.5E-3)
    lhf = climlab.surface.LatentHeatFlux(state=diffmodel_surfflux.state, Cd=0.5E-3)
    # set the water vapor input field for LHF
    lhf.q = diffmodel_surfflux.q
    diffmodel_surfflux.add_subprocess('SHF', shf)
    diffmodel_surfflux.add_subprocess('LHF', lhf)
    #  Convective adjustment for atmosphere only
    diffmodel_surfflux.remove_subprocess('convective adjustment')
    conv = climlab.convection.ConvectiveAdjustment(state={'Tatm':diffmodel_surfflux.state['Tatm']},
                                **diffmodel_surfflux.param)
    diffmodel_surfflux.add_subprocess('convective adjustment', conv)
    return diffmodel_surfflux
Пример #15
0
col = climlab.GreyRadiationModel()
lev = col.lev
Tinterp = np.flipud(
    np.interp(np.flipud(lev), np.flipud(level), np.flipud(Tglobal)))

col.Ts[:] = Tglobal[0]
col.Tatm[:] = Tinterp

epsarray = np.linspace(0.01, 0.1, 100)
OLRarray = np.zeros_like(epsarray)

# col está em equilibro térmico
eps = brentq(OLRanom, 0.01, 0.1)
col.subprocess['LW'].absorptivity = eps

col2 = climlab.process_like(col)


def log(a):
    return math.log(a)


absorptivityChangeRate = 1.0005
years = 90
# Aumentando a taxa de absorção de radiação com amplo comprimento de onda
for i in range(years):
    col2.subprocess['LW'].absorptivity *= absorptivityChangeRate
    col2.integrate_years(1.)
    col2.compute_diagnostics()
    absorptivityChangeRate += -(1 /
                                (log(1 / (absorptivityChangeRate - 1)) *