Skip to content

Commit

Permalink
better API and actually fix meter costs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomastu committed Apr 10, 2020
1 parent 3304c1e commit 418bbce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ubc"
version = "0.0.3"
version = "0.0.4"
description = "Utility Bill Calculator"
authors = ["Thomas Tu <[email protected]>"]

Expand Down
14 changes: 10 additions & 4 deletions ubc/calculator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from ubc.rates.openei.api import RateSchedule
from dataclasses import dataclass
from pandas import Timedelta

from ubc.rates.openei.api import RateSchedule


DELTA_HOUR = Timedelta("1 hour")


@dataclass
Expand Down Expand Up @@ -113,14 +118,15 @@ def calculate_meter_charges(self, load):
cost = num_days*self.schedule.meter
return cost.rename("cost")

def calculate_total(self, load_kw, interval=1):
def calculate_total(self, load_kw):
"""
Args:
load_kw (pd.Series): timestamp series of demand data.
interval (float): Fraction of an hour for timestamp.
"""

interval = load_kw.index.freq.delta / DELTA_HOUR
energy_charges = self.calculate_energy_charges(load_kw*interval)["cost"].resample("M").sum()
demand_charges = self.calculate_demand_charges(load_kw)["cost"].sum(axis=1)
flatdemand_charges = self.calculate_flatdemand_charges(load_kw)["cost"]
meter_charges = self.calculate_meter_charges(load_kw)["cost"]
meter_charges = self.calculate_meter_charges(load_kw)
return (meter_charges + energy_charges + demand_charges + flatdemand_charges).rename("total_cost")
3 changes: 3 additions & 0 deletions ubc/rates/openei/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .api import RateSchedule as OpenEI

__all__ = ["OpenEI"]

0 comments on commit 418bbce

Please sign in to comment.