modelutil Example: Atmospheric Constants

The AtmConst class provides a comprehensive (someday) and consistent definition of important atmospheric constants. Constants are defined both as class attributes and also as instance attributes whose initial values are set by the class attribute version. This "double-definition" enables one to make local changes to local instances of the AtmConst class without having the changes propagate to all subsequent references. At the same time, you can change the value in all subsequent references, if you wish, by altering and using the class attribute definition.

The AtmConst class is found in the atmconst module in the package. Here is an example of accessing the gas constant for dry air, both as a class attribute and an instance attribute:

>>> from modelutil.atmconst import AtmConst
>>> AtmConst.R_d
287.05000000000001
>>> const = AtmConst()
>>> const.R_d
287.05000000000001

The pydoc documentation for the AtmConst class provides details as to what constants are defined and their units, and also gives more information about the difference in using the class and instance attributes.

Return to modelutil Reference Manual Index.
Return to modelutil Home Page.

Valid HTML 4.01! Valid CSS! Updated: January 5, 2005 by Johnny Lin <email address>. License.