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

Psychrometric RH #345

Merged
merged 2 commits into from Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api/thermo.rst
Expand Up @@ -24,3 +24,5 @@ Thermodynamic Calculations
virtual_temperature
virtual_potential_temperature
density
relative_humidity_wet_psychrometric
psychrometric_vapor_pressure_wet
37 changes: 35 additions & 2 deletions metpy/calc/tests/test_thermo.py
Expand Up @@ -8,8 +8,9 @@

from metpy.calc import (density, dewpoint, dewpoint_rh, dry_lapse, el,
equivalent_potential_temperature, lcl, lfc, mixing_ratio, moist_lapse,
parcel_profile, potential_temperature, saturation_mixing_ratio,
saturation_vapor_pressure, vapor_pressure,
parcel_profile, potential_temperature,
psychrometric_vapor_pressure_wet, relative_humidity_wet_psychrometric,
saturation_mixing_ratio, saturation_vapor_pressure, vapor_pressure,
virtual_potential_temperature, virtual_temperature)

from metpy.testing import assert_almost_equal, assert_array_almost_equal
Expand Down Expand Up @@ -248,3 +249,35 @@ def test_no_el():
el_pressure, el_temperature = el(levels, temperatures, dewpoints)
assert el_pressure is None
assert el_temperature is None


def test_wet_psychrometric_vapor_pressure():
"""Test calculation of vapor pressure from wet and dry bulb temperatures."""
p = 1013.25 * units.mbar
dry_bulb_temperature = 20. * units.degC
wet_bulb_temperature = 18. * units.degC
psychrometric_vapor_pressure = psychrometric_vapor_pressure_wet(dry_bulb_temperature,
wet_bulb_temperature, p)
assert_almost_equal(psychrometric_vapor_pressure, 19.3673 * units.mbar, 3)


def test_wet_psychrometric_rh():
"""Test calculation of relative humidity from wet and dry bulb temperatures."""
p = 1013.25 * units.mbar
dry_bulb_temperature = 20. * units.degC
wet_bulb_temperature = 18. * units.degC
psychrometric_rh = relative_humidity_wet_psychrometric(dry_bulb_temperature,
wet_bulb_temperature, p)
assert_almost_equal(psychrometric_rh, 82.8747 * units.percent, 3)


def test_wet_psychrometric_rh_kwargs():
"""Test calculation of relative humidity from wet and dry bulb temperatures."""
p = 1013.25 * units.mbar
dry_bulb_temperature = 20. * units.degC
wet_bulb_temperature = 18. * units.degC
coeff = 6.1e-4 / units.kelvin
psychrometric_rh = relative_humidity_wet_psychrometric(dry_bulb_temperature,
wet_bulb_temperature, p,
psychrometer_coefficient=coeff)
assert_almost_equal(psychrometric_rh, 82.9701 * units.percent, 3)
100 changes: 100 additions & 0 deletions metpy/calc/thermo.py
Expand Up @@ -665,3 +665,103 @@ def density(pressure, temperature, mixing, molecular_weight_ratio=epsilon):
"""
virttemp = virtual_temperature(temperature, mixing, molecular_weight_ratio)
return (pressure / (Rd * virttemp)).to(units.kilogram / units.meter ** 3)


@exporter.export
def relative_humidity_wet_psychrometric(dry_bulb_temperature, web_bulb_temperature,
pressure, **kwargs):
r"""Calculate the relative humidity with wet bulb and dry bulb temperatures.

Parameters
----------
dry_bulb_temperature: `pint.Quantity`
Dry bulb temperature
web_bulb_temperature: `pint.Quantity`
Wet bulb temperature
pressure: `pint.Quantity`
Total atmospheric pressure

Returns
-------
`pint.Quantity`
Relative humidity

Notes
-----
.. math:: RH = 100 \frac{e}{e_s}

* :math:`RH` is relative humidity
* :math:`e` is vapor pressure from the wet psychrometric calculation
* :math:`e_s` is the saturation vapor pressure

References
----------
.. [10] WMO GUIDE TO METEOROLOGICAL INSTRUMENTS AND METHODS OF OBSERVATION WMO-No.8
(2008 edition, Updated in 2010) : PART 4
https://www.wmo.int/pages/prog/www/IMOP/CIMO-Guide.html

.. [11] Fan, Jinpeng. "Determination of the psychrometer coefficient A of the WMO
reference psychrometer by comparison with a standard gravimetric hygrometer."
Journal of Atmospheric and Oceanic Technology 4.1 (1987): 239-244.

See Also
--------
psychrometric_vapor_pressure_wet, saturation_vapor_pressure
"""
return (100 * units.percent * psychrometric_vapor_pressure_wet(dry_bulb_temperature,
web_bulb_temperature, pressure, **kwargs) /
saturation_vapor_pressure(dry_bulb_temperature))


@exporter.export
def psychrometric_vapor_pressure_wet(dry_bulb_temperature, wet_bulb_temperature, pressure,
psychrometer_coefficient=6.21e-4 / units.kelvin):
r"""Calculate the vapor pressure with wet bulb and dry bulb temperatures.

Parameters
----------
dry_bulb_temperature: `pint.Quantity`
Dry bulb temperature
web_bulb_temperature: `pint.Quantity`
Wet bulb temperature
pressure: `pint.Quantity`
Total atmospheric pressure
psychrometer coefficient: `pint.Quantity`
Psychrometer coefficient

Returns
-------
`pint.Quantity`
Vapor pressure

Notes
-----
.. math:: e' = e'_w(T_w) - A p (T - T_w)

* :math:`e'` is vapor pressure
* :math:`e'_w(T_w)` is the saturation vapor pressure with respect to water at temperature
:math:`T_w`
* :math:`p` is the pressure of the wet bulb
* :math:`T` is the temperature of the dry bulb
* :math:`T_w` is the temperature of the wet bulb
* :math:`A` is the psychrometer coefficient

Psychrometer coefficient depends on the specific instrument being used and the ventilation
of the instrument.

References
----------
.. [12] WMO GUIDE TO METEOROLOGICAL INSTRUMENTS AND METHODS OF OBSERVATION WMO-No.8
(2008 edition, Updated in 2010) : PART 4
https://www.wmo.int/pages/prog/www/IMOP/CIMO-Guide.html

.. [13] Fan, Jinpeng. "Determination of the psychrometer coefficient A of the WMO reference
psychrometer by comparison with a standard gravimetric hygrometer."
Journal of Atmospheric and Oceanic Technology 4.1 (1987): 239-244.

See Also
--------
saturation_vapor_pressure
"""
return (saturation_vapor_pressure(wet_bulb_temperature) - psychrometer_coefficient *
pressure * (dry_bulb_temperature - wet_bulb_temperature).to('kelvin'))