Package aerocalc :: Module std_atm
[frames] | no frames]

Module std_atm

source code

Calculate standard atmosphere parametres.

Calculates standard atmosphere parametres, using the 1976 International Standard Atmosphere. The default units for the input and output are defined in default_units.py

All altitudes are geopotential altitudes (i.e. it is assumed that there is no variation with altitude of the acceleration due to gravity).

Works up to 84.852 km (278,386 ft) altitude.

Functions
 
alt2temp(H, alt_units='ft', temp_units='C')
Return the standard temperature for the specified altitude.
source code
 
alt2temp_ratio(H, alt_units='ft')
Return the temperature ratio (temperature / standard temperature for sea level).
source code
 
isa2temp(ISA_dev, altitude, temp_units='C', alt_units='ft')
Return the temperature that is a specified amount warmer or cooler than the standard temperature for the altitude.
source code
 
temp2isa(temp, altitude, temp_units='C', alt_units='ft')
Return the amount that the specified temperature is warmer or cooler than the standard temperature for the altitude.
source code
 
alt2press_ratio(H, alt_units='ft')
Return the pressure ratio (atmospheric pressure / standard pressure for sea level).
source code
 
alt2press(H, alt_units='ft', press_units='in HG')
Return the atmospheric pressure for a given altitude, with the altitude in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'), and the pressure in inches of HG ('in HG'), mm of HG ('mm HG'), psi, lb per sq.
source code
 
pressure_alt(H, alt_setting, alt_units='ft')
Return the pressure altitude, given the barometric altitude and the altimeter setting.
source code
 
QNH(HP, H, alt_units='ft', alt_setting_units='in HG')
Return the altimeter setting, given the pressure altitude (HP) and the barometric altitude (H).
source code
 
alt2density_ratio(H, alt_units='ft')
Return the density ratio (atmospheric density / standard density for sea level).
source code
 
alt2density(H, alt_units='ft', density_units='lb/ft**3')
Return the density given the pressure altitude.
source code
 
density2alt(Rho, density_units='lb/ft**3', alt_units='ft')
Return the altitude corresponding to the specified density, with density in 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'.
source code
 
density_ratio2alt(DR, alt_units='ft')
Return the altitude for the specified density ratio.
source code
 
density_alt(H, T, alt_setting=29.9213, DP='FALSE', RH=0.0, alt_units='ft', temp_units='C')
Return density altitude, given the pressure altitude and the temperature with altitudes in units of feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'), and temperature in units of deg C, F, K or R ('C', 'F', 'K' or 'R').
source code
 
sat_press(T='FALSE', DP='FALSE', RH=0.0, temp_units='C', press_units='in HG')
Return the saturated vapour pressure of water.
source code
 
dry_press(H, Pv, alt_setting=29.9213, alt_units='ft', press_units='in HG')
Returns dry air pressure, i.e.
source code
 
density_alt2temp(density_alt_seek, press_alt, alt_units='ft', temp_units='C')
Return temperature to achieve a desired density altitude.
source code
 
density_alt_table(density_alt_seek, alt_range=2000, alt_inc=100, alt_units='ft', temp_units='C', multi_units=False, file='', format='text')
Return a text or html table of required temperature vs pressure altitude.
source code
 
press2alt(P, press_units='in HG', alt_units='ft')
Return the altitude corresponding to the specified pressure, with pressure in inches of HG, mm of HG, psi, psf (lb per sq.
source code
 
press_ratio2alt(PR, alt_units='ft')
Return the pressure ratio for the specified altitude.
source code
 
temp2speed_of_sound(temp, temp_units='C', speed_units='kt')
Return the speed of sound, given the air temperature.
source code
Variables
  default_area_units = 'ft**2'
  default_power_units = 'hp'
  default_speed_units = 'kt'
  default_temp_units = 'C'
  default_weight_units = 'lb'
  default_press_units = 'in HG'
  default_density_units = 'lb/ft**3'
  default_length_units = 'ft'
  default_alt_units = 'ft'
  default_avgas_units = 'lb'
  g = 9.80665
  Rd = 287.05307
  T0 = 288.15
  L0 = -6.5
  P0 = 29.9213
  Rho0 = 1.225
  T11 = 216.65
  PR11 = 0.223361102705
  P11 = 6.68325456235
  Rho11 = 0.363918022787
  T20 = 216.65
  PR20 = 0.0540329489834
  L20 = 1
  P20 = 1.61673607642
  Rho20 = 0.0880348624774
  T32 = 228.65
  PR32 = 0.0085666780685
  L32 = 2.8
  P32 = 0.256326144491
  Rho32 = 0.0132250083082
  T47 = 270.65
  PR47 = 0.00109456008056
  P47 = 0.0327506605385
  Rho47 = 0.00142753342633
  T51 = 270.65
  PR51 = 0.000660635278789
  L51 = -2.8
  P51 = 0.0197670663672
  Rho51 = 0.000861605461257
  T71 = 214.65
  PR71 = 3.90468309069e-05
  L71 = -2.0
  P71 = 0.00116833194161
  Rho71 = 6.42110263179e-05
  default_vol_units = 'ft**3'
Function Details

alt2temp(H, alt_units='ft', temp_units='C')

source code 

Return the standard temperature for the specified altitude. Altitude units may be feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'). Temperature units may be degrees C, F, K or R ('C', 'F', 'K' or 'R')

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the standard temperature (in default temperature units) at 5,000 (default altitude units): >>> alt2temp(5000) 5.0939999999999941

Calculate the standard temperature in deg F at sea level: >>> alt2temp(0, temp_units = 'F') 59.0

Calculate the standard temperature in deg K at 11,000 m: >>> alt2temp(11000, alt_units = 'm', temp_units = 'K') 216.64999999999998

Calculate the standard temperature at 11 statute miles in deg R: >>> alt2temp(11, alt_units = 'sm', temp_units = 'R') 389.96999999999997

The input value may be an expression: >>> alt2temp(11 * 5280, temp_units = 'R') 389.96999999999997

alt2temp_ratio(H, alt_units='ft')

source code 

Return the temperature ratio (temperature / standard temperature for sea level). The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the temperature ratio at 8,000 (default altitude units) >>> alt2temp_ratio(8000) 0.94499531494013533

Calculate the temperature ratio at 8,000 m. >>> alt2temp_ratio(8000, alt_units = 'm') 0.81953843484296374

isa2temp(ISA_dev, altitude, temp_units='C', alt_units='ft')

source code 

Return the temperature that is a specified amount warmer or cooler than the standard temperature for the altitude.

The temperature may be in deg C, F, K or R.

The altitude may be in feet ('ft'), metres ('m'), kilometres ('km'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Determine the temperature that is 10 deg (default temperature units) warmer than the standard temperature at 8,000 (default altitude units): >>> isa2temp(10, 8000) 9.1503999999999905

Determine the temperature that is 25 degrees K cooler than the standard temperature at 2000 m. >>> isa2temp(-25, 2000, temp_units = 'K', alt_units = 'm') 250.14999999999998

temp2isa(temp, altitude, temp_units='C', alt_units='ft')

source code 

Return the amount that the specified temperature is warmer or cooler than the standard temperature for the altitude.

The temperature may be in deg C, F, K or R.

The altitude may be in feet ('ft'), metres ('m'), kilometres ('km'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Determine the ISA deviation for a temperature of 30 deg (default temperature units) at an altitude of 2000 (default altitude units): >>> temp2isa(30, 2000) 18.962400000000002

Determine the ISA deviation in degrees F for a temperature of 45 deg F at an altitude of 1000 m: >>> temp2isa(45, 1000, temp_units = 'F', alt_units = 'm') -2.2999999999999972

alt2press_ratio(H, alt_units='ft')

source code 

Return the pressure ratio (atmospheric pressure / standard pressure
for sea level).  The altitude is specified in feet ('ft'), metres ('m'),
statute miles, ('sm') or nautical miles ('nm').   

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the pressure ratio at 5000 (default altitude units):
>>> alt2press_ratio(5000)
0.8320481158727735

Calculate the pressure ratio at 1000 m:
>>> alt2press_ratio(1000, alt_units = 'm')
0.88699304638887044

The functions are only implemented at altitudes of 84.852 km and lower.
>>> alt2press_ratio(90, alt_units = 'km')
Traceback (most recent call last):
  File '<stdin>', line 1, in ?
  File './std_atm.py', line 189, in alt2press_ratio
if H <= 20:
ValueError: This function is only implemented for altitudes of 84.852 km and below.

alt2press(H, alt_units='ft', press_units='in HG')

source code 

Return the atmospheric pressure for a given altitude, with the altitude in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm'), and the pressure in inches of HG ('in HG'), mm of HG ('mm HG'), psi, lb per sq. ft ('psf'), pa, hpa or mb.

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the pressure in inches of mercury at 5,000 (default altitude units): >>> alt2press(5000) 24.895961289464015

Calculate the pressure in pounds per square foot at 10,000 (default altitude units): >>> alt2press(10000, press_units = 'psf') 1455.3301392981359

Calculate the pressure in pascal at 20 km: >>> alt2press(20, press_units = 'pa', alt_units = 'km') 5474.8827144576408

pressure_alt(H, alt_setting, alt_units='ft')

source code 

Return the pressure altitude, given the barometric altitude and the altimeter setting.

Altimeter setting may have units of inches of HG, or hpa or mb. If the altimeter setting value is less than 35, the units are assumed to be in HG, otherwise they are assumed to be hpa. The altimeter setting must be in the range of 25 to 35 inches of mercury.

The altitude may have units of feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the pressure altitude for 1,000 (default altitude units) barometric altitude with altimeter setting of 30.92 in HG: >>> pressure_alt(1000, 30.92) 88.612734282205338

Calculate the pressure altitude for 1,000 (default altitude units) barometric altitude with altimeter setting of 1008 mb: >>> pressure_alt(1000, 1008) 1143.6503495627171

Calculate the pressure altitude in metres for 304.8 m barometric altitude with altimeter setting of 1008 mb: >>> pressure_alt(304.8, 1008, alt_units = 'm') 348.58462654671621

alt2density_ratio(H, alt_units='ft')

source code 

Return the density ratio (atmospheric density / standard density for sea level). The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the density ratio at 7,500 (default altitude units): >>> alt2density_ratio(7500) 0.79825819881753035

Calculate the density ratio at 2 km: >>> alt2density_ratio(2, alt_units = 'km') 0.8216246960994622

alt2density(H, alt_units='ft', density_units='lb/ft**3')

source code 

Return the density given the pressure altitude. The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

The desired density units are specified as 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'.

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the density in lb / ft cubed at 7,500 (default altitude units): >>> alt2density(7500) 0.061046199847730374

Calculate the density in slugs / ft cubed at 5,000 (default altitude units): >>> alt2density(5000, density_units = 'slug/ft**3') 0.0020480982157718704

Calculate the density in kg / m cubed at 0 (default altitude units: >>> alt2density(0, density_units = 'kg/m**3') 1.2250000000000001

Calculate the density in kg / m cubed at 81,000 m: >>> alt2density(81000, density_units = 'kg/m**3', alt_units = 'm') 1.3320480184052337e-05

density2alt(Rho, density_units='lb/ft**3', alt_units='ft')

source code 

Return the altitude corresponding to the specified density, with density in 'lb/ft**3', 'slug/ft**3' or 'kg/m**3'.

The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the altitude in default altitude units where the density is 0.056475 in default density units: >>> density2alt(.056475) 9999.8040934937271

Calculate the altitude in metres where the density is 0.018012 kg / m cubed: >>> density2alt(.018012, alt_units = 'm', density_units = 'kg/m**3') 29999.978688508152

density_ratio2alt(DR, alt_units='ft')

source code 

Return the altitude for the specified density ratio. The altitude is in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the altitude in default altitude units where the density ratio is 1: >>> density_ratio2alt(1) 0.0

Calculate the altitude in feet where the density ratio is 0.5: >>> density_ratio2alt(.5) 21859.50324995652

Calculate the altitude in km where the density ratio is 0.1 >>> density_ratio2alt(.1, alt_units = 'km') 17.9048674520646

density_alt(H, T, alt_setting=29.9213, DP='FALSE', RH=0.0, alt_units='ft', temp_units='C')

source code 

Return density altitude, given the pressure altitude and the 
temperature with altitudes in units of feet ('ft'), metres ('m'), 
statute miles, ('sm') or nautical miles ('nm'), and temperature in units
of deg C, F, K or R ('C', 'F', 'K' or 'R').

Mandatory parametres:
H = altitude
T = temperature

Optional parametres:
alt_setting = altimeter setting (defaults to 29.9213 if not provided
DP = dew point
RH = relative humidity
alt_units = units for the altitude.  'ft', 'm', or 'km'.  
temp_units = units for the temperature and dew point.  'C', 'F', 'K' 
             or 'R'.

The altimeter setting units are assumed to be inches of HG, unless the 
value is greater than 35.  In this case the units are assumed to be mb.

If the dew point or relative humidity are not specified, the air is 
assumed to be completely dry.  If both the dew point and relative humidity
are specified, the relative humidity value is ignored.

If the units are not specified, the units in default_units.py are used.

The method is from: http://wahiduddin.net/calc/density_altitude.htm

Examples:

Calculate the density altitude in default altitude units for a pressure 
altitude of 7000 default altitude units and a temperature of 15 deg 
(default temperature units).  The altimeter setting is not specified, so it 
defaults to standard pressure of 29.9213 in HG or 1013.25 mb:
>>> density_alt(7000, 15)
8595.3465863232504

Calculate the density altitude in default altitude units for a pressure 
altitude of 7000 default altitude units and a temperature of 85 deg F.  
The altimeter setting is not specified, so it defaults to standard pressure 
of 29.9213 in HG or 1013.25 mb.  The dew point and relative humidity are 
not specified, so the air is assumed to be dry:
>>> density_alt(7000, 85, temp_units = 'F')
10159.10696106757

Calculate the density altitude in default altitude units for a pressure 
altitude of 7000 default altitude units, an altimeter setting of 29.80 and
a temperature of 85 deg F and a dew point of 55 deg F:
>>> density_alt(7000, 85, 29.80, 55, temp_units = 'F')
10522.776013011618

Calculate the density altitude in metres for a pressure altitude of 
2000 m, an altimeter setting of 1010 mb,  a temperature of 15 deg (default 
temperature units) and a relative humidity of 50%:
>>> density_alt(2000, 15, 1010, alt_units = 'm', RH = 0.5)
2529.8230634449737

The dew point may be specified in one of two ways: as the fourth 
argument on the command line, or via the keyword argument DP.
>>> density_alt(2000, 15, 1010, alt_units = 'm', DP = 5)
2530.7528237990618
    
The relative humidity must be in the range of 0 to 1:
>>> density_alt(2000, 15, 1010, alt_units = 'm', RH = 1.1)
Traceback (most recent call last):
  File '<stdin>', line 1, in ?
  File 'std_atm.py', line 533, in density_alt
raise ValueError, 'The relative humidity must be in the range of 0 to 1.'
ValueError: The relative humidity must be in the range of 0 to 1.

sat_press(T='FALSE', DP='FALSE', RH=0.0, temp_units='C', press_units='in HG')

source code 

Return the saturated vapour pressure of water. Either the dew point, or the temperature and the relative humidity must be specified. If both the dew point and relative humidity are specified, the relative humidity value is ignored.

If the temperature and dew point are both specified, the dew point cannot be greater than the temperature:

If the units are not specified, the units in default_units.py are used.

>>> sat_press(T=10, DP=11)
Traceback (most recent call last):
  File '<stdin>', line 1, in <module>
  File 'std_atm.py', line 795, in sat_press
    raise ValueError, 'The dew point cannot be greater than the temperature.'
ValueError: The dew point cannot be greater than the temperature.

Dew point is 11 deg (default temperature units). Find the water vapour pressure in default pressure units: >>> sat_press(DP=11) 0.38741015927568667

Dew point is 65 deg F. Find the water vapour pressure in default pressure units: >>> sat_press(DP=65, temp_units = 'F') 0.62207710701956165

Dew point is 212 deg F (the boiling point of water at sea level). Find the water vapour pressure in lb per sq. inch: >>> sat_press(DP=212, temp_units = 'F', press_units = 'psi') 14.696764873564959

Temperature is 30 deg C. Find the water vapour pressure in default pressure units: for 50% relative humidity: >>> sat_press(T=30, RH = 0.5) 0.62647666996057927

dry_press(H, Pv, alt_setting=29.9213, alt_units='ft', press_units='in HG')

source code 

Returns dry air pressure, i.e. the total air pressure, less the water vapour pressure.

density_alt2temp(density_alt_seek, press_alt, alt_units='ft', temp_units='C')

source code 

Return temperature to achieve a desired density altitude.

If the units are not specified, the units in default_units.py are used.

density_alt_table(density_alt_seek, alt_range=2000, alt_inc=100, alt_units='ft', temp_units='C', multi_units=False, file='', format='text')

source code 

Return a text or html table of required temperature vs pressure altitude.

If the units are not specified, the units in default_units.py are used.

press2alt(P, press_units='in HG', alt_units='ft')

source code 

Return the altitude corresponding to the specified pressure, with pressure in inches of HG, mm of HG, psi, psf (lb per sq. ft), pa, hpa or mb.

The altitude is in units of feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm')

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the pressure altitude in feet for a pressure of 31.0185 inches of HG: >>> press2alt(31.0185) -999.98992888235091

Calculate the pressure altitude in feet for a pressure of 1455.33 lb sq. ft: >>> press2alt(1455.33, press_units = 'psf') 10000.002466564831

Calculate the pressure altitude in metres for a pressure of 90.3415 mm HG: >>> press2alt(90.3415, press_units = 'mm HG', alt_units = 'm') 15000.025465320754

Calculate the pressure altitude in metres for a pressure of 1171.86 pascal: >>> press2alt(1171.86, press_units = 'pa', alt_units = 'm') 30000.029510365184

press_ratio2alt(PR, alt_units='ft')

source code 

Return the pressure ratio for the specified altitude. The altitude is specified in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical miles ('nm').

If the units are not specified, the units in default_units.py are used.

Examples:

Calculate the altitude in feet where the pressure ratio is 0.5: >>> press_ratio2alt(.5) 17969.990746028907

Calculate the altitude in metres where the pressure ratio is 0.1: >>> press_ratio2alt(.1, alt_units = 'm') 16096.249927559489

temp2speed_of_sound(temp, temp_units='C', speed_units='kt')

source code 

Return the speed of sound, given the air temperature.

The temperature units may be deg C, F, K or R ('C', 'F', 'K' or 'R').

The speed units may be 'kt', 'mph', 'km/h', 'm/s' and 'ft/s'.

If the units are not specified, the units in default_units.py are used.

Examples:

Determine speed of sound in knots at 15 deg (default temperature units): >>> temp2speed_of_sound(15) 661.47882487301808

Determine speed of sound in mph at 120 deg F: >>> temp2speed_of_sound(120, speed_units = 'mph', temp_units = 'F') 804.73500154991291