What went wrong?
I noticed some of my unit test from checking/convert between RH and dewpoint were failing in v1.71. Upon investigation, I noticed that the saturation_vapor_pressure function now implements the Ambaum formula; however, the dewpoint function "inverts the [Bolton1980]_ formula for saturation vapor pressure", causing inconsistencies.
The "code to reproduce" passes using v1.6.3 but fails for 1.7.1
Operating System
Linux
Version
1.7.1
Python Version
3.12
Code to Reproduce
import numpy as np
import xarray as xr
from metpy.calc import (
relative_humidity_from_dewpoint,
dewpoint_from_relative_humidity,
)
dim = 'dim_0'
temp = xr.DataArray(
data=[20.0, 25.0, 30.0],
dims=dim,
attrs={'units': 'degC'},
)
dew = xr.DataArray(
data=[12.0, 16.0, 20.0],
dims=dim,
attrs={'units': 'degC'},
)
rh = (
relative_humidity_from_dewpoint(temp, dew)
.metpy
.dequantify()
)
dew_test = dewpoint_from_relative_humidity(temp, rh)
np.testing.assert_almost_equal(dew_test.values, dew.values)
Errors, Traceback, and Logs
AssertionError:
Arrays are not almost equal to 7 decimals
Mismatched elements: 3 / 3 (100%)
Max absolute difference among violations: 0.01519082
Max relative difference among violations: 0.00075954
ACTUAL: array([11.9932291, 15.9904193, 19.9848092])
DESIRED: array([12., 16., 20.])
What went wrong?
I noticed some of my unit test from checking/convert between RH and dewpoint were failing in v1.71. Upon investigation, I noticed that the
saturation_vapor_pressurefunction now implements the Ambaum formula; however, thedewpointfunction "inverts the [Bolton1980]_ formula for saturation vapor pressure", causing inconsistencies.The "code to reproduce" passes using v1.6.3 but fails for 1.7.1
Operating System
Linux
Version
1.7.1
Python Version
3.12
Code to Reproduce
Errors, Traceback, and Logs