Skip to content

Commit

Permalink
Reduce array ops
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamron committed Jan 6, 2025
1 parent be2c8bc commit 26ea138
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ def moist_air_gas_constant(specific_humidity):
Notes
-----
Adapted from
.. math:: R_m = (1 - q_v) R_a + q_v R_v
Eq 16, [Romps2017]_ using MetPy-defined constants in place of cited values.
"""
return ((1 - specific_humidity) * mpconsts.nounit.Rd
+ specific_humidity * mpconsts.nounit.Rv)
return mpconsts.nounit.Rd + specific_humidity * (mpconsts.nounit.Rv - mpconsts.nounit.Rd)


@exporter.export
Expand Down Expand Up @@ -98,13 +99,15 @@ def moist_air_specific_heat_pressure(specific_humidity):
Notes
-----
Adapted from
.. math:: c_{pm} = (1 - q_v) c_{pa} + q_v c_{pv}
Eq 17, [Romps2017]_ using MetPy-defined constants in place of cited values.
"""
return ((1 - specific_humidity) * mpconsts.nounit.Cp_d
+ specific_humidity * mpconsts.nounit.Cp_v)
return (mpconsts.nounit.Cp_d
+ specific_humidity * (mpconsts.nounit.Cp_v - mpconsts.nounit.Cp_d))


@exporter.export
Expand Down

0 comments on commit 26ea138

Please sign in to comment.