axis

digraph inheritanced0dc3b8a38 { bgcolor=transparent; rankdir=LR; ratio=expand; size=""; "Axis" [URL="#climlab.domain.axis.Axis",dirType=back,fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=14,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Creates a new climlab Axis object."]; }
class climlab.domain.axis.Axis(axis_type='abstract', num_points=10, points=None, bounds=None)[source]

Bases: object

Creates a new climlab Axis object.

An Axis is an object where information of a spacial dimension of a _Domain are specified.

These include the type of the axis, the number of points, location of points and bounds on the spatial dimension, magnitude of bounds differences delta as well as their unit.

The axes of a _Domain are stored in the dictionary axes, so they can be accessed through dom.axes if dom is an instance of _Domain.

Initialization parameters

An instance of Axis is initialized with the following arguments (for detailed information see Object attributes below):

Parameters:
  • axis_type (str) – information about the type of axis [default: ‘abstract’]

  • num_points (int) – number of points on axis [default: 10]

  • points (array) – array with specific points (optional)

  • bounds (array) – array with specific bounds between points (optional)

Raises:

ValueError if axis_type is not one of the valid types or their euqivalents (see below).

Raises:

ValueError if points are given and not array-like.

Raises:

ValueError if bounds are given and not array-like.

Object attributes

Following object attributes are generated during initialization:

Variables:
  • axis_type (str) –

    Information about the type of axis. Valid axis types are:

    • 'lev'

    • 'lat'

    • 'lon'

    • 'depth'

    • 'abstract' (default)

  • num_points (int) – number of points on axis

  • units (str) – Unit of the axis. During intialization the unit is chosen from the defaultUnits dictionary (see below).

  • points (array) – array with all points of the axis (grid)

  • bounds (array) – array with all bounds between points (staggered grid)

  • delta (array) – array with spatial differences between bounds

Axis Types

A couple of differing axis type strings are rendered to valid axis types. Alternate forms are listed here:

  • 'lev'
    • 'p'

    • 'press'

    • 'pressure'

    • 'P'

    • 'Pressure'

    • 'Press'

  • 'lat'
    • 'Latitude'

    • 'latitude'

  • 'lon'
    • 'Longitude'

    • 'longitude'

  • 'depth'
    • 'Depth'

    • 'waterDepth'

    • 'water_depth'

    • 'slab'

The default units are:

defaultUnits = {'lev': 'mb',
                'lat': 'degrees',
                'lon': 'degrees',
                'depth': 'meters',
                'abstract': 'none'}

If bounds are not given during initialization, default end points are used:

defaultEndPoints = {'lev': (0., climlab.constants.ps),
                    'lat': (-90., 90.),
                    'lon': (0., 360.),
                    'depth': (0., 10.),
                    'abstract': (0, num_points)}
Example:

Creation of a standalone Axis:

>>> import climlab
>>> ax = climlab.domain.Axis(axis_type='Latitude', num_points=36)

>>> print ax
Axis of type lat with 36 points.

>>> ax.points
array([-87.5, -82.5, -77.5, -72.5, -67.5, -62.5, -57.5, -52.5, -47.5,
       -42.5, -37.5, -32.5, -27.5, -22.5, -17.5, -12.5,  -7.5,  -2.5,
         2.5,   7.5,  12.5,  17.5,  22.5,  27.5,  32.5,  37.5,  42.5,
        47.5,  52.5,  57.5,  62.5,  67.5,  72.5,  77.5,  82.5,  87.5])

>>> ax.bounds
array([-90., -85., -80., -75., -70., -65., -60., -55., -50., -45., -40.,
       -35., -30., -25., -20., -15., -10.,  -5.,   0.,   5.,  10.,  15.,
        20.,  25.,  30.,  35.,  40.,  45.,  50.,  55.,  60.,  65.,  70.,
        75.,  80.,  85.,  90.])

>>> ax.delta
array([ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.])