| |
- mix_ratio(variables, missing=1e+20)
- Calculate mixing ratio.
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 values that may be used by this function
include:
+ 'e': Vapor pressure over water [hPa].
+ 'p': Total pressure [hPa].
+ 'q': Specific humidity [kg/kg].
* missing: If values in variables has missing values, this is
the missing value value. Floating point scalar. Default is
1e+20. Optional.
Output:
* Mixing ratio [kg/kg]. Numeric array of same dimensions and
size as state variables in the argument. 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.
The mixing ratio can be calculated from a variety of different
combinations of state variables. In this function, the following
combinations are supported:
* Vapor pressure and total pressure.
* Specific humidity.
The function will automatically apply the correct equation depen-
ding on the key values of the argument dictionary. An error is
returned if none of the above combinations are present as the
input argument.
Reference:
* Emanuel, K. A. (1994): Atmospheric Convection. New York, NY:
Oxford University Press, 580 pp.
Example with missing values:
>>> from mix_ratio import mix_ratio
>>> import Numeric as N
>>> p = N.array([1026.8, 840.2, 1e+20, 450.2])
>>> e = N.array([9.00051379, 7.23209979, 1e+20, 2.80541885])
>>> r = mix_ratio({'p':p, 'e':e}, missing=1e+20)
>>> ['%.7g' % r[i] for i in range(len(r))]
['0.0055', '0.0054', '1e+20', '0.0039']
|