Skip to content

Commit

Permalink
MNT: Refactor montgomery_streamfunction
Browse files Browse the repository at this point in the history
Rewrite to forward on to dry_static_energy since they are identical
calculations. Also add references to each other in the docstrings.
  • Loading branch information
dopplershift committed Oct 31, 2020
1 parent 54129e6 commit db49633
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/metpy/calc/kinematics.py
Expand Up @@ -4,7 +4,7 @@
"""Contains calculation of kinematic parameters (e.g. divergence or vorticity)."""
import numpy as np

from . import coriolis_parameter
from . import coriolis_parameter, dry_static_energy
from .tools import first_derivative, get_layer_heights, gradient
from .. import constants as mpconsts
from ..package_tools import Exporter
Expand Down Expand Up @@ -484,7 +484,6 @@ def ageostrophic_wind(height, u, v, dx=None, dy=None, latitude=None, x_dim=-1, y


@exporter.export
@preprocess_and_wrap(wrap_like='height', broadcast=('height', 'temperature'))
@check_units('[length]', '[temperature]')
def montgomery_streamfunction(height, temperature):
r"""Compute the Montgomery Streamfunction on isentropic surfaces.
Expand Down Expand Up @@ -519,10 +518,10 @@ def montgomery_streamfunction(height, temperature):
See Also
--------
get_isentropic_pressure
get_isentropic_pressure, dry_static_energy
"""
return (mpconsts.g * height) + (mpconsts.Cp_d * temperature)
return dry_static_energy(height, temperature)


@exporter.export
Expand Down
4 changes: 4 additions & 0 deletions src/metpy/calc/thermo.py
Expand Up @@ -2358,6 +2358,10 @@ def dry_static_energy(height, temperature):
`pint.Quantity`
The dry static energy
See Also
--------
montgomery_streamfunction
"""
return (mpconsts.g * height + mpconsts.Cp_d * temperature).to('kJ/kg')

Expand Down

0 comments on commit db49633

Please sign in to comment.