Skip to content

Commit 1eff53f

Browse files
committed
added a round-trip test for magnus tetens
Added a new test to show that you can calculate relative humidity from dewpoint and then calculate dewpoint from relative humidity and it will be the same as the original dewpoint values
1 parent 25527d6 commit 1eff53f

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

pvlib/tests/test_atmosphere.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,34 @@ def test_gueymard94_pw():
8888
assert_allclose(pws, expected, atol=0.01)
8989

9090

91-
# Unit tests
91+
def test_tdew_to_rh_to_tdew():
92+
93+
# dewpoint temp calculated with who and aekr coefficients
94+
dewpoint_original = pd.Series([
95+
15.0, 20.0, 25.0, 12.0, 8.0
96+
])
97+
98+
temperature_ambient = pd.Series([20.0, 25.0, 30.0, 15.0, 10.0])
99+
100+
# Calculate relative humidity using pandas series as input
101+
relative_humidity = atmosphere.rh_from_tdew(
102+
temperature=temperature_ambient,
103+
dewpoint=dewpoint_original
104+
)
105+
106+
dewpoint_calculated = atmosphere.tdew_from_rh(
107+
temperature=temperature_ambient,
108+
relative_humidity=relative_humidity
109+
)
110+
111+
# test
112+
pd.testing.assert_series_equal(
113+
dewpoint_original,
114+
dewpoint_calculated,
115+
check_names=False
116+
)
117+
118+
92119
def test_rh_from_tdew():
93120

94121
# dewpoint temp calculated with who and aekr coefficients
@@ -128,12 +155,6 @@ def test_rh_from_tdew():
128155
dewpoint=dewpoint.to_numpy()
129156
)
130157

131-
# Calculate relative humidity using float as input
132-
rh_float = atmosphere.rh_from_tdew(
133-
temperature=temperature_ambient.iloc[0],
134-
dewpoint=dewpoint.iloc[0]
135-
)
136-
137158
# test
138159
pd.testing.assert_series_equal(
139160
rh_series,
@@ -152,6 +173,12 @@ def test_rh_from_tdew():
152173
relative_humidity_who.to_numpy(),
153174
)
154175

176+
# Calculate relative humidity using float as input
177+
rh_float = atmosphere.rh_from_tdew(
178+
temperature=temperature_ambient.iloc[0],
179+
dewpoint=dewpoint.iloc[0]
180+
)
181+
155182
assert np.isclose(
156183
rh_float,
157184
relative_humidity_who.iloc[0]

0 commit comments

Comments
 (0)