|
5 | 5 | from conftest import DATA_DIR, assert_series_equal
|
6 | 6 | from numpy.testing import assert_allclose
|
7 | 7 |
|
8 |
| -from pvlib import temperature |
| 8 | +from pvlib import temperature, location, irradiance, iam |
9 | 9 |
|
10 | 10 |
|
11 | 11 | @pytest.fixture
|
@@ -206,5 +206,56 @@ def test__calculate_radiative_heat():
|
206 | 206 |
|
207 | 207 | def test_hayes():
|
208 | 208 | # TODO placeholder until final model is validated
|
209 |
| - pass |
210 | 209 |
|
| 210 | + # simulate psm3 data |
| 211 | + data_psm3 = [ |
| 212 | + {'Latitude': 39.66, 'Longitude': -105.207}, |
| 213 | + pd.DataFrame( |
| 214 | + data={ |
| 215 | + 'DNI': [0, 163, 133, 189], |
| 216 | + 'DHI': [0, 4, 12, 16], |
| 217 | + 'GHI': [0, 7, 16, 25], |
| 218 | + 'Temperature': [-13.2, -13.1, -13.1, -13], |
| 219 | + 'Wind Speed': [1.6, 1.7, 1.7, 1.7] |
| 220 | + }, |
| 221 | + index=pd.date_range('2019-01-01 07:25:00', |
| 222 | + '2019-01-01 07:40:00', |
| 223 | + freq='5min') |
| 224 | + ) |
| 225 | + ] |
| 226 | + |
| 227 | + # data preparation |
| 228 | + module_tilt = 30 |
| 229 | + module_azimuth = 180 |
| 230 | + site = location.Location( |
| 231 | + latitude=data_psm3[0]['Latitude'], |
| 232 | + longitude=data_psm3[0]['Longitude'], |
| 233 | + tz='MST' |
| 234 | + ) |
| 235 | + solar_position = site.get_solarposition(times=data_psm3[1].index) |
| 236 | + poa_global = irradiance.get_total_irradiance( |
| 237 | + surface_tilt=module_tilt, |
| 238 | + surface_azimuth=module_azimuth, |
| 239 | + dni=data_psm3[1]['DNI'], |
| 240 | + ghi=data_psm3[1]['GHI'], |
| 241 | + dhi=data_psm3[1]['DHI'], |
| 242 | + solar_zenith=solar_position['apparent_zenith'], |
| 243 | + solar_azimuth=solar_position['azimuth'] |
| 244 | + )['poa_global'] |
| 245 | + temp_air = data_psm3[1]['Temperature'] |
| 246 | + wind_speed = data_psm3[1]['Wind Speed'] |
| 247 | + |
| 248 | + # 1. Calculate module temp with new model |
| 249 | + aoi = irradiance.aoi(module_tilt, module_azimuth, |
| 250 | + solar_position['zenith'], |
| 251 | + solar_position['azimuth']) |
| 252 | + poa_effective = poa_global.multiply(iam.ashrae(aoi)) |
| 253 | + module_efficiency = 0.176 |
| 254 | + module_area = 2.47 # m^2 |
| 255 | + module_weight = 34.5 |
| 256 | + tmod_hayes = temperature.hayes(poa_effective, temp_air, wind_speed, |
| 257 | + module_efficiency, module_area, |
| 258 | + module_weight, module_tilt) |
| 259 | + |
| 260 | + assert [round(t, 2) for t in tmod_hayes.values] == \ |
| 261 | + [-13.20, -7.81, -8.98, -9.85] |
0 commit comments