Quickstart¶
Let us start with a simple climt model which is not very useful, but helps illustrate how to use climt:
In [1]: import climt
# Create some components
In [2]: radiation = climt.GrayLongwaveRadiation()
In [3]: surface = climt.SlabSurface()
# Get a state dictionary filled with required quantities
# for the components to run
In [4]: state = climt.get_default_state([radiation, surface])
# Run components
In [5]: tendencies, diagnostics = radiation(state)
# See output
In [6]: tendencies.keys()
Out[6]: dict_keys(['air_temperature'])
In [7]: tendencies['air_temperature']
Out[7]:
<xarray.DataArray (mid_levels: 28, lat: 1, lon: 1)>
array([[[-8.65953484e-06]],
[[-8.82597967e-06]],
[[-9.10930142e-06]],
[[-9.50816216e-06]],
[[-1.00211876e-05]],
[[-1.06462877e-05]],
[[-1.13814120e-05]],
[[-1.22239221e-05]],
[[-1.31708319e-05]],
[[-1.42185500e-05]],
...
[[-2.69670979e-05]],
[[-2.85017885e-05]],
[[-2.99815186e-05]],
[[-3.13776165e-05]],
[[-3.26612456e-05]],
[[-3.38033767e-05]],
[[-3.47767484e-05]],
[[-3.55573827e-05]],
[[-3.61242997e-05]],
[[-3.64632192e-05]]])
Dimensions without coordinates: mid_levels, lat, lon
Attributes:
units: degK s^-1
Here, all the essential aspects of creating and running a model in climt are present:
- Import the
climt
package - Create one or many components
- Create a state dictionary using
get_default_state
- Run the components
- Do something with the output
Variables radiation
and surface
are two components that we
create. All climt components take a lot of optional arguments: However, by
design, the default options (which are used if you don’t specify any arguments)
are meant to be scientifically meaningful.
The variables state
, tendencies
and
diagnostics
are dictionaries which contain quantities
which act either as inputs to components or outputs from components.
The function get_default_state()
, if called only with a list of components,
will provide a set of quantities which represent
a single column of the atmosphere. These default values may or may not be
meaningful in your context, so it is best to see what they are and change them
according to your needs.
Note
The square brackets are required in the call to get_default_state
, even
if it is one component: climt.get_default_state([radiation])
is the
correct syntax.
Building more sophisticated models and running them is merely an extended version of the above simple example. climt makes heavy use of Sympl, and knowledge of Sympl is necessary to use climt to its full capabilities. So, do go through Sympl’s docs!