@@ -82,47 +82,121 @@ def test_gueymard94_pw():
8282    pws  =  atmosphere .gueymard94_pw (temps_humids [:, 0 ], temps_humids [:, 1 ])
8383
8484    expected  =  np .array (
85-         [0.1        ,   0.33702061 ,   1.12340202 ,   0.1        ,
85+         [   0.1        ,   0.33702061 ,   1.12340202 ,   0.1        ,
8686         1.12040963 ,   3.73469877 ,   0.1        ,   3.44859767 ,  11.49532557 ])
8787
8888    assert_allclose (pws , expected , atol = 0.01 )
8989
9090
9191# Unit tests 
9292def  test_rh_from_tdew (
93-     tdew_rh_conversion_temperature , tdew_rh_conversion_dewpoint ,
94-     tdew_rh_conversion_relative_humidity 
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 
9596):
9697
97-     # Calculate relative humidity 
98-     rh  =  atmosphere .rh_from_tdew (
99-         temperature = tdew_rh_conversion_temperature ,
100-         dewpoint = tdew_rh_conversion_dewpoint 
98+     # Calculate relative humidity using pandas series as input 
99+     rh_series  =  atmosphere .rh_from_tdew (
100+         temperature = tdew_from_rh_tamb ,
101+         dewpoint = tdew_from_rh_tdew 
102+     )
103+ 
104+     # Calulate relative humidity using pandas series as input 
105+     # with AEKR coefficients 
106+     rh_series_aekr  =  atmosphere .rh_from_tdew (
107+         temperature = tdew_from_rh_tamb ,
108+         dewpoint = tdew_from_rh_tdew ,
109+         coeff = (6.1094 , 17.625 , 243.04 )
110+     )
111+ 
112+     # Calculate relative humidity using array as input 
113+     rh_array  =  atmosphere .rh_from_tdew (
114+         temperature = tdew_from_rh_tamb .to_numpy (),
115+         dewpoint = tdew_from_rh_tdew .to_numpy ()
116+     )
117+ 
118+     # Calculate relative humidity using float as input 
119+     rh_float  =  atmosphere .rh_from_tdew (
120+         temperature = tdew_from_rh_tamb .iloc [0 ],
121+         dewpoint = tdew_from_rh_tdew .iloc [0 ]
101122    )
102123
103124    # test 
104125    pd .testing .assert_series_equal (
105-         rh ,
106-         tdew_rh_conversion_relative_humidity ,
126+         rh_series ,
127+         tdew_from_rh_rh ,
128+         check_names = False 
129+     )
130+ 
131+     pd .testing .assert_series_equal (
132+         rh_series_aekr ,
133+         tdew_from_rh_rh_aekr ,
107134        check_names = False 
108135    )
109136
137+     np .testing .assert_allclose (
138+         rh_array ,
139+         tdew_from_rh_rh .to_numpy (),
140+         atol = 0.001 
141+     )
142+ 
143+     assert  np .isclose (
144+         rh_float ,
145+         tdew_from_rh_rh .iloc [0 ]
146+     )
147+ 
110148
111149# Unit tests 
112150def  test_tdew_from_rh (
113-     tdew_rh_conversion_temperature , tdew_rh_conversion_dewpoint ,
114-     tdew_rh_conversion_relative_humidity 
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 
115154):
116155
117-     # Calculate relative humidity 
118-     dewpoint  =  atmosphere .tdew_from_rh (
119-         temperature = tdew_rh_conversion_temperature ,
120-         relative_humidity = tdew_rh_conversion_relative_humidity 
156+     # test as series 
157+     dewpoint_series  =  atmosphere .tdew_from_rh (
158+         temperature = tdew_from_rh_tamb ,
159+         relative_humidity = tdew_from_rh_rh 
160+     )
161+ 
162+     # test as series with AEKR coefficients 
163+     dewpoint_series_aekr  =  atmosphere .tdew_from_rh (
164+         temperature = tdew_from_rh_tamb ,
165+         relative_humidity = tdew_from_rh_rh ,
166+         coeff = (6.1094 , 17.625 , 243.04 )
167+     )
168+ 
169+     # test as numpy array 
170+     dewpoint_array  =  atmosphere .tdew_from_rh (
171+         temperature = tdew_from_rh_tamb .to_numpy (),
172+         relative_humidity = tdew_from_rh_rh .to_numpy ()
173+     )
174+ 
175+     # test as float 
176+     dewpoint_float  =  atmosphere .tdew_from_rh (
177+         temperature = tdew_from_rh_tamb .iloc [0 ],
178+         relative_humidity = tdew_from_rh_rh .iloc [0 ]
121179    )
122180
123181    # test 
124182    pd .testing .assert_series_equal (
125-         dewpoint , dewpoint , check_names = False 
183+         dewpoint_series , tdew_from_rh_tdew , check_names = False 
184+     )
185+ 
186+     pd .testing .assert_series_equal (
187+         dewpoint_series_aekr , tdew_from_rh_tdew_aekr ,
188+         check_names = False 
189+     )
190+ 
191+     np .testing .assert_allclose (
192+         dewpoint_array ,
193+         tdew_from_rh_tdew .to_numpy (),
194+         atol = 0.001 
195+     )
196+ 
197+     assert  np .isclose (
198+         dewpoint_float ,
199+         tdew_from_rh_tdew .iloc [0 ]
126200    )
127201
128202
0 commit comments