-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Added Altitude Pressure equation #8909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
0c7c59d
a6a2ef7
8637b46
329c1bd
83397b0
b0e0aac
87e18da
1ef703a
56061bb
2a9a4fc
a80c46d
dbda328
eeb3186
ef1e63d
b88c755
8bbf349
dbb6803
3f66598
e7e7f3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"githubPullRequests.ignoredPullRequestBranches": [ | ||
"master" | ||
] | ||
], | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.enabled": true | ||
Bazifrasool marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||||||
""" | ||||||||||
Title : Calculate altitude using Pressure | ||||||||||
|
||||||||||
Description : | ||||||||||
The below algorithm approximates the altitute using Barometric formula | ||||||||||
|
||||||||||
|
||||||||||
""" | ||||||||||
|
||||||||||
|
||||||||||
def get_altitude_at_pressure(pressure: float) -> float: | ||||||||||
""" | ||||||||||
This method calculates the altitude from Pressure wrt to | ||||||||||
Sea level pressure as reference .Pressure is in Pascals | ||||||||||
https://en.wikipedia.org/wiki/Pressure_altitude | ||||||||||
https://community.bosch-sensortec.com/t5/Question-and-answers/How-to-calculate-the-altitude-from-the-pressure-sensor-data/qaq-p/5702 | ||||||||||
|
||||||||||
H = 44330 * [1 - (P/p0)^(1/5.255) ] | ||||||||||
|
||||||||||
Where : | ||||||||||
H = altitude (m) | ||||||||||
P = measured pressure | ||||||||||
p0 = reference pressure at sea level 101325 Pa | ||||||||||
|
||||||||||
Examples: | ||||||||||
|
||||||||||
>>> get_altitude_at_pressure(pressure=100000) | ||||||||||
105.47836610778828 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make tests for H ~= sea level, H ~= 100 meters (the current test), H ~= 1,750 (altitude of my house) also a zero pressure, a negative pressure, and a pressure greater than 101,325... The last few should prove that the code raises ValueErrors like... Python/arithmetic_analysis/bisection.py Lines 9 to 12 in d31750a
|
||||||||||
""" | ||||||||||
|
||||||||||
if pressure > 101325: | ||||||||||
raise ValueError("Value Higer than Pressure at Sea Level !") | ||||||||||
|
||||||||||
return 44330 * (1 - (pressure / 101325) ** (1 / 5.5255)) | ||||||||||
Bazifrasool marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
|
||||||||||
if __name__ == "__main__": | ||||||||||
import doctest | ||||||||||
|
||||||||||
doctest.testmod() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change. This repo not use pylint. Instead, we use ruff that includes the pylint rules.
Python/pyproject.toml
Line 111 in d31750a