Created
January 23, 2022 21:18
-
-
Save DougieLawson/c46b8538486b9a2ddb62097ff2e5e0ce to your computer and use it in GitHub Desktop.
Pressure vs elevation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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