Re: Home-made ranging and hold-over "computer system"
Here's the python code for IACO Standard Atmosphere / Pressure Altitude as a Function of Station Pressure. Just put in your station pressure and it prints out the following:
Pressure Altitude (OSL)
Pressure (in Hg)
Temperature (in F)
----
<div class="ubbcode-block"><div class="ubbcode-header">Code:</div><div class="ubbcode-body ubbcode-pre" ><pre>
#!/usr/bin/python
################################################################################
## DATE: 2010-10-31
## AUTHOR: Matt Reid
## WEBSITE:
http://themattreid.com ## EMAIL:
[email protected] ## LICENSE: BSD
http://www.opensource.org/licenses/bsd-license.php from __future__ import division
import sys
increments = {"35":"-4402","34.75":"-4198","34.5":"-3992","34.25":"-3786","34":"-3578","33.75":"-3369","33.5":"-3159","33.25":"-2947","33":"-2734","32.75":"-2520","32.5":"-2305","32.25":"-2088","32":"-1870","31.75":"-1650","31.5":"-1429","31.25":"-1207","31":"-938","30.75":"-758","30.5":"-531","30.25":"-303","30":"-73","29.75":"159","29.5":"392","29.25":"626","29":"862","28.75":"1100","28.5":"1340","28.25":"1581","28":"1824","27.75":"2069","27.5":"2315","27.25":"2564","27":"2814","26.75":"3066","26.5":"3320","26.25":"3576","26":"3834","25.75":"4094","25.5":"4356","25.25":"4620","25":"4886","24.75":"5155","24.5":"5425","24.25":"5698","24":"5973","23.75":"6251","23.5":"6531","23.25":"6813","23":"7098","22.75":"7385","22.5":"7675","22.25":"7967","22":"8262","21.75":"8560","21.5":"8861","21.25":"9164","21":"9471","20.75":"9780","20.5":"10092","20.25":"10408","20":"10726","19.75":"11048","19.5":"11374","19.25":"11702","19":"12034","18.75":"12370","18.5":"12709","18.25":"13052","18":"13399","17.75":"13750","17.5":"14104","17.25":"14463","17":"14826","16.75":"15194","16.5":"15566","16.25":"15942","16":"16324","15.75":"16710","15.5":"17101","15.25":"17497","15":"17899","14.75":"18306","14.5":"18718","14.25":"19137","14":"19561","13.75":"19992","13.5":"20429","13.25":"20872","13":"21323","12.75":"21780","12.5":"22245","12.25":"22718","12":"23198","11.75":"23686","11.5":"24183","11.25":"24689","11":"25204","10.75":"25728","10.5":"26263","10.25":"26808","10":"27364","9.75":"27931","9.5":"28510","9.25":"29101"}
alt = ["-6000", "-5000", "-4000", "-3000", "-2000", "-1000", "0", "1000", "2000", "3000", "4000", "5000", "6000", "7000", "8000", "9000", "10000", "11000", "12000", "13000", "14000", "15000", "16000", "17000", "18000", "19000", "20000"]
pressure = ["37","35.74", "34.51", "33.31", "32.15", "31.02", "29.92", "28.86", "27.82", "26.82", "25.84", "24.89", "23.98", "23.09", "22.22", "21.38", "20.57", "19.79", "19.02", "18.29", "17.57", "16.88", "16.21", "15.56", "14.94", "14.33", "13.74"]
temp = ["80.4", "76.8", "73.3", "69.7", "66.1", "62.6", "59", "55.4", "51.9", "48.3", "44.7", "41.2", "37.6", "34", "30.5", "26.9", "23.3", "19.8", "16.2", "12.6", "9.1", "5.5", "1.9", "-1.6", "-5.2", "-8.8", "-12.3"]
def pressure_match(P):
y=0
match=[]
for each in pressure:
if P in each:
match.append
y+=1
if len(match) > 0:
if len(match) > 1:
print "\nMultiple matches found, please choose a precision."
print "--------"
for i in match:
print "Pressure (in Hg): %s"%(pressure
)
print "--------"
print "Exiting"
sys.exit(1)
return match[0]
P = str(raw_input("Current station pressure(in Hg): "))
try:
print "Pressure Altitude (OSL): %s"%(increments[P])
print "Temperature (in F): N/A"
except:
try:
index = pressure_match(P)
print "Pressure Altitude (OSL): %s"%(alt[index])
print "Pressure (in Hg): %s"%(pressure[index])
print "Temperature (in F): %s"%(temp[index])
except:
print "----------"
print "No record found for entry: %s."%(P)
print" Please specify pressure in increments of .25"
print "Minimum value: 9.25"
print "Maximum Value: 35"
print "----------"</pre></div></div>