def test_fuentes(filename, inoct): # Test against data exported from pvwatts.nrel.gov data = _read_pvwatts_8760(DATA_DIR / filename) data = data.iloc[:24*7, :] # just use one week inputs = { 'poa_global': data['Plane of Array Irradiance (W/m^2)'], 'temp_air': data['Ambient Temperature (C)'], 'wind_speed': data['Wind Speed (m/s)'], 'noct_installed': inoct, } expected_tcell = data['Cell Temperature (C)'] expected_tcell.name = 'tmod' actual_tcell = temperature.fuentes(**inputs) # the SSC implementation of PVWatts diverges from the Fuentes model at # at night by setting Tcell=Tamb when POA=0. This not only means that # nighttime values are slightly different (Fuentes models cooling to sky # at night), but because of the thermal inertia, there is a transient # error after dawn as well. Test each case separately: is_night = inputs['poa_global'] == 0 is_dawn = is_night.shift(1) & ~is_night is_daytime = (inputs['poa_global'] > 0) & ~is_dawn # the accuracy is probably higher than 3 digits here, but the PVWatts # export data has low precision so can only test up to 3 digits assert_series_equal(expected_tcell[is_daytime].round(3), actual_tcell[is_daytime].round(3)) # use lower precision for dawn times to accommodate the dawn transient error = actual_tcell[is_dawn] - expected_tcell[is_dawn] assert (error.abs() < 0.1).all() # sanity check on night values -- Fuentes not much lower than PVWatts night_difference = expected_tcell[is_night] - actual_tcell[is_night] assert night_difference.max() < 6 assert night_difference.min() > 0
def test_fuentes_timezone(tz): index = pd.date_range('2019-01-01', freq='h', periods=3, tz=tz) df = pd.DataFrame({'poa_global': 1000, 'temp_air': 20, 'wind_speed': 1}, index) out = temperature.fuentes(df['poa_global'], df['temp_air'], df['wind_speed'], noct_installed=45) assert_series_equal(out, pd.Series([47.85, 50.85, 50.85], index=index, name='tmod'))