Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/sphinx/source/whatsnew/v0.8.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Enhancements

Bug fixes
~~~~~~~~~

* Fix issue with :py:func:`pvlib.temperature.fuentes` with timezone-aware
inputs. (:issue:`1071`, :pull:`1072`)

Testing
~~~~~~~
Expand Down
5 changes: 3 additions & 2 deletions pvlib/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,9 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
# n.b. the way Fuentes calculates the first timedelta makes it seem like
# the value doesn't matter -- rather than recreate it here, just assume
# it's the same as the second timedelta:
timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
timedelta_hours = np.append([timedelta_hours[0]], timedelta_hours)
timedelta_seconds = poa_global.index.to_series().diff().dt.total_seconds()
timedelta_hours = timedelta_seconds / 3600
timedelta_hours.iloc[0] = timedelta_hours.iloc[1]

tamb_array = temp_air + 273.15
sun_array = poa_global * absorp
Expand Down
14 changes: 14 additions & 0 deletions pvlib/tests/test_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,17 @@ def test_fuentes(filename, inoct):
night_difference = expected_tcell[is_night] - actual_tcell[is_night]
assert night_difference.max() < 6
assert night_difference.min() > 0


@pytest.mark.parametrize('tz', [None, 'Etc/GMT+5'])
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'))