| |
- press2alt(arg, P0=None, T0=None, missing=1e+20, invert=0)
- Calculate elevation given pressure (or vice versa).
Calculations are made assuming that the temperature distribution
follows the 1976 Standard Atmosphere. Technically the standard
atmosphere defines temperature distribution as a function of
geopotential altitude, and this routine actually calculates geo-
potential altitude rather than geometric altitude.
Method Positional Argument:
* arg: Numeric floating point vector of any shape and size, or a
Numeric floating point scalar. If invert=0 (the default), arg
is air pressure [hPa]. If invert=1, arg is elevation [m].
Method Keyword Arguments:
* P0: Pressure [hPa] at the surface (altitude equals 0). Numeric
floating point vector of same size and shape as arg or a scalar.
Default of keyword is set to None, in which case the routine
uses the value of instance attribute sea_level_press (converted
to hPa) from the AtmConst class. Keyword value is used if the
keyword is set in the function call. This keyword cannot have
any missing values.
* T0: Temperature [K] at the surface (altitude equals 0). Numeric
floating point vector of same size and shape as arg or a scalar.
Default of keyword is set to None, in which case the routine uses
the value of instance attribute sea_level_temp from the AtmConst
class. Keyword value is used if the keyword is set in the func-
tion call. This keyword cannot have any missing values.
* missing: If arg has missing values, this is the missing value
value. Floating point scalar. Default is 1e+20.
* invert: If set to 1, function calculates pressure [hPa] from
altitude [m]. In that case, positional input variable arg is
altitude [m] and the output is pressure [hPa]. Default value of
invert=0, which means the function calculates altitude given
pressure.
Output:
* If invert=0 (the default), output is elevation [m] at each
element of arg, relative to the surface. If invert=1, output
is the air pressure [hPa]. Numeric floating point array of
the same size and shape as arg.
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.
References:
* Carmichael, Ralph (2003): "Definition of the 1976 Standard Atmo-
sphere to 86 km," Public Domain Aeronautical Software (PDAS).
URL: http://www.pdas.com/coesa.htm.
* Wallace, J. M., and P. V. Hobbs (1977): Atmospheric Science:
An Introductory Survey. San Diego, CA: Academic Press, ISBN
0-12-732950-1, pp. 60-61.
Examples:
(1) Calculating altitude given pressure:
>>> from press2alt import press2alt
>>> import Numeric as N
>>> press = N.array([200., 350., 850., 1e+20, 50.])
>>> alt = press2alt(press, missing=1e+20)
>>> ['%.7g' % alt[i] for i in range(5)]
['11783.94', '8117.19', '1457.285', '1e+20', '20575.96']
(2) Calculating pressure given altitude:
>>> alt = N.array([0., 10000., 15000., 20000., 50000.])
>>> press = press2alt(alt, missing=1e+20, invert=1)
>>> ['%.7g' % press[i] for i in range(5)]
['1013.25', '264.3589', '120.443', '54.74718', '0.7593892']
(3) Input is a Numeric floating point scalar, and using a keyword
set surface pressure to a different scalar:
>>> alt = press2alt(N.array(850.), P0=1000.)
>>> ['%.7g' % alt[0]]
['1349.778']
|