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
5 changes: 2 additions & 3 deletions pvanalytics/features/orientation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Functions for identifying system orientation."""
import pandas as pd
from pandas.tseries import frequencies
from pvanalytics.util import _fit, _group


Expand Down Expand Up @@ -55,9 +56,7 @@ def _conditional_fit(day, minutes, fitfunc, freq, default=0.0, min_hours=0.0,

def _freqstr_to_hours(freq):
# Convert pandas freqstr to hours (as a float)
if freq.isalpha():
freq = '1' + freq
return pd.to_timedelta(freq).seconds / 60
return pd.to_timedelta(frequencies.to_offset(freq)).seconds / 3600


def _hours(data, freq):
Expand Down
6 changes: 6 additions & 0 deletions pvanalytics/tests/features/test_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ def test_stuck_tracker_profile(solarposition, clearsky):
poa['poa_global'],
solarposition['zenith'] < 70
).all()


def test_frequency_to_hours():
assert orientation._freqstr_to_hours('H') == 1.0
assert orientation._freqstr_to_hours('15T') == 0.25
assert orientation._freqstr_to_hours('2H') == 2.0