-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresults.py
348 lines (269 loc) · 20.3 KB
/
results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import pandas as pd
import os
class Results():
def __init__(self, time_periods, participant_ids):
# Make empty df to store energy calcs
self.energy_output = {
"df_net_export" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_network_energy_flows" : pd.DataFrame(0,index = time_periods, columns=['net_participant_export', 'central_battery_export', 'unallocated_local_solar', 'unallocated_central_battery_load','gross_participant_grid_import','gross_participant_local_solar_import','gross_participant_central_battery_import']),
"df_local_solar_import" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_participant_central_batt_import" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_local_solar_sales" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_central_batt_solar_sales" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_export_to_grid_solar_sales" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_external_grid_elec_import": pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids])
}
self.financial_output = {
"df_participant_variable_charge" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_local_solar_import_charge" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_central_batt_import_charge" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_local_solar_sales_revenue" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_central_batt_solar_sales_revenue" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_export_to_grid_solar_sales_revenue" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_fixed_charge" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_total_participant_bill" : pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
# The df_participant_duos_payments df contains the amount paid by each participant in DUOS charges. This is summed to find the DNSP variable revenue from grid import
"df_participant_duos_payments": pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_participant_tuos_payments": pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
# Where nuos = duos + tuos + green scheme stuff
"df_participant_nuos_payments": pd.DataFrame(0,index = time_periods, columns=[p for p in participant_ids]),
"df_dnsp_revenue" : pd.DataFrame(0,index = time_periods, columns=['grid_import_revenue_fixed','grid_import_revenue_variable','local_solar_import_revenue','central_battery_import_revenue','total_revenue']),
"df_tnsp_revenue" : pd.DataFrame(0,index = time_periods, columns=['grid_import_revenue_fixed','grid_import_revenue_variable','local_solar_import_revenue','central_battery_import_revenue','total_revenue']),
"df_nuos_revenue" : pd.DataFrame(0,index = time_periods, columns=['grid_import_revenue_fixed','grid_import_revenue_variable','local_solar_import_revenue','central_battery_import_revenue','total_revenue']),
"df_retailer_revenue" : pd.DataFrame(0,index = time_periods, columns=['grid_import_revenue_fixed','grid_import_revenue_variable','local_solar_import_revenue','central_battery_import_revenue','total_revenue']),
"df_retailer_fit_payments" : pd.DataFrame(0,index = time_periods, columns=['solar_fit_payments',]),
"df_central_battery_revenue" : pd.DataFrame(0,index = time_periods, columns=['central_battery_revenue'])
}
def to_csv(self, output_dir, info_tag):
info_tag = str(info_tag)
for label in self.financial_output:
print label
self.financial_output[label].to_csv(path_or_buf=os.path.join(output_dir, label+info_tag+".csv"))
for label in self.energy_output:
print label
self.energy_output[label].to_csv(path_or_buf=os.path.join(output_dir, label+info_tag+".csv"))
def to_dict(self):
new_financial_output = {}
for key in self.financial_output:
new_financial_output[key]=[]
for date, row in self.financial_output[key].T.iteritems():
row_dict = {'dt_str':str(date)}
for col_header in financial_output[key]:
row_dict[col_header] = float(row[col_header]) if not pd.isnull(row[col_header]) else 0
new_financial_output[key].append(row_dict)
# print col_header+": "+str(row[col_header])
new_energy_output = {}
for key in self.energy_output:
new_energy_output[key]=[]
for date, row in self.energy_output[key].T.iteritems():
row_dict = {'dt_str':str(date)}
for col_header in energy_output[key]:
row_dict[col_header] = float(row[col_header]) if not pd.isnull(row[col_header]) else 0
# print col_header+": "+str(row[col_header])
new_energy_output[key].append(row_dict)
return {'financial_output':new_financial_output, 'energy_output': new_energy_output}
def set_net_export(self, time, participant_id, value):
self.energy_output['df_net_export'].loc[time,participant_id] = value
def get_net_export(self, time, participant_id):
return self.energy_output['df_net_export'].loc[time,participant_id]
# NOTE there was a typo here where we werent setting it to participant id but the actual participant object. might have been causing an issue.
# If differences come out in results, I'd suggest this might have been a cause
# To test that, try passing the participant object in the participant id spot and see if it makes a difference.
def set_local_solar_import(self, time, participant_id, value):
self.energy_output["df_local_solar_import"].loc[time, participant_id] = value
def get_local_solar_import(self, time, participant_id):
return self.energy_output["df_local_solar_import"].loc[time, participant_id]
# NOTE there was a typo here where we werent setting it to participant id but the actual participant object. might have been causing an issue.
# If differences come out in results, I'd suggest this might have been a cause
# To test that, try passing the participant object in the participant id spot and see if it makes a difference.
def set_participant_central_batt_import(self, time, participant_id, value):
self.energy_output["df_participant_central_batt_import"].loc[time, participant_id] = value
def get_participant_central_batt_import(self, time, participant_id):
return self.energy_output["df_participant_central_batt_import"].loc[time, participant_id]
# NOTE there was a typo here where we werent setting it to participant id but the actual participant object. might have been causing an issue.
# If differences come out in results, I'd suggest this might have been a cause
# To test that, try passing the participant object in the participant id spot and see if it makes a difference.
def set_local_solar_sales(self, time, participant_id, value):
self.energy_output["df_local_solar_sales"].loc[time, participant_id] = value
def get_local_solar_sales(self, time, participant_id):
return self.energy_output["df_local_solar_sales"].loc[time, participant_id]
# NOTE there was a typo here where we werent setting it to participant id but the actual participant object. might have been causing an issue.
# If differences come out in results, I'd suggest this might have been a cause
# To test that, try passing the participant object in the participant id spot and see if it makes a difference.
def set_central_batt_solar_sales(self, time, participant_id, value):
self.energy_output["df_central_batt_solar_sales"].loc[time, participant_id] = value
def get_central_batt_solar_sales(self, time, participant_id):
return self.energy_output["df_central_batt_solar_sales"].loc[time, participant_id]
def set_export_to_grid_solar_sales(self, time, participant_id, value):
self.energy_output["df_export_to_grid_solar_sales"].loc[time,participant_id] = value
def get_export_to_grid_solar_sales(self, time, participant_id,):
return self.energy_output["df_export_to_grid_solar_sales"].loc[time,participant_id]
def set_external_grid_elec_import(self, time, participant_id, value):
self.energy_output["df_external_grid_elec_import"].loc[time,participant_id] = value
def get_external_grid_elec_import(self, time, participant_id):
return self.energy_output["df_external_grid_elec_import"].loc[time,participant_id]
# 'Network Energy Flows'
def set_net_participant_export(self, time, value):
self.energy_output['df_network_energy_flows'].loc[time, 'net_participant_export'] = value
def get_net_participant_export(self, time):
return self.energy_output['df_network_energy_flows'].loc[time, 'net_participant_export']
def set_central_battery_export(self, time, value):
self.energy_output['df_network_energy_flows'].loc[time, 'central_battery_export'] = value
def get_central_battery_export(self, time):
return self.energy_output['df_network_energy_flows'].loc[time, 'central_battery_export']
# TODO I think this should be labelled import, as our convention is normally subject -> action with the action as positive.
def set_net_network_export(self, time, value):
self.energy_output['df_network_energy_flows'].loc[time, 'net_network_export'] = value
def set_unallocated_local_solar(self, time, value):
self.energy_output["df_network_energy_flows"].loc[time, 'unallocated_local_solar'] = value
def set_unallocated_central_battery_load(self, time, value):
self.energy_output["df_network_energy_flows"].loc[time, 'unallocated_central_battery_load'] = value
def set_gross_participant_grid_import(self, time, value):
self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_grid_import'] = value
def get_gross_participant_grid_import(self, time):
return self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_grid_import']
def set_gross_participant_local_solar_import(self, time, value):
self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_local_solar_import'] = value
def get_gross_participant_local_solar_import(self, time):
return self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_local_solar_import']
def set_gross_participant_central_battery_import(self, time, value):
self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_central_battery_import'] = value
def get_gross_participant_central_battery_import(self, time):
return self.energy_output["df_network_energy_flows"].loc[time, 'gross_participant_central_battery_import']
# Financial Results
def set_participant_variable_charge(self, time, participant_id, value):
self.financial_output["df_participant_variable_charge"].loc[time, participant_id] = value
def get_participant_variable_charge(self, time, participant_id):
return self.financial_output["df_participant_variable_charge"].loc[time, participant_id]
def set_local_solar_import_charge(self, time, participant_id, value):
self.financial_output["df_local_solar_import_charge"].loc[time,participant_id] = value
def get_local_solar_import_charge(self, time, participant_id):
return self.financial_output["df_local_solar_import_charge"].loc[time,participant_id]
def set_central_batt_import_charge(self, time, participant_id, value):
self.financial_output["df_central_batt_import_charge"].loc[time,participant_id] = value
def get_central_batt_import_charge(self, time, participant_id):
return self.financial_output["df_central_batt_import_charge"].loc[time,participant_id]
def set_local_solar_sales_revenue(self, time, participant_id, value):
self.financial_output["df_local_solar_sales_revenue"].loc[time,participant_id] = value
def get_local_solar_sales_revenue(self, time, participant_id):
return self.financial_output["df_local_solar_sales_revenue"].loc[time,participant_id]
def set_central_batt_solar_sales_revenue(self, time, participant_id, value):
self.financial_output["df_central_batt_solar_sales_revenue"].loc[time,participant_id] = value
def get_central_batt_solar_sales_revenue(self, time, participant_id):
return self.financial_output["df_central_batt_solar_sales_revenue"].loc[time,participant_id]
def set_export_to_grid_solar_sales_revenue(self, time, participant_id, value):
self.financial_output["df_export_to_grid_solar_sales_revenue"].loc[time,participant_id] = value
def get_export_to_grid_solar_sales_revenue(self, time, participant_id):
return self.financial_output["df_export_to_grid_solar_sales_revenue"].loc[time,participant_id]
def set_fixed_charge(self, time, participant_id, value):
self.financial_output["df_fixed_charge"].loc[time,participant_id] = value
def get_fixed_charge(self, time, participant_id):
return self.financial_output["df_fixed_charge"].loc[time,participant_id]
def set_total_participant_bill(self, time, participant_id, value):
self.financial_output["df_total_participant_bill"].loc[time,participant_id] = value
def get_total_participant_bill(self, time, participant_id):
return self.financial_output["df_total_participant_bill"].loc[time,participant_id]
def set_participant_duos_payments(self, time, participant_id, value):
self.financial_output["df_participant_duos_payments"].loc[time,participant_id] = value
def get_participant_duos_payments(self, time, participant_id):
return self.financial_output["df_participant_duos_payments"].loc[time,participant_id]
def set_participant_tuos_payments(self, time, participant_id, value):
self.financial_output["df_participant_tuos_payments"].loc[time,participant_id] = value
def get_participant_tuos_payments(self, time, participant_id):
return self.financial_output["df_participant_tuos_payments"].loc[time,participant_id]
def set_participant_nuos_payments(self, time, participant_id, value):
self.financial_output["df_participant_nuos_payments"].loc[time,participant_id] = value
def get_participant_nuos_payments(self, time, participant_id):
return self.financial_output["df_participant_nuos_payments"].loc[time,participant_id]
def set_central_battery_revenue(self, time, value):
self.financial_output["df_central_battery_revenue"].loc[time,'central_battery_revenue'] = value
def get_central_battery_revenue(self, time):
return self.financial_output["df_central_battery_revenue"].loc[time,'central_battery_revenue']
# DNSP Revenues
def set_dnsp_grid_import_revenue_fixed(self, time, value):
self.financial_output["df_dnsp_revenue"].loc[time,'grid_import_revenue_fixed'] = value
def get_dnsp_grid_import_revenue_fixed(self, time):
return self.financial_output["df_dnsp_revenue"].loc[time,'grid_import_revenue_fixed']
def set_dnsp_grid_import_revenue_variable(self, time, value):
self.financial_output["df_dnsp_revenue"].loc[time,'grid_import_revenue_variable'] = value
def get_dnsp_grid_import_revenue_variable(self, time):
return self.financial_output["df_dnsp_revenue"].loc[time,'grid_import_revenue_variable']
def set_dnsp_local_solar_import_revenue(self, time, value):
self.financial_output["df_dnsp_revenue"].loc[time,'local_solar_import_revenue'] = value
def get_dnsp_local_solar_import_revenue(self, time):
return self.financial_output["df_dnsp_revenue"].loc[time,'local_solar_import_revenue']
def set_dnsp_central_battery_import_revenue(self, time, value):
self.financial_output["df_dnsp_revenue"].loc[time,'central_battery_import_revenue'] = value
def get_dnsp_central_battery_import_revenue(self, time):
return self.financial_output["df_dnsp_revenue"].loc[time,'central_battery_import_revenue']
def set_dnsp_total_revenue(self, time, value):
self.financial_output["df_dnsp_revenue"].loc[time,'total_revenue'] = value
def get_dnsp_total_revenue(self, time):
return self.financial_output["df_dnsp_revenue"].loc[time,'total_revenue']
# TNSP Revenues
def set_tnsp_grid_import_revenue_fixed(self, time, value):
self.financial_output["df_tnsp_revenue"].loc[time,'grid_import_revenue_fixed'] = value
def get_tnsp_grid_import_revenue_fixed(self, time):
return self.financial_output["df_tnsp_revenue"].loc[time,'grid_import_revenue_fixed']
def set_tnsp_grid_import_revenue_variable(self, time, value):
self.financial_output["df_tnsp_revenue"].loc[time,'grid_import_revenue_variable'] = value
def get_tnsp_grid_import_revenue_variable(self, time):
return self.financial_output["df_tnsp_revenue"].loc[time,'grid_import_revenue_variable']
def set_tnsp_local_solar_import_revenue(self, time, value):
self.financial_output["df_tnsp_revenue"].loc[time,'local_solar_import_revenue'] = value
def get_tnsp_local_solar_import_revenue(self, time):
return self.financial_output["df_tnsp_revenue"].loc[time,'local_solar_import_revenue']
def set_tnsp_central_battery_import_revenue(self, time, value):
self.financial_output["df_tnsp_revenue"].loc[time,'central_battery_import_revenue'] = value
def get_tnsp_central_battery_import_revenue(self, time):
return self.financial_output["df_tnsp_revenue"].loc[time,'central_battery_import_revenue']
def set_tnsp_total_revenue(self, time, value):
self.financial_output["df_tnsp_revenue"].loc[time,'total_revenue'] = value
def get_tnsp_total_revenue(self, time):
return self.financial_output["df_tnsp_revenue"].loc[time,'total_revenue']
# NUOS Revenues
def set_nuos_grid_import_revenue_fixed(self, time, value):
self.financial_output["df_nuos_revenue"].loc[time,'grid_import_revenue_fixed'] = value
def get_nuos_grid_import_revenue_fixed(self, time):
return self.financial_output["df_nuos_revenue"].loc[time,'grid_import_revenue_fixed']
def set_nuos_grid_import_revenue_variable(self, time, value):
self.financial_output["df_nuos_revenue"].loc[time,'grid_import_revenue_variable'] = value
def get_nuos_grid_import_revenue_variable(self, time):
return self.financial_output["df_nuos_revenue"].loc[time,'grid_import_revenue_variable']
def set_nuos_local_solar_import_revenue(self, time, value):
self.financial_output["df_nuos_revenue"].loc[time,'local_solar_import_revenue'] = value
def get_nuos_local_solar_import_revenue(self, time):
return self.financial_output["df_nuos_revenue"].loc[time,'local_solar_import_revenue']
def set_nuos_central_battery_import_revenue(self, time, value):
self.financial_output["df_nuos_revenue"].loc[time,'central_battery_import_revenue'] = value
def get_nuos_central_battery_import_revenue(self, time):
return self.financial_output["df_nuos_revenue"].loc[time,'central_battery_import_revenue']
def set_nuos_total_revenue(self, time, value):
self.financial_output["df_nuos_revenue"].loc[time,'total_revenue'] = value
def get_nuos_total_revenue(self, time):
return self.financial_output["df_nuos_revenue"].loc[time,'total_revenue']
# Retailer Revenues
def set_retailer_grid_import_revenue_fixed(self, time, value):
self.financial_output["df_retailer_revenue"].loc[time,'grid_import_revenue_fixed'] = value
def get_retailer_grid_import_revenue_fixed(self, time):
return self.financial_output["df_retailer_revenue"].loc[time,'grid_import_revenue_fixed']
def set_retailer_grid_import_revenue_variable(self, time, value):
self.financial_output["df_retailer_revenue"].loc[time,'grid_import_revenue_variable'] = value
def get_retailer_grid_import_revenue_variable(self, time):
return self.financial_output["df_retailer_revenue"].loc[time,'grid_import_revenue_variable']
def set_retailer_local_solar_import_revenue(self, time, value):
self.financial_output["df_retailer_revenue"].loc[time,'local_solar_import_revenue'] = value
def get_retailer_local_solar_import_revenue(self, time):
return self.financial_output["df_retailer_revenue"].loc[time,'local_solar_import_revenue']
def set_retailer_central_battery_import_revenue(self, time, value):
self.financial_output["df_retailer_revenue"].loc[time,'central_battery_import_revenue'] = value
def get_retailer_central_battery_import_revenue(self, time):
return self.financial_output["df_retailer_revenue"].loc[time,'central_battery_import_revenue']
def set_retailer_total_revenue(self, time, value):
self.financial_output["df_retailer_revenue"].loc[time,'total_revenue'] = value
def get_retailer_total_revenue(self, time):
return self.financial_output["df_retailer_revenue"].loc[time,'total_revenue']
def set_retailer_solar_fit_payments(self, time, value):
self.financial_output["df_retailer_fit_payments"].loc[time,'solar_fit_payments'] = value
def get_retailer_solar_fit_payments(self, time):
return self.financial_output["df_retailer_fit_payments"].loc[time,'solar_fit_payments']