Skip to content
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

Merged
merged 2 commits into from May 8, 2017

Conversation

jrleeman
Copy link
Contributor

@jrleeman jrleeman commented May 8, 2017

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

@jrleeman jrleeman requested a review from dopplershift May 8, 2017 15:12
Copy link
Member

@dopplershift dopplershift left a 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.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'uses' -> 'inverts'

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)))
Copy link
Member

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))

@jrleeman
Copy link
Contributor Author

jrleeman commented May 8, 2017

Rebasing - then we're good to go :shipit:

@dopplershift dopplershift merged commit 1f8181e into Unidata:master May 8, 2017
@dopplershift dopplershift added Area: Calc Pertains to calculations Type: Feature New functionality labels May 8, 2017
@dopplershift dopplershift added this to the Summer 2017 milestone May 8, 2017
@jrleeman jrleeman deleted the height_to_pressure branch May 10, 2017 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Calc Pertains to calculations Type: Feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants