Esempio n. 1
0
 def __init__(
         self,
         num_lat=90,
         num_lon=None,
         S0=const.S0,
         s2=-0.48,
         A=210.,
         B=2.,
         D=0.555,  # in W / m^2 / degC, same as B
         water_depth=10.0,
         Tf=-10.,
         a0=0.3,
         a2=0.078,
         ai=0.62,
         timestep=const.seconds_per_year / 90.,
         T0=12.,  # initial temperature parameters
         T2=-40.,  #  (2nd Legendre polynomial)
         **kwargs):
     # Check to see if an initial state is already provided
     #  If not, make one
     if 'state' not in kwargs:
         state = surface_state(num_lat=num_lat,
                               num_lon=num_lon,
                               water_depth=water_depth,
                               T0=T0,
                               T2=T2)
         sfc = state.Ts.domain
         kwargs.update({'state': state, 'domains': {'sfc': sfc}})
     super(EBM, self).__init__(timestep=timestep, **kwargs)
     sfc = self.Ts.domain
     self.param['S0'] = S0
     self.param['s2'] = s2
     self.param['A'] = A
     self.param['B'] = B
     self.param['D'] = D
     self.param['Tf'] = Tf
     self.param['water_depth'] = water_depth
     self.param['a0'] = a0
     self.param['a2'] = a2
     self.param['ai'] = ai
     # create sub-models
     lw = AplusBT(state=self.state, **self.param)
     ins = P2Insolation(domains=sfc, **self.param)
     alb = albedo.StepFunctionAlbedo(state=self.state, **self.param)
     sw = SimpleAbsorbedShortwave(state=self.state,
                                  insolation=ins.insolation,
                                  albedo=alb.albedo,
                                  **self.param)
     diff = MeridionalHeatDiffusion(state=self.state,
                                    use_banded_solver=False,
                                    **self.param)
     self.add_subprocess('LW', lw)
     self.add_subprocess('insolation', ins)
     self.add_subprocess('albedo', alb)
     self.add_subprocess('SW', sw)
     self.add_subprocess('diffusion', diff)
     self.topdown = False  # call subprocess compute methods first
     self.add_diagnostic('net_radiation', 0. * self.Ts)
Esempio n. 2
0
 def __init__(
         self,
         num_lat=90,
         S0=const.S0,
         A=210.,
         B=2.,
         D=0.555,  # in W / m^2 / degC, same as B
         water_depth=10.0,
         Tf=-10.,
         a0=0.3,
         a2=0.078,
         ai=0.62,
         timestep=const.seconds_per_year / 90.,
         T0=12.,  # initial temperature parameters
         T2=-40.,  #  (2nd Legendre polynomial)
         **kwargs):
     # Check to see if an initial state is already provided
     #  If not, make one
     if 'state' not in kwargs:
         state = surface_state(num_lat=num_lat,
                               water_depth=water_depth,
                               T0=T0,
                               T2=T2)
         sfc = state.Ts.domain
         kwargs.update({'state': state, 'domains': {'sfc': sfc}})
     super(EBM, self).__init__(timestep=timestep, **kwargs)
     sfc = self.Ts.domain
     self.param['S0'] = S0
     self.param['A'] = A
     self.param['B'] = B
     self.param['D'] = D
     self.param['Tf'] = Tf
     self.param['water_depth'] = water_depth
     self.param['a0'] = a0
     self.param['a2'] = a2
     self.param['ai'] = ai
     # create sub-models
     self.add_subprocess('LW', AplusBT(state=self.state, **self.param))
     self.add_subprocess('insolation',
                         P2Insolation(domains=sfc, **self.param))
     self.add_subprocess(
         'albedo', albedo.StepFunctionAlbedo(state=self.state,
                                             **self.param))
     # diffusivity in units of 1/s
     K = self.param['D'] / self.domains['Ts'].heat_capacity
     self.add_subprocess(
         'diffusion',
         MeridionalDiffusion(state=self.state,
                             K=K,
                             use_banded_solver=True,
                             **self.param))
     self.topdown = False  # call subprocess compute methods first
     self.add_diagnostic('ASR', 0. * self.Ts)
     self.add_diagnostic('net_radiation', 0. * self.Ts)
     self.add_diagnostic('albedo', 0. * self.Ts)
     self.add_diagnostic('icelat', None)
     self.add_diagnostic('ice_area', None)
Esempio n. 3
0
 def __init__(
         self,
         num_lat=90,
         S0=const.S0,
         A=210.,
         B=2.,
         D=0.555,  # in W / m^2 / degC, same as B
         water_depth=10.0,
         Tf=-10.,
         a0=0.3,
         a2=0.078,
         ai=0.62,
         timestep=const.seconds_per_year / 90.,
         T_init_0=12.,
         T_init_P2=-40.,
         **kwargs):
     super(EBM, self).__init__(timestep=timestep, **kwargs)
     if not self.domains and not self.state:  # no state vars or domains yet
         sfc = domain.zonal_mean_surface(num_lat=num_lat,
                                         water_depth=water_depth)
         lat = sfc.axes['lat'].points
         initial = T_init_0 + T_init_P2 * legendre.P2(
             np.sin(np.deg2rad(lat)))
         self.set_state('Ts', Field(initial, domain=sfc))
     self.param['S0'] = S0
     self.param['A'] = A
     self.param['B'] = B
     self.param['D'] = D
     self.param['Tf'] = Tf
     self.param['water_depth'] = water_depth
     self.param['a0'] = a0
     self.param['a2'] = a2
     self.param['ai'] = ai
     # create sub-models
     self.add_subprocess('LW', AplusBT(state=self.state, **self.param))
     self.add_subprocess('insolation',
                         P2Insolation(domains=sfc, **self.param))
     self.add_subprocess(
         'albedo', albedo.StepFunctionAlbedo(state=self.state,
                                             **self.param))
     # diffusivity in units of 1/s
     K = self.param['D'] / self.domains['Ts'].heat_capacity
     self.add_subprocess(
         'diffusion',
         MeridionalDiffusion(state=self.state, K=K, **self.param))
     self.topdown = False  # call subprocess compute methods first
Esempio n. 4
0
 def __init__(self, a0=0.33, a2=0.25, ai=None, **kwargs):
     '''This EBM uses realistic daily insolation.
     If ai is not given, the model will not have an albedo feedback.'''
     super(EBM_seasonal, self).__init__(a0=a0, a2=a2, ai=ai, **kwargs)
     sfc = self.domains['Ts']
     self.add_subprocess('insolation',
                         DailyInsolation(domains=sfc, **self.param))
     self.param['a0'] = a0
     self.param['a2'] = a2
     if ai is None:
         # No albedo feedback
         # Remove unused parameters here for clarity
         _ = self.param.pop('ai')
         _ = self.param.pop('Tf')
         self.add_subprocess('albedo',
                             albedo.P2Albedo(domains=sfc, **self.param))
     else:
         self.param['ai'] = ai
         self.add_subprocess(
             'albedo',
             albedo.StepFunctionAlbedo(state=self.state, **self.param))
Esempio n. 5
0
    def __init__(self, a0=0.33, a2=0.25, ai=None, **kwargs):
        """A class that implements Energy Balance Models with realistic
        daily insolation.

        This class is inherited from the general :class:`~climlab.EBM`
        class and uses the insolation subprocess
        :class:`~climlab.radiation.DailyInsolation` instead of
        :class:`~climlab.radiation.P2Insolation` to compute a
        realisitc distribution of solar radiation on a daily basis.

        If argument for ice albedo ``'ai'`` is not given, the model will not
        have an albedo feedback.

        An instance of ``EBM_seasonal`` is initialized with the following
        arguments:

        :param float a0:            base value for planetary albedo parametrization
                                    :class:`~climlab.surface.albedo.StepFunctionAlbedo`
                                    [default: 0.33]
        :param float a2:            parabolic value for planetary  albedo parametrization
                                    :class:`~climlab.surface.albedo.StepFunctionAlbedo`
                                    [default: 0.25]
        :param float ai:            value for ice albedo paramerization in
                                    :class:`~climlab.surface.albedo.StepFunctionAlbedo`
                                    (optional)


        **Object attributes** \n

        Following object attributes are updated during initialization: \n

        :ivar dict param:       The parameter dictionary is updated with
                                ``'a0'`` and ``'a2'``.
        :ivar dict subprocess:  suprocess ``'insolation'`` is overwritten by
                                :class:`~climlab.radiation.insolation.DailyInsolation`.

        *if* ``'ai'`` *is not given*:

        :ivar dict param:       ``'ai'`` and ``'Tf'`` are removed from the
                                parameter dictionary (initialized by parent class
                                :class:`~climlab.model.ebm.EBM`)
        :ivar dict subprocess:  suprocess ``'albedo'`` is overwritten by
                                :class:`~climlab.surface.albedo.P2Albedo`.

        *if* ``'ai'`` *is given*:

        :ivar dict param:       The parameter dictionary is updated with
                                ``'ai'``.
        :ivar dict subprocess:  suprocess ``'albedo'`` is overwritten by
                                :class:`~climlab.surface.albedo.StepFunctionAlbedo`
                                (which basically has been there before but now is
                                updated with the new albedo parameter values).
        :Example:

            The annual distribution of solar insolation:

            .. plot:: code_input_manual/example_EBM_seasonal.py
                :include-source:

        """
        if ai is None:
            no_albedo_feedback = True
            ai = 0. # ignored but need to set a number
        else:
            no_albedo_feedback = False
        super(EBM_seasonal, self).__init__(a0=a0, a2=a2, ai=ai, **kwargs)
        self.param['a0'] = a0
        self.param['a2'] = a2
        sfc = self.domains['Ts']
        ins = DailyInsolation(domains=sfc, **self.param)
        if no_albedo_feedback:
            # Remove unused parameters here for clarity
            _ = self.param.pop('ai')
            _ = self.param.pop('Tf')
            alb = albedo.P2Albedo(domains=sfc, **self.param)
        else:
            self.param['ai'] = ai
            alb = albedo.StepFunctionAlbedo(state=self.state, **self.param)
        sw = SimpleAbsorbedShortwave(state=self.state,
                                     insolation=ins.insolation,
                                     albedo=alb.albedo,
                                     **self.param)
        self.add_subprocess('insolation', ins)
        self.add_subprocess('albedo', alb)
        self.add_subprocess('SW', sw)