Skip to content

Commit 337f723

Browse files
committed
refactored tests, removed magnus_tetens, updated whatsnew
1 parent 0ae31e1 commit 337f723

File tree

3 files changed

+60
-179
lines changed

3 files changed

+60
-179
lines changed

pvlib/spectrum/magnus_tetens.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

pvlib/tests/conftest.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -474,39 +474,3 @@ def sapm_module_params():
474474
'IXXO': 3.18803,
475475
'FD': 1}
476476
return parameters
477-
478-
479-
@pytest.fixture(scope='function')
480-
def tdew_from_rh_tamb():
481-
temperature = pd.Series([20.0, 25.0, 30.0, 15.0, 10.0])
482-
return temperature
483-
484-
485-
@pytest.fixture(scope='function')
486-
def tdew_from_rh_tdew():
487-
dewpoint = pd.Series([15.0, 20.0, 25.0, 12.0, 8.0])
488-
return dewpoint
489-
490-
@pytest.fixture(scope='function')
491-
def tdew_from_rh_tdew_aekr():
492-
dewpoint = pd.Series([
493-
15.002788636614607, 20.00273293813965, 25.002679259728964,
494-
12.001714029144065, 8.0011690397714
495-
])
496-
return dewpoint
497-
498-
@pytest.fixture(scope='function')
499-
def tdew_from_rh_rh():
500-
relative_humidity = pd.Series([
501-
72.95185312581116, 73.81500029087906, 74.6401272083123,
502-
82.27063889868842, 87.39018119185337
503-
])
504-
return relative_humidity
505-
506-
@pytest.fixture(scope='function')
507-
def tdew_from_rh_rh_aekr():
508-
relative_humidity = pd.Series([
509-
72.93876680928582, 73.8025121880607, 74.62820502423823,
510-
82.26135295757305, 87.38323744820416
511-
])
512-
return relative_humidity

pvlib/tests/test_atmosphere.py

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -89,114 +89,139 @@ def test_gueymard94_pw():
8989

9090

9191
# Unit tests
92-
def test_rh_from_tdew(
93-
tdew_from_rh_tamb, tdew_from_rh_tdew,
94-
tdew_from_rh_tdew_aekr, tdew_from_rh_rh,
95-
tdew_from_rh_rh_aekr
96-
):
92+
def test_rh_from_tdew():
93+
94+
# dewpoint temp calculated with who and aekr coefficients
95+
dewpoint = pd.Series([
96+
15.0, 20.0, 25.0, 12.0, 8.0
97+
])
98+
99+
# relative humidity calculated with who and aekr coefficients
100+
relative_humidity_who = pd.Series([
101+
72.95185312581116, 73.81500029087906, 74.6401272083123,
102+
82.27063889868842, 87.39018119185337
103+
])
104+
relative_humidity_aekr = pd.Series([
105+
72.93876680928582, 73.8025121880607, 74.62820502423823,
106+
82.26135295757305, 87.38323744820416
107+
])
108+
109+
temperature_ambient = pd.Series([20.0, 25.0, 30.0, 15.0, 10.0])
97110

98111
# Calculate relative humidity using pandas series as input
99112
rh_series = atmosphere.rh_from_tdew(
100-
temperature=tdew_from_rh_tamb,
101-
dewpoint=tdew_from_rh_tdew
113+
temperature=temperature_ambient,
114+
dewpoint=dewpoint
102115
)
103116

104117
# Calulate relative humidity using pandas series as input
105118
# with AEKR coefficients
106119
rh_series_aekr = atmosphere.rh_from_tdew(
107-
temperature=tdew_from_rh_tamb,
108-
dewpoint=tdew_from_rh_tdew,
120+
temperature=temperature_ambient,
121+
dewpoint=dewpoint,
109122
coeff=(6.1094, 17.625, 243.04)
110123
)
111124

112125
# Calculate relative humidity using array as input
113126
rh_array = atmosphere.rh_from_tdew(
114-
temperature=tdew_from_rh_tamb.to_numpy(),
115-
dewpoint=tdew_from_rh_tdew.to_numpy()
127+
temperature=temperature_ambient.to_numpy(),
128+
dewpoint=dewpoint.to_numpy()
116129
)
117130

118131
# Calculate relative humidity using float as input
119132
rh_float = atmosphere.rh_from_tdew(
120-
temperature=tdew_from_rh_tamb.iloc[0],
121-
dewpoint=tdew_from_rh_tdew.iloc[0]
133+
temperature=temperature_ambient.iloc[0],
134+
dewpoint=dewpoint.iloc[0]
122135
)
123136

124137
# test
125138
pd.testing.assert_series_equal(
126139
rh_series,
127-
tdew_from_rh_rh,
140+
relative_humidity_who,
128141
check_names=False
129142
)
130143

131144
pd.testing.assert_series_equal(
132145
rh_series_aekr,
133-
tdew_from_rh_rh_aekr,
146+
relative_humidity_aekr,
134147
check_names=False
135148
)
136149

137150
np.testing.assert_allclose(
138151
rh_array,
139-
tdew_from_rh_rh.to_numpy(),
152+
relative_humidity_who.to_numpy(),
140153
atol=0.001
141154
)
142155

143156
assert np.isclose(
144157
rh_float,
145-
tdew_from_rh_rh.iloc[0]
158+
relative_humidity_who.iloc[0]
146159
)
147160

148161

149162
# Unit tests
150-
def test_tdew_from_rh(
151-
tdew_from_rh_tamb, tdew_from_rh_tdew,
152-
tdew_from_rh_rh, tdew_from_rh_rh_aekr,
153-
tdew_from_rh_tdew_aekr
154-
):
163+
def test_tdew_from_rh():
164+
165+
# dewpoint temp calculated with who and aekr coefficients
166+
dewpoint = pd.Series([
167+
15.0, 20.0, 25.0, 12.0, 8.0
168+
])
169+
170+
# relative humidity calculated with who and aekr coefficients
171+
relative_humidity_who = pd.Series([
172+
72.95185312581116, 73.81500029087906, 74.6401272083123,
173+
82.27063889868842, 87.39018119185337
174+
])
175+
relative_humidity_aekr = pd.Series([
176+
72.93876680928582, 73.8025121880607, 74.62820502423823,
177+
82.26135295757305, 87.38323744820416
178+
])
179+
180+
temperature_ambient = pd.Series([20.0, 25.0, 30.0, 15.0, 10.0])
155181

156182
# test as series
157183
dewpoint_series = atmosphere.tdew_from_rh(
158-
temperature=tdew_from_rh_tamb,
159-
relative_humidity=tdew_from_rh_rh
184+
temperature=temperature_ambient,
185+
relative_humidity=relative_humidity_who
160186
)
161187

162188
# test as series with AEKR coefficients
163189
dewpoint_series_aekr = atmosphere.tdew_from_rh(
164-
temperature=tdew_from_rh_tamb,
165-
relative_humidity=tdew_from_rh_rh,
190+
temperature=temperature_ambient,
191+
relative_humidity=relative_humidity_aekr,
166192
coeff=(6.1094, 17.625, 243.04)
167193
)
168194

169195
# test as numpy array
170196
dewpoint_array = atmosphere.tdew_from_rh(
171-
temperature=tdew_from_rh_tamb.to_numpy(),
172-
relative_humidity=tdew_from_rh_rh.to_numpy()
197+
temperature=temperature_ambient.to_numpy(),
198+
relative_humidity=relative_humidity_who.to_numpy()
173199
)
174200

175201
# test as float
176202
dewpoint_float = atmosphere.tdew_from_rh(
177-
temperature=tdew_from_rh_tamb.iloc[0],
178-
relative_humidity=tdew_from_rh_rh.iloc[0]
203+
temperature=temperature_ambient.iloc[0],
204+
relative_humidity=relative_humidity_who.iloc[0]
179205
)
180206

181207
# test
182208
pd.testing.assert_series_equal(
183-
dewpoint_series, tdew_from_rh_tdew, check_names=False
209+
dewpoint_series, dewpoint, check_names=False
184210
)
185211

186212
pd.testing.assert_series_equal(
187-
dewpoint_series_aekr, tdew_from_rh_tdew_aekr,
213+
dewpoint_series_aekr, dewpoint,
188214
check_names=False
189215
)
190216

191217
np.testing.assert_allclose(
192218
dewpoint_array,
193-
tdew_from_rh_tdew.to_numpy(),
194-
atol=0.001
219+
dewpoint.to_numpy(),
195220
)
196221

197222
assert np.isclose(
198223
dewpoint_float,
199-
tdew_from_rh_tdew.iloc[0]
224+
dewpoint.iloc[0]
200225
)
201226

202227

0 commit comments

Comments
 (0)