-
-
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0c7c59d
Added Altitude Pressure equation
Bazifrasool a6a2ef7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8637b46
Removed trailing whitespaces
Bazifrasool 329c1bd
Merge branch 'Altitude-Equation' of https://github.com/Bazifrasool/Py…
Bazifrasool 83397b0
Removed pylint
Bazifrasool b0e0aac
Merge branch 'Altitude-Equation' of https://github.com/Bazifrasool/Py…
Bazifrasool 87e18da
Fix lru_cache_pythonic.py
cclauss 1ef703a
Fixed spellings
Bazifrasool 56061bb
Merge branch 'Altitude-Equation' of https://github.com/Bazifrasool/Py…
Bazifrasool 2a9a4fc
Fix again lru_cache_pythonic.py
cclauss a80c46d
Update .vscode/settings.json
Bazifrasool dbda328
Third fix lru_cache_pythonic.py
cclauss eeb3186
Update .vscode/settings.json
Bazifrasool ef1e63d
4th fix lru_cache_pythonic.py
cclauss b88c755
Update physics/altitude_pressure.py
Bazifrasool 8bbf349
lru_cache_pythonic.py: def get(self, key: Any, /) -> Any | None:
cclauss dbb6803
Delete lru_cache_pythonic.py
cclauss 3f66598
Added positive and negative pressure test cases
Bazifrasool e7e7f3a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 altitude 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 | ||
""" | ||
|
||
if pressure > 101325: | ||
raise ValueError("Value Higher than Pressure at Sea Level !") | ||
|
||
return 44_330 * (1 - (pressure / 101_325) ** (1 / 5.5255)) | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
|
||
doctest.testmod() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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