Skip to content

Instantly share code, notes, and snippets.

@DougieLawson
Created January 23, 2022 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougieLawson/c46b8538486b9a2ddb62097ff2e5e0ce to your computer and use it in GitHub Desktop.
Save DougieLawson/c46b8538486b9a2ddb62097ff2e5e0ce to your computer and use it in GitHub Desktop.
Pressure vs elevation
#!/usr/bin/python
import math
import sys
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-e', '--elevation')
parser.add_argument('-p', '--pressure')
parser.add_argument('-m', '--msl')
# Give any two parms, calculate the other.
args = parser.parse_args()
if args.elevation is None:
args.elevation = 112.2 # Value from my GPS for my house in metres
if args.pressure is None:
print "Pressure value required"
sys.exit(40)
if args.msl is None:
args.msl = 1013.25
args.pressure = float(args.pressure)
args.elevation = float(args.elevation)
args.msl = float(args.msl)
print "Elevation:", args.elevation, "Pressure:", args.pressure, "MSL:", args.msl
print "Sealevel:",args.pressure/pow(1-(args.elevation/44330.0),5.255)
print "Elevation:",(44330.0*(1-pow(args.pressure/args.msl,1/5.255)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment