Skip to content

Commit

Permalink
update to process_units
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamron committed Dec 24, 2024
1 parent 1afd853 commit 5e1ac05
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

@exporter.export
@preprocess_and_wrap(wrap_like='specific_humidity')
@check_units('[dimensionless]')
@process_units(input_dimensionalities={'specific_humidity': 'dimensionless'},
output_dimensionalities='[specific_heat_capacity]',
output_to='J kg**-1 K**-1')
def moist_air_gas_constant(specific_humidity):
r"""Calculate R_m, the specific gas constant for a parcel of moist air.
Expand Down Expand Up @@ -68,7 +70,9 @@ def moist_air_gas_constant(specific_humidity):

@exporter.export
@preprocess_and_wrap(wrap_like='specific_humidity')
@check_units('[dimensionless]')
@process_units(input_dimensionalities={'specific_humidity': 'dimensionless'},
output_dimensionalities='[specific_heat_capacity]',
output_to='J kg**-1 K**-1')
def moist_air_specific_heat_pressure(specific_humidity):
r"""Calculate C_pm, the specific heat at constant pressure for a moist air parcel.
Expand Down Expand Up @@ -105,7 +109,9 @@ def moist_air_specific_heat_pressure(specific_humidity):

@exporter.export
@preprocess_and_wrap(wrap_like='temperature')
@check_units('[temperature]')
@process_units(input_dimensionalities={'temperature': '[temperature]'},
output_dimensionalities='[specific_enthalpy]',
output_to='J kg**-1')
def water_latent_heat_vaporization(temperature):
r"""Calculate the latent heat of vaporization for water.
Expand Down Expand Up @@ -140,14 +146,16 @@ def water_latent_heat_vaporization(temperature):
Eq 15, [Ambaum2020]_, using MetPy-defined constants in place of cited values.
"""
return (mpconsts.water_heat_vaporization
- (mpconsts.water_specific_heat - mpconsts.wv_specific_heat_press)
* (temperature - mpconsts.water_triple_point_temperature))
return (mpconsts.nounit.Lv
- (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_v)
* (temperature - mpconsts.nounit.T0))


@exporter.export
@preprocess_and_wrap(wrap_like='temperature')
@check_units('[temperature]')
@process_units(input_dimensionalities={'temperature': '[temperature]'},
output_dimensionalities='[specific_enthalpy]',
output_to='J kg**-1')
def water_latent_heat_sublimation(temperature):
r"""Calculate the latent heat of sublimation for water.
Expand Down Expand Up @@ -180,14 +188,16 @@ def water_latent_heat_sublimation(temperature):
Eq 18, [Ambaum2020]_, using MetPy-defined constants in place of cited values.
"""
return (mpconsts.water_heat_sublimation
- (mpconsts.ice_specific_heat - mpconsts.wv_specific_heat_press)
* (temperature - mpconsts.water_triple_point_temperature))
return (mpconsts.nounit.Ls
- (mpconsts.nounit.Cp_i - mpconsts.nounit.Cp_v)
* (temperature - mpconsts.nounit.T0))


@exporter.export
@preprocess_and_wrap(wrap_like='temperature')
@check_units('[temperature]')
@process_units(input_dimensionalities={'temperature': '[temperature]'},
output_dimensionalities='[specific_enthalpy]',
output_to='J kg**-1')
def water_latent_heat_melting(temperature):
r"""Calculate the latent heat of melting for water.
Expand Down Expand Up @@ -221,9 +231,9 @@ def water_latent_heat_melting(temperature):
Uses MetPy-defined constants in place of cited values.
"""
return (mpconsts.water_heat_fusion
- (mpconsts.water_specific_heat - mpconsts.ice_specific_heat)
* (temperature - mpconsts.water_triple_point_temperature))
return (mpconsts.nounit.Lf
- (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_i)
* (temperature - mpconsts.nounit.T0))


@exporter.export
Expand Down Expand Up @@ -1478,7 +1488,7 @@ def vapor_pressure(pressure, mixing_ratio):

@exporter.export
@preprocess_and_wrap(wrap_like='temperature')
@process_units({'temperature': '[temperature]'}, '[pressure]')
@process_units({'temperature': '[temperature]'},'[pressure]')
def saturation_vapor_pressure(temperature):
r"""Calculate the saturation water vapor (partial) pressure.
Expand Down

0 comments on commit 5e1ac05

Please sign in to comment.