| |
- press(variables, p0=1000.0, missing=1e+20)
- Calculate pressure.
The primary purpose of this function is to calculate pressure
given temperature and potential temperature (this is needed to
interpolate from isentropic surfaces to pressure levels).
Currently, this function only accomplishes that primary purpose.
There are, however, a number of different ways to calculate
pressure from a variety of state (primary and derived) variables,
and this function is written so those methods can be easily added
in the future.
The reference pressure for potential temperature is set to 1000
hPa by default. To use a different reference pressure, set p0 to
a different value when calling the method.
Method Arguments:
* variables: A dictionary of input state variables, where for
each key:value pair the key labels what state variable it is
and the value is the state variable. The value is a Numeric
floating point array of any number of dimensions and size.
All state variables must be arrays of the same shape and size.
Argument variables can have any number of items. Key values
may be any value, but the values that are understood by this
function include:
+ 'T': Temperature [K].
+ 'theta': Potential temperature [K].
Any other entries in the variables dictionary will be ignored.
* p0: Potential temperature reference pressure [hPa]. Floating
point scalar. Optional.
* missing: If argument variables has missing values, this is the
missing value value. Floating point scalar. Default is 1e+20.
Optional.
In this function, the following combination of input state vari-
ables are supported for calculating pressure:
* Temperature and potential temperature
The function will automatically apply the correct equation depend-
ing on what key values are available in the argument variables
dictionary. An error is returned if none of the above combina-
tions are present in argument variables.
Output:
* Pressure [hPa]. Numeric floating point array of same dimensions
and size as the arrays in the key:value pairs of argument varia-
bles. If there are any missing values in output, those values
are set to the value in argument missing from the input. If
there are missing values in the output due to math errors and
missing is set to None, output will fill those missing values
with the MA default value of 1e+20.
Reference:
* Wallace, J. M., and P. V. Hobbs (1977): Atmospheric Science:
An Introductory Survey. San Diego, CA: Academic Press, ISBN
0-12-732950-1, p. 69.
Example without missing values:
>>> import press
>>> import Numeric as N
>>> theta = N.array([273.1, 279.404, 277.75073])
>>> T = N.array([273.1, 280.2, 278.4])
>>> a = press.press({'theta':theta, 'T':T})
>>> ['%.8g' % a[i] for i in range(len(a))]
['1000', '1010', '1008.2']
Example with missing values:
>>> import press
>>> import Numeric as N
>>> theta = N.array([273.1, 1e+20, 277.75073])
>>> T = N.array([273.1, 280.2, 278.4])
>>> a = press.press({'theta':theta, 'T':T}, missing=1e20)
>>> ['%.8g' % a[i] for i in range(len(a))]
['1000', '1e+20', '1008.2']
|