Let us start with a simple climt model which is not very useful, but helps illustrate how to use climt:
In : import climt # Create some components In : radiation = climt.GrayLongwaveRadiation() In : surface = climt.SlabSurface() # Get a state dictionary filled with required quantities # for the components to run In : state = climt.get_default_state([radiation, surface]) # Run components In : tendencies, diagnostics = radiation(state) # See output In : tendencies.keys() Out: dict_keys(['air_temperature']) In : tendencies['air_temperature'] Out: <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
- Create one or many components
- Create a state dictionary using
- Run the components
- Do something with the output
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.
diagnostics are dictionaries which contain quantities
which act either as inputs to components or outputs from components.
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.
The square brackets are required in the call to
if it is one component:
climt.get_default_state([radiation]) is the
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!