domain

- class climlab.domain.domain.Atmosphere(**kwargs)[source]
Bases:
_DomainClass for the implementation of an Atmosphere Domain.
Object attributes
Additional to the parent class
_Domainthe 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
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 axisself.axes['lev'].deltaas 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:
_DomainClass for the implementation of an Ocean Domain.
Object attributes
Additional to the parent class
_Domainthe 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
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 axisself.axes['depth'].deltaas 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:
AtmosphereA class to create a SlabAtmosphere Domain by default.
Initializes the parent
Atmosphereclass with a simple axis for a Slab Atmopshere created bymake_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:
OceanA class to create a SlabOcean Domain by default.
Initializes the parent
Oceanclass with a simple axis for a Slab Ocean created bymake_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:
objectPrivate parent class for Domains.
A Domain defines an area or spatial base for a climlab
Processobject. It consists of axes which areAxisobjects 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
AtmosphereandOceanof the private_Domainclass implemented which themselves have daughter classesSlabAtmosphereandSlabOcean.Several methods are implemented that create Domains with special specifications. These are
Initialization parameters
An instance of
_Domainis 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 argumentaxesnumdims (int) – Number of
Axisobjects inself.axesdictionary.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
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
Axisobject orNone) – axes input- Raises:
ValueErrorif input is not an instance of Axis class or a dictionary of Axis objetcs- Returns:
dictionary of input axes
- Return type:
- 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'andself.domain_type = 'box'- Return type:
- 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'andnum_points=num_points- Return type:
- 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'andnum_points=num_points- Return type:
- 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
levis notNonethen function tries to build a level axis andnum_levis ignored.Function-call argument
- Parameters:
- Raises:
ValueErrorif lev is given but neither Axis nor pressure array.- Returns:
a list of 2 Domain objects (slab ocean, atmosphere)
- Return type:
- 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 (
Axisor latitude array) – specification for latitude axis (optional)lon (
Axisor longitude array) – specification for longitude axis (optional)
- Raises:
ValueErrorif lat is given but neither Axis nor latitude array.- Raises:
ValueErrorif lon is given but neither Axis nor longitude array.- Returns:
surface domain
- Return type:
- 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 (
Axisor latitude array) – specification for latitude axis (optional)lev (
Axisor pressure array) – specification for height axis (optional)
- Raises:
ValueErrorif lat is given but neither Axis nor latitude array.- Raises:
ValueErrorif lev is given but neither Axis nor pressure array.- Returns:
a list of 2 Domain objects (slab ocean, atmosphere)
- Return type:
listofSlabOcean,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:
- Raises:
ValueErrorif lat is given but neither Axis nor latitude array.- Returns:
surface domain
- Return type:
- 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)