domain

Inheritance diagram of climlab.domain.domain
class climlab.domain.domain.Atmosphere(**kwargs)[source]

Bases: climlab.domain.domain._Domain

Class for the implementation of an Atmosphere Domain.

Object attributes

Additional to the parent class _Domain the following object attribute is modified during initialization:

Variables

domain_type (str) – is set to 'atm'

Example

Setting up an Atmosphere Domain:

>>> import climlab
>>> atm_ax = climlab.domain.Axis(axis_type='pressure', num_points=10)
>>> atm_domain = climlab.domain.Atmosphere(axes=atm_ax)

>>> print atm_domain
climlab Domain object with domain_type=atm and shape=(10,)

>>> atm_domain.axes
{'lev': <climlab.domain.axis.Axis object at 0x7fe5b8ef8e10>}

>>> atm_domain.heat_capacity
array([ 1024489.79591837,  1024489.79591837,  1024489.79591837,
        1024489.79591837,  1024489.79591837,  1024489.79591837,
        1024489.79591837,  1024489.79591837,  1024489.79591837,
        1024489.79591837])

Methods

set_heat_capacity()

Sets the heat capacity of the Atmosphere Domain.

set_heat_capacity()[source]

Sets the heat capacity of the Atmosphere Domain.

Calls the utils heat capacity function atmosphere() and gives the delta array of grid points of it’s level axis self.axes['lev'].delta as input.

Object attributes

During method execution following object attribute is modified:

Variables

heat_capacity (array) – the ocean domain’s heat capacity over the 'lev' Axis.

class climlab.domain.domain.Ocean(**kwargs)[source]

Bases: climlab.domain.domain._Domain

Class for the implementation of an Ocean Domain.

Object attributes

Additional to the parent class _Domain the following object attribute is modified during initialization:

Variables

domain_type (str) – is set to 'ocean'

Example

Setting up an Ocean Domain:

>>> import climlab
>>> ocean_ax = climlab.domain.Axis(axis_type='depth', num_points=5)
>>> ocean_domain = climlab.domain.Ocean(axes=ocean_ax)

>>> print ocean_domain
climlab Domain object with domain_type=ocean and shape=(5,)

>>> ocean_domain.axes
{'depth': <climlab.domain.axis.Axis object at 0x7fe5b8f102d0>}

>>> ocean_domain.heat_capacity
array([ 8362600.,  8362600.,  8362600.,  8362600.,  8362600.])

Methods

set_heat_capacity()

Sets the heat capacity of the Ocean Domain.

set_heat_capacity()[source]

Sets the heat capacity of the Ocean Domain.

Calls the utils heat capacity function ocean() and gives the delta array of grid points of it’s depth axis self.axes['depth'].delta as input.

Object attributes

During method execution following object attribute is modified:

Variables

heat_capacity (array) – the ocean domain’s heat capacity over the 'depth' Axis.

class climlab.domain.domain.SlabAtmosphere(axes=<climlab.domain.axis.Axis object>, **kwargs)[source]

Bases: climlab.domain.domain.Atmosphere

A class to create a SlabAtmosphere Domain by default.

Initializes the parent Atmosphere class with a simple axis for a Slab Atmopshere created by make_slabatm_axis() which has just 1 cell in height by default.

Example

Creating a SlabAtmosphere Domain:

>>> import climlab
>>> slab_atm_domain = climlab.domain.SlabAtmosphere()

>>> print slab_atm_domain
climlab Domain object with domain_type=atm and shape=(1,)

>>> slab_atm_domain.axes
{'lev': <climlab.domain.axis.Axis object at 0x7fe5c4281610>}

>>> slab_atm_domain.heat_capacity
array([ 10244897.95918367])

Methods

set_heat_capacity()

Sets the heat capacity of the Atmosphere Domain.

class climlab.domain.domain.SlabOcean(axes=<climlab.domain.axis.Axis object>, **kwargs)[source]

Bases: climlab.domain.domain.Ocean

A class to create a SlabOcean Domain by default.

Initializes the parent Ocean class with a simple axis for a Slab Ocean created by make_slabocean_axis() which has just 1 cell in depth by default.

Example

Creating a SlabOcean Domain:

>>> import climlab
>>> slab_ocean_domain = climlab.domain.SlabOcean()

>>> print slab_ocean_domain
climlab Domain object with domain_type=ocean and shape=(1,)

>>> slab_ocean_domain.axes
{'depth': <climlab.domain.axis.Axis object at 0x7fe5c42814d0>}

>>> slab_ocean_domain.heat_capacity
array([ 41813000.])

Methods

set_heat_capacity()

Sets the heat capacity of the Ocean Domain.

class climlab.domain.domain._Domain(axes=None, **kwargs)[source]

Bases: object

Private parent class for Domains.

A Domain defines an area or spatial base for a climlab Process object. It consists of axes which are Axis objects that define the dimensions of the Domain.

In a Domain the heat capacity of grid points, bounds or cells/boxes is specified.

There are daughter classes Atmosphere and Ocean of the private _Domain class implemented which themselves have daughter classes SlabAtmosphere and SlabOcean.

Several methods are implemented that create Domains with special specifications. These are

Initialization parameters

An instance of _Domain is initialized with the following arguments:

Parameters

axes (dict or Axis) – Axis object or dictionary of Axis object where domain will be defined on.

Object attributes

Following object attributes are generated during initialization:

Variables
  • domain_type (str) – Set to 'undefined'.

  • axes (dict) – A dictionary of the domains axes. Created by _make_axes_dict() called with input argument axes

  • numdims (int) – Number of Axis objects in self.axes dictionary.

  • ax_index (dict) –

    A dictionary of domain axes and their corresponding index in an ordered list of the axes with:

    • 'lev' or 'depth' is last

    • 'lat' is second last

  • shape (tuple) – Number of points of all domain axes. Order in tuple given by self.ax_index.

  • heat_capacity (array) – the domain’s heat capacity over axis specified in function call of set_heat_capacity()

Methods

set_heat_capacity()

A dummy function to set the heat capacity of a domain.

_make_axes_dict(axes)[source]

Makes an axes dictionary.

Note

In case the input is None, the dictionary {'empty': None} is returned.

Function-call argument

Parameters

axes (dict or single instance of Axis object or None) – axes input

Raises

ValueError if input is not an instance of Axis class or a dictionary of Axis objetcs

Returns

dictionary of input axes

Return type

dict

set_heat_capacity()[source]

A dummy function to set the heat capacity of a domain.

Should be overridden by daugter classes.

climlab.domain.domain.box_model_domain(num_points=2, **kwargs)[source]

Creates a box model domain (a single abstract axis).

Parameters

num_points (int) – number of boxes [default: 2]

Returns

Domain with single axis of type 'abstract' and self.domain_type = 'box'

Return type

_Domain

Example
>>> from climlab import domain
>>> box = domain.box_model_domain(num_points=2)

>>> print box
climlab Domain object with domain_type=box and shape=(2,)
climlab.domain.domain.make_slabatm_axis(num_points=1)[source]

Convenience method to create a simple axis for a slab atmosphere.

Function-call argument

Parameters

num_points (int) – number of points for the slabatmosphere Axis [default: 1]

Returns

an Axis with axis_type='lev' and num_points=num_points

Return type

Axis

Example
>>> import climlab
>>> slab_atm_axis = climlab.domain.make_slabatm_axis()

>>> print slab_atm_axis
Axis of type lev with 1 points.

>>> slab_atm_axis.axis_type
'lev'

>>> slab_atm_axis.bounds
array([    0.,  1000.])

>>> slab_atm_axis.units
'mb'
climlab.domain.domain.make_slabocean_axis(num_points=1)[source]

Convenience method to create a simple axis for a slab ocean.

Function-call argument

Parameters

num_points (int) – number of points for the slabocean Axis [default: 1]

Returns

an Axis with axis_type='depth' and num_points=num_points

Return type

Axis

Example
>>> import climlab
>>> slab_ocean_axis = climlab.domain.make_slabocean_axis()

>>> print slab_ocean_axis
Axis of type depth with 1 points.

>>> slab_ocean_axis.axis_type
'depth'

>>> slab_ocean_axis.bounds
array([  0.,  10.])

>>> slab_ocean_axis.units
'meters'
climlab.domain.domain.single_column(num_lev=30, water_depth=1.0, lev=None, **kwargs)[source]

Creates domains for a single column of atmosphere overlying a slab of water.

Can also pass a pressure array or pressure level axis object specified in lev.

If argument lev is not None then function tries to build a level axis and num_lev is ignored.

Function-call argument

Parameters
  • num_lev (int) – number of pressure levels (evenly spaced from surface to TOA) [default: 30]

  • water_depth (float) – depth of the ocean slab [default: 1.]

  • lev (Axis or pressure array) – specification for height axis (optional)

Raises

ValueError if lev is given but neither Axis nor pressure array.

Returns

a list of 2 Domain objects (slab ocean, atmosphere)

Return type

list of SlabOcean, SlabAtmosphere

Example
>>> from climlab import domain

>>> sfc, atm = domain.single_column(num_lev=2, water_depth=10.)

>>> print sfc
climlab Domain object with domain_type=ocean and shape=(1,)

>>> print atm
climlab Domain object with domain_type=atm and shape=(2,)
climlab.domain.domain.surface_2D(num_lat=90, num_lon=180, water_depth=10.0, lon=None, lat=None, **kwargs)[source]

Creates a 2D slab ocean Domain in latitude and longitude with uniform water depth.

Domain has a single heat capacity according to the specified water depth.

Function-call argument

Parameters
  • num_lat (int) – number of latitude points [default: 90]

  • num_lon (int) – number of longitude points [default: 180]

  • water_depth (float) – depth of the slab ocean in meters [default: 10.]

  • lat (Axis or latitude array) – specification for latitude axis (optional)

  • lon (Axis or longitude array) – specification for longitude axis (optional)

Raises

ValueError if lat is given but neither Axis nor latitude array.

Raises

ValueError if lon is given but neither Axis nor longitude array.

Returns

surface domain

Return type

SlabOcean

Example
>>> from climlab import domain
>>> sfc = domain.surface_2D(num_lat=36, num_lat=72)

>>> print sfc
climlab Domain object with domain_type=ocean and shape=(36, 72, 1)
climlab.domain.domain.zonal_mean_column(num_lat=90, num_lev=30, water_depth=10.0, lat=None, lev=None, **kwargs)[source]

Creates two Domains with one water cell, a latitude axis and a level/height axis.

  • SlabOcean: one water cell and a latitude axis above (similar to zonal_mean_surface())

  • Atmosphere: a latitude axis and a level/height axis (two dimensional)

Function-call argument

Parameters
  • num_lat (int) – number of latitude points on the axis [default: 90]

  • num_lev (int) – number of pressure levels (evenly spaced from surface to TOA) [default: 30]

  • water_depth (float) – depth of the water cell (slab ocean) [default: 10.]

  • lat (Axis or latitude array) – specification for latitude axis (optional)

  • lev (Axis or pressure array) – specification for height axis (optional)

Raises

ValueError if lat is given but neither Axis nor latitude array.

Raises

ValueError if lev is given but neither Axis nor pressure array.

Returns

a list of 2 Domain objects (slab ocean, atmosphere)

Return type

list of SlabOcean, Atmosphere

Example
>>> from climlab import domain
>>> sfc, atm = domain.zonal_mean_column(num_lat=36,num_lev=10)

>>> print sfc
climlab Domain object with domain_type=ocean and shape=(36, 1)

>>> print atm
climlab Domain object with domain_type=atm and shape=(36, 10)
climlab.domain.domain.zonal_mean_surface(num_lat=90, water_depth=10.0, lat=None, **kwargs)[source]

Creates a 1D slab ocean Domain in latitude with uniform water depth.

Domain has a single heat capacity according to the specified water depth.

Function-call argument

Parameters
  • num_lat (int) – number of latitude points [default: 90]

  • water_depth (float) – depth of the slab ocean in meters [default: 10.]

  • lat (Axis or latitude array) – specification for latitude axis (optional)

Raises

ValueError if lat is given but neither Axis nor latitude array.

Returns

surface domain

Return type

SlabOcean

Example
>>> from climlab import domain
>>> sfc = domain.zonal_mean_surface(num_lat=36)

>>> print sfc
climlab Domain object with domain_type=ocean and shape=(36, 1)