Example #1
0
def column_state(num_lev=30, num_lat=1, lev=None, lat=None, water_depth=1.0):
    '''Set up a state variable dictionary consisting of temperatures
    for atmospheric column (`Tatm`) and surface mixed layer (`Ts`).
    '''
    if lat is not None:
        num_lat = np.array(lat).size
    if lev is not None:
        num_lev = np.array(lev).size

    if num_lat is 1:
        sfc, atm = domain.single_column(water_depth=water_depth,
                                        num_lev=num_lev,
                                        lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth,
                                            num_lev=num_lev,
                                            lev=lev,
                                            num_lat=num_lat,
                                            lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288. * np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(200., 288. - 10., num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = AttrDict()
    state['Ts'] = Ts
    state['Tatm'] = Tatm
    return state
Example #2
0
def initial_state(num_lev, num_lat, lev, lat, water_depth):
    if num_lat is 1:
        sfc, atm = domain.single_column(water_depth=water_depth, num_lev=num_lev, lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth, num_lev=num_lev, lev=lev, num_lat=num_lat, lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288.0 * np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(288.0 - 10.0, 200.0, num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = {"Ts": Ts, "Tatm": Tatm}
    return state
Example #3
0
def initial_state(num_lev, num_lat, lev, lat, water_depth):
    if num_lat is 1:
        sfc, atm = domain.single_column(water_depth=water_depth,
                                        num_lev=num_lev,
                                        lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth,
                                            num_lev=num_lev,
                                            lev=lev,
                                            num_lat=num_lat,
                                            lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288. * np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(288. - 10., 200., num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = {'Ts': Ts, 'Tatm': Tatm}
    return state
Example #4
0
def make_column(lev=None, ps=1013, tmp=None, ts=None):
    state = climlab.column_state(lev=lev)
    num_lev = np.array(lev).size
    lev = state.Tatm.domain.lev

    lev_values = lev.points
    lev_dfs = np.zeros(num_lev)
    lev_dfs[1:] = np.diff(lev_values)
    lev_dfs[0] = lev_values[0]
    lev_dfs = lev_dfs / 2.

    lev.bounds = np.full(num_lev + 1, ps)
    lev.bounds[:-1] = lev_values - lev_dfs
    lev.delta = np.abs(np.diff(lev.bounds))
    sfc, atm = domain.single_column(lev=lev)
    state['Ts'] = Field(ts, domain=sfc)
    state['Tatm'] = Field(tmp, domain=atm)

    return state
Example #5
0
def column_state(num_lev=30, num_lat=1, lev=None, lat=None, water_depth=1.0):
    """Set up a state variable dictionary consisting of temperatures
    for atmospheric column (`Tatm`) and surface mixed layer (`Ts`).
    """
    if lat is not None:
        num_lat = np.array(lat).size
    if lev is not None:
        num_lev = np.array(lev).size

    if num_lat is 1:
        sfc, atm = domain.single_column(water_depth=water_depth, num_lev=num_lev, lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth, num_lev=num_lev, lev=lev, num_lat=num_lat, lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288.0 * np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(200.0, 288.0 - 10.0, num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = AttrDict()
    state["Ts"] = Ts
    state["Tatm"] = Tatm
    return state
Example #6
0
def column_state(num_lev=30,
                 num_lat=1,
                 lev=None,
                 lat=None,
                 water_depth=1.0):
    """Sets up a state variable dictionary consisting of temperatures
    for atmospheric column (``Tatm``) and surface mixed layer (``Ts``).

    Surface temperature is always 288 K. Atmospheric temperature is initialized
    between 278 K at lowest altitude and 200 at top of atmosphere according to
    the number of levels given.

    **Function-call arguments** \n

    :param int num_lev:         number of pressure levels
                                (evenly spaced from surface to top of atmosphere)
                                [default: 30]
    :param int num_lat:         number of latitude points on the axis
                                [default: 1]
    :param lev:                 specification for height axis (optional)
    :type lev:                  :class:`~climlab.domain.axis.Axis`
                                or pressure array
    :param array lat:           size of array determines dimension of latitude
                                (optional)
    :param float water_depth:   *irrelevant*

    :returns:                   dictionary with two temperature
                                :class:`~climlab.domain.field.Field`
                                for atmospheric column ``Tatm`` and
                                surface mixed layer ``Ts``
    :rtype:                     dict

    :Example:

        ::

            >>> from climlab.domain import initial
            >>> T_dict = initial.column_state()

            >>> print T_dict
            {'Tatm': Field([ 200.        ,  202.68965517,  205.37931034,  208.06896552,
                    210.75862069,  213.44827586,  216.13793103,  218.82758621,
                    221.51724138,  224.20689655,  226.89655172,  229.5862069 ,
                    232.27586207,  234.96551724,  237.65517241,  240.34482759,
                    243.03448276,  245.72413793,  248.4137931 ,  251.10344828,
                    253.79310345,  256.48275862,  259.17241379,  261.86206897,
                    264.55172414,  267.24137931,  269.93103448,  272.62068966,
                    275.31034483,  278.        ]), 'Ts': Field([ 288.])}

    """
    if lat is not None:
        num_lat = np.array(lat).size
    if lev is not None:
        num_lev = np.array(lev).size

    if num_lat == 1:
        sfc, atm = domain.single_column(water_depth=water_depth,
                                        num_lev=num_lev,
                                        lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth,
                                            num_lev=num_lev,
                                            lev=lev,
                                            num_lat=num_lat,
                                            lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288.*np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(200., 288.-10., num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = AttrDict()
    state['Ts'] = Ts
    state['Tatm'] = Tatm
    return state
Example #7
0
def column_state(num_lev=30,
                 num_lat=1,
                 lev=None,
                 lat=None,
                 water_depth=1.0):
    """Sets up a state variable dictionary consisting of temperatures
    for atmospheric column (``Tatm``) and surface mixed layer (``Ts``).

    Surface temperature is always 288 K. Atmospheric temperature is initialized
    between 278 K at lowest altitude and 200 at top of atmosphere according to
    the number of levels given.

    **Function-call arguments** \n

    :param int num_lev:         number of pressure levels
                                (evenly spaced from surface to top of atmosphere)
                                [default: 30]
    :param int num_lat:         number of latitude points on the axis
                                [default: 1]
    :param lev:                 specification for height axis (optional)
    :type lev:                  :class:`~climlab.domain.axis.Axis`
                                or pressure array
    :param array lat:           size of array determines dimension of latitude
                                (optional)
    :param float water_depth:   *irrelevant*

    :returns:                   dictionary with two temperature
                                :class:`~climlab.domain.field.Field`
                                for atmospheric column ``Tatm`` and
                                surface mixed layer ``Ts``
    :rtype:                     dict

    :Example:

        ::

            >>> from climlab.domain import initial
            >>> T_dict = initial.column_state()

            >>> print T_dict
            {'Tatm': Field([ 200.        ,  202.68965517,  205.37931034,  208.06896552,
                    210.75862069,  213.44827586,  216.13793103,  218.82758621,
                    221.51724138,  224.20689655,  226.89655172,  229.5862069 ,
                    232.27586207,  234.96551724,  237.65517241,  240.34482759,
                    243.03448276,  245.72413793,  248.4137931 ,  251.10344828,
                    253.79310345,  256.48275862,  259.17241379,  261.86206897,
                    264.55172414,  267.24137931,  269.93103448,  272.62068966,
                    275.31034483,  278.        ]), 'Ts': Field([ 288.])}

    """
    if lat is not None:
        num_lat = np.array(lat).size
    if lev is not None:
        num_lev = np.array(lev).size

    if num_lat is 1:
        sfc, atm = domain.single_column(water_depth=water_depth,
                                        num_lev=num_lev,
                                        lev=lev)
    else:
        sfc, atm = domain.zonal_mean_column(water_depth=water_depth,
                                            num_lev=num_lev,
                                            lev=lev,
                                            num_lat=num_lat,
                                            lat=lat)
    num_lev = atm.lev.num_points
    Ts = Field(288.*np.ones(sfc.shape), domain=sfc)
    Tinitial = np.tile(np.linspace(200., 288.-10., num_lev), sfc.shape)
    Tatm = Field(Tinitial, domain=atm)
    state = AttrDict()
    state['Ts'] = Ts
    state['Tatm'] = Tatm
    return state