Skip to content

Commit

Permalink
load factor analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JrtPec committed Apr 9, 2018
1 parent e3fe417 commit 260e5a0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions opengrid/library/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,33 @@ def count_peaks(ts):
result = on_toggles & shifted
count = result.sum()
return count


def load_factor(ts, resolution=None, norm=None):
"""
Calculate the ratio of input vs. norm over a given interval.
Parameters
----------
ts : Pandas Series
timeseries
resolution : str, optional
interval over which to calculate the ratio
default: resolution of the input timeseries
norm : int | float, optional
denominator of the ratio
default: the maximum of the input timeseries
Returns
-------
Pandas Series
"""
if norm is None:
norm = ts.max()

if resolution is not None:
ts = ts.resample(rule=resolution).mean()

lf = ts/norm

return lf

0 comments on commit 260e5a0

Please sign in to comment.