@@ -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