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 25, 2024
1 parent 818ece7 commit 3659a11
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 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 K**-1 kg**-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 @@ -62,13 +64,15 @@ def moist_air_gas_constant(specific_humidity):
Eq 16, [Romps2017]_ using MetPy-defined constants in place of cited values.
"""
return ((1 - specific_humidity) * mpconsts.dry_air_gas_constant
+ specific_humidity * mpconsts.water_gas_constant)
return ((1 - specific_humidity) * mpconsts.nounit.Rd
+ specific_humidity * mpconsts.nounit.Rv)


@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 K**-1 kg**-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 @@ -99,13 +103,15 @@ def moist_air_specific_heat_pressure(specific_humidity):
Eq 17, [Romps2017]_ using MetPy-defined constants in place of cited values.
"""
return ((1 - specific_humidity) * mpconsts.dry_air_spec_heat_press
+ specific_humidity * mpconsts.wv_specific_heat_press)
return ((1 - specific_humidity) * mpconsts.nounit.Cp_d
+ specific_humidity * mpconsts.nounit.Cp_v)


@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

0 comments on commit 3659a11

Please sign in to comment.