#%reset
import pandas as pd
import TOU_pricing
import numpy as np
#reload(TOU_pricing)
gray_light = '#bbbbbb'
gray_med = '#737373'
red_orange = '#ff3700'
my_demand_new = pd.read_csv('raw_data/new_apt_demand_thru_july2014.csv',index_col='timestamp',parse_dates=True)
my_demand_old = pd.read_csv('raw_data/old_apt_demand.csv',index_col='timestamp',parse_dates=True)
green_button_sample = pd.read_csv('raw_data/Green_Button_Sample_Inland_SingleFamily.csv',index_col='timestamp',parse_dates=True)
my_demand = my_demand_old.append(my_demand_new)
my_demand_cost = TOU_pricing.BGE_elec_cost(my_demand)
green_button_sample_cost = TOU_pricing.BGE_elec_cost(green_button_sample)
my_demand_cost['BGE-R_cost'] = my_demand_cost['USAGE'] * my_demand_cost['BGE-R_cost_perkWh']
my_demand_cost['BGE-RL_cost'] = my_demand_cost['USAGE'] * my_demand_cost['BGE-RL_cost_perkWh']
my_demand_cost['BGE-EV_cost'] = my_demand_cost['USAGE'] * my_demand_cost['BGE-EV_cost_perkWh']
green_button_sample_cost['BGE-R_cost'] = green_button_sample_cost['USAGE'] * green_button_sample_cost['BGE-R_cost_perkWh']
green_button_sample_cost['BGE-RL_cost'] = green_button_sample_cost['USAGE'] * green_button_sample_cost['BGE-RL_cost_perkWh']
green_button_sample_cost['BGE-EV_cost'] = green_button_sample_cost['USAGE'] * green_button_sample_cost['BGE-EV_cost_perkWh']
month = 'jul-2014'
print 'Total usage:', round(sum(my_demand_cost['USAGE'].ix[month]),2),'kWh \n'
print 'R total: $', round(sum(my_demand_cost['USAGE'].ix[month] * my_demand_cost['BGE-R_cost_perkWh'].ix[month]),2)
print 'RL total: $', round(sum(my_demand_cost['USAGE'].ix[month] * my_demand_cost['BGE-RL_cost_perkWh'].ix[month]),2)
print 'EV total: $', round(sum(my_demand_cost['USAGE'].ix[month] * my_demand_cost['BGE-EV_cost_perkWh'].ix[month]),2)
Total usage: 671.6 kWh R total: $ 57.87 RL total: $ 54.38 EV total: $ 47.31
jul_elec_bill = 93.49
print round(sum(my_demand_cost['USAGE'].ix['jul-2014'] * my_demand_cost['BGE-R_cost_perkWh'].ix['jul-2014']),2)/jul_elec_bill
0.618996684137
my_monthly_diffs = pd.DataFrame(np.zeros((7,3)),columns=['R-RL','R-EV','USAGE'],index=[1,2,3,4,5,6,7])
my_monthly_diffs['R-RL'] = my_demand_cost['BGE-R_cost'].groupby(my_demand_cost.index.month).sum()-my_demand_cost['BGE-RL_cost'].groupby(my_demand_cost.index.month).sum()
my_monthly_diffs['R-EV'] = my_demand_cost['BGE-R_cost'].groupby(my_demand_cost.index.month).sum()-my_demand_cost['BGE-EV_cost'].groupby(my_demand_cost.index.month).sum()
my_monthly_diffs['USAGE'] = my_demand_cost['USAGE'].groupby(my_demand_cost.index.month).sum()
my_monthly_diffs.index = ['Jan','Feb','Mar','Apr','May','Jun','Jul']
my_monthly_diffs = my_monthly_diffs.drop(['May'])
my_monthly_diffs[:10]
R-RL | R-EV | USAGE | |
---|---|---|---|
Jan | 1.216777 | 1.456228 | 787.34 |
Feb | 1.812211 | 2.080608 | 1086.16 |
Mar | 0.972739 | 1.036178 | 641.49 |
Apr | 0.047755 | -0.440503 | 195.86 |
Jun | 2.626015 | 8.097076 | 636.66 |
Jul | 3.481570 | 10.552970 | 671.60 |
print sum(my_monthly_diffs['R-RL'])
print sum(my_monthly_diffs['R-EV'])
10.1570672 22.7825565
width = .4
ind = np.arange(len(my_monthly_diffs['R-EV']))+1
fig, ax = plt.subplots(figsize=[4,4])
ax.barh(ind,my_monthly_diffs['R-EV'],width,color=red_orange,label='EV')
ax.barh(ind+width,my_monthly_diffs['R-RL'],width,color=gray_light,label='RL')
ax.set_yticks(ind+width)
ax.set_yticklabels(my_monthly_diffs.index)
xlim([-2,12])
ylim([min(ind)-width,max(ind)+3*width])
title('Cost Savings on BGE Electricity Bill, My Usage \n Compared to Residential "R" Plan')
xlabel('Cost Saved (USD)')
legend(loc='lower right')
subplots_adjust(top=.85)
fig.savefig('plots/My_Cost_Savings_TOU_Pricing.png')
gb_monthly_diffs = pd.DataFrame(np.zeros((12,3)),columns=['R-RL','R-EV','USAGE'],index=[1,2,3,4,5,6,7,8,9,10,11,12])
gb_monthly_diffs['R-RL'] = green_button_sample_cost['BGE-R_cost'].groupby(green_button_sample_cost.index.month).sum()-green_button_sample_cost['BGE-RL_cost'].groupby(green_button_sample_cost.index.month).sum()
gb_monthly_diffs['R-EV'] = green_button_sample_cost['BGE-R_cost'].groupby(green_button_sample_cost.index.month).sum()-green_button_sample_cost['BGE-EV_cost'].groupby(green_button_sample_cost.index.month).sum()
gb_monthly_diffs['USAGE'] = green_button_sample_cost['USAGE'].groupby(green_button_sample_cost.index.month).sum()
gb_monthly_diffs.index = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
width = .4
ind = np.arange(len(gb_monthly_diffs['R-EV']))+1
fig, ax = plt.subplots(figsize=[4,8])
ax.barh(ind,gb_monthly_diffs['R-EV'],width,color=red_orange,label='EV')
ax.barh(ind+width,gb_monthly_diffs['R-RL'],width,color=gray_light,label='RL')
ax.set_yticks(ind+width)
ax.set_yticklabels(gb_monthly_diffs.index)
xlim([-2,12])
ylim([min(ind)-width,max(ind)+3*width])
title('Cost Savings on BGE Electricity Bill \n Green Button Sample \n Compared to Residential "R" Plan')
xlabel('Cost Saved (USD)')
legend(loc='lower right')
subplots_adjust(top=.9)
fig.savefig('plots/GB_Cost_Savings_TOU_Pricing.png')
print 'Annual Usage:', round(sum(gb_monthly_diffs['USAGE']),1),'kWh'
print 'Annual Cost Savings: $',round(sum(gb_monthly_diffs['R-RL']),2)
print 'Annual Cost Savings: $',round(sum(gb_monthly_diffs['R-EV']),2)
Annual Usage: 8343.3 kWh Annual Cost Savings: $ 27.23 Annual Cost Savings: $ 60.25
fig = plt.figure()
#plot2 = gb_monthly_diffs['USAGE'].plot(marker='o')
plot1 = my_monthly_diffs['USAGE'].plot(marker='o')