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

Module unit_conversion

source code

Convert between various units.

Functions
 
area_conv(A, from_units='ft**2', to_units='ft**2')
Convert area values between ft**2, in**2, m**2, km**2, sm**2 and nm**2.
source code
 
density_conv(D, from_units, to_units)
Convert density values between kg/m**3, slug/ft**3 and lb/ft**3.
source code
 
force_conv(F, from_units='lb', to_units='lb')
Convert force values between lb and N.
source code
 
len_conv(L, from_units='ft', to_units='ft')
Convert length values between ft, in, m, km, sm and nm.
source code
 
power_conv(P, from_units='hp', to_units='hp')
Convert power values between horsepower, ft-lb/mn, ft-lb/s, watts, kilowatts, BTU/hr and BTU/mn.
source code
 
press_conv(P, from_units='in HG', to_units='in HG')
Convert pressure values between inches of HG, mm of HG, psi, lb/ft^2, hpa and mb.
source code
 
speed_conv(S, from_units='kt', to_units='kt')
Convert speed values between kt, mph, km/h, m/s and ft/s.
source code
 
temp_conv(T, from_units='C', to_units='C')
Convert absolute temperature values between deg C, F, K and R.
source code
 
vol_conv(V, from_units='ft**3', to_units='ft**3')
Convert volume values between USG, ImpGal (Imperial gallons), l (litres), ft**3, in**3, m**3, km**3, sm**3 and nm**3.
source code
 
wt_conv(W, from_units='lb', to_units='lb')
Convert weight values between lb and kg.
source code
 
avgas_conv(AG, from_units='lb', to_units='lb', temp=15, temp_units='C', grade='nominal')
Convert aviation gasoline between units of lb, US Gallon (USG), Imperial Gallon (Imp Gal), litres (l) and kg, assuming nominal density for aviation gasoline of 6.01 lb per USG.
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'
  default_vol_units = 'ft**3'
Function Details

area_conv(A, from_units='ft**2', to_units='ft**2')

source code 

Convert area values between ft**2, in**2, m**2, km**2, sm**2 and nm**2.

The incoming value is first converted to ft**2, then it is converted to desired return value.

The units default to those specified in default_units.py

Examples:

Convert 1 ft**2 to inches**2, with ft**2 already defined as the default units: >>> area_conv(1, to_units = 'in**2') 144.0

Convert 288 square inches to square feet, with ft**2 already defined as the default units: >>> area_conv(288, from_units = 'in**2') 2.0

Convert 10 square metres to square inches: >>> area_conv(1000, from_units = 'm**2', to_units = 'in**2') 1550003.1000061999

density_conv(D, from_units, to_units)

source code 

Convert density values between kg/m**3, slug/ft**3 and lb/ft**3.

The incoming value is first converted to kg/m**3, then it is converted to desired return value.

There are no default units. Both the from_units and the to_units must be specified.

Example:

Convert 1.225 kg per metre cubed to lb per foot cubed: >>> density_conv(1.225, from_units = 'kg/m**3', to_units = 'lb/ft**3') 0.076474253491112101

force_conv(F, from_units='lb', to_units='lb')

source code 

Convert force values between lb and N.

The incoming value is first converted to N, then it is converted to the desired return value.

len_conv(L, from_units='ft', to_units='ft')

source code 

Convert length values between ft, in, m, km, sm and nm.

The incoming value is first converted to ft, then it is converted to desired return value.

The units default to those specified in default_units.py

Examples:

Convert 5280 ft to statute miles, with feet already defined as the default units: >>> len_conv(5280, to_units = 'sm') 1.0

Convert 1 nautical mile to feet, with feet already defined as the default units: >>> len_conv(1, from_units = 'nm') 6076.1154855643044

Convert 1000 metres to kilometres: >>> len_conv(1000, from_units = 'm', to_units = 'km') 0.99999999999999989

power_conv(P, from_units='hp', to_units='hp')

source code 

Convert power values between horsepower, ft-lb/mn, ft-lb/s, watts, kilowatts, BTU/hr and BTU/mn.

The incoming value is first converted to hp, then it is converted to the desired return value. The units default to those specified in default_units.py

press_conv(P, from_units='in HG', to_units='in HG')

source code 

Convert pressure values between inches of HG, mm of HG, psi, lb/ft^2, hpa and mb.

The incoming value is first converted to Pa, then it is converted to desired return value. The units default to those specified in default_units.py

Examples:

Convert 1013.25 hpa to default pressure units: >>> press_conv(1013.25, from_units = 'hpa') 29.921331923765198

Convert 29.9213 default pressure units to mm of HG: >>> press_conv(29.9213, to_units = 'mm HG') 760.00128931459176

Convert 2116.22 lb per sq. ft to lb per sq. inch: >>> press_conv(2116.22, from_units = 'psf', to_units = 'psi') 14.695973160069311

speed_conv(S, from_units='kt', to_units='kt')

source code 

Convert speed values between kt, mph, km/h, m/s and ft/s.

The incoming value is first converted to kt, then it is converted to desired return value. The units default to those specified in default_units.py

Example:

Convert 230 mph to kt: >>> speed_conv(230, from_units = 'mph', to_units = 'kt') 199.86453563714903

temp_conv(T, from_units='C', to_units='C')

source code 

Convert absolute temperature values between deg C, F, K and R.

This function should not be used for relative temperature conversions, i.e. temperature differences.

The incoming value is first converted to deg K, then it is converted to desired return value. The units default to those specified in default_units.py

Examples:

Convert 32 deg F to deg C, with deg C as the default units: >>> temp_conv(32, from_units = 'F') 0.0

Convert 100 deg C to deg F, with deg C as the default units: >>> temp_conv(100, to_units = 'F') 212.0

Convert 59 deg F to deg K >>> temp_conv(59, from_units = 'F', to_units = 'K') 288.14999999999998

vol_conv(V, from_units='ft**3', to_units='ft**3')

source code 

Convert volume values between USG, ImpGal (Imperial gallons), l (litres), ft**3, in**3, m**3, km**3, sm**3 and nm**3.

The incoming value is first converted to ft**3, then it is converted to desired return value.

The units default to those specified in default_units.py

Examples:

Convert 1 cubic foot to US gallons, with cubic feet already defined as the default units: >>> vol_conv(1, to_units = 'USG') 7.4805194804946105

Convert 1 Imperial gallon to cubic feet, with cubic feet already defined as the default units: >>> vol_conv(1, from_units = 'ImpGal') 0.16054365323600001

Convert 10 US gallon to litres: >>> vol_conv(10, from_units = 'USG', to_units = 'l') 37.854117840125852

wt_conv(W, from_units='lb', to_units='lb')

source code 

Convert weight values between lb and kg.

Purists will yell that lb is a unit of weight, and kg is a unit of mass. Get over it.

The incoming value is first converted to kg, then it is converted to the desired return value.

The units default to those specified in default_units.py

avgas_conv(AG, from_units='lb', to_units='lb', temp=15, temp_units='C', grade='nominal')

source code 

Convert aviation gasoline between units of lb, US Gallon (USG), 
Imperial Gallon (Imp Gal), litres (l) and kg, assuming nominal
density for aviation gasoline of 6.01 lb per USG.

The units default to those specified in default_units.py

Note: it was difficult to find authoritative values for aviation gasoline 
density.  Conventional wisdom is that aviation gasoline has a density of
6 lb/USG.  The Canada Flight Supplement provides densities of:
temp      density     density    density
(deg C)   (lb/USG)  (lb/ImpGal)  (lb/l)
-40         6.41       7.68       1.69
-20         6.26       7.50       1.65
  0         6.12       7.33       1.62
 15         6.01       7.20       1.59
 30         5.90       7.07       1.56

However, the Canada Flight Supplement does not provide a source for its
density data.  And, the values for the different volume units are not 
completly consistent, as they don't vary by exactly the correct factor.
For example, if the density at 15 deg C is 6.01 lb/USG, we would expect 
the density in lb/ImpGal to be 7.22, (given that 1 ImpGal = 1.201 USG) 
yet the Canada Flight Supplement has 7.20.

The only authoritative source for aviation gasoline density that was
found on the web was the "Air BP Handbook of Products" on the British 
Petroleum (BP) web site:

<http://www.bp.com/liveassets/bp_internet/aviation/air_bp/STAGING/local_assets/downloads_pdfs/a/air_bp_products_handbook_04004_1.pdf>

It provides the following density data valid at 15 deg C (the BP document
only provides density in kg/m**3 - the density in lb/USG were calculated 
by Kevin Horton):
Avgas    density     density
Type    (kg/m**3)    (lb/USG)
80       690          5.76
100      695          5.80
100LL    715          5.97

The available aviation gasoline specifications do not appear to define an 
allowable density range.  They do define allowable ranges for various 
parametres of the distillation process - the density of the final product 
will vary depending on where in the allowable range the refinery is run.
Thus there will be some variation in density from refinery to refinery.

This function uses the 15 deg C density values provided by BP, with the
variation with temperature provided in the Canada Flight Supplement.

The grade may be specified as "80", "100" or "100LL".  It defaults to 
"100LL" if it is not specified.

The temperature defaults to 15 deg C if it is not specified.