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
Add height to pressure conversion #419
Conversation
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.
Fixed your log
/exp
problem. Also small doc tweak.
metpy/calc/basic.py
Outdated
def height_to_pressure_std(height): | ||
r"""Convert height data to pressures using the U.S. standard atmosphere. | ||
|
||
The implementation uses the formula outlined in [Hobbs1977]_ pg.60-61. |
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.
'uses' -> 'inverts'
metpy/calc/basic.py
Outdated
t0 = 288. * units.kelvin | ||
gamma = 6.5 * units('K/km') | ||
p0 = 1013.25 * units.mbar | ||
return p0 * np.exp((g / (Rd * gamma)) * np.log(1 - (height * gamma / t0))) |
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.
return p0 * (1 - (gamma / t0) * height) ** (g / (Rd * gamma))
4a7e52b
to
2e5058b
Compare
Rebasing - then we're good to go |
2e5058b
to
d80c014
Compare
We had the other way (pressure to height), but this will be useful when drawing scale bars, coloring things based on their height, etc. The equations smells like it could maybe be slightly simplified, but I haven't seen a way to do it that results in any fewer operations, just moves the logarithm around. Closes #407