-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmd_results.py
85 lines (47 loc) · 1.45 KB
/
gmd_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
#!/usr/bin/env python
# coding: utf-8
# In[22]:
import json, gzip, os
from glob import glob
import numpy as np
import pandas as pd
# In[2]:
os.getcwd()
# In[5]:
with open("data/epri21_ots.json") as h:
output = json.load(h);
result = output['result']
# In[24]:
def merge_results(output, table_names=None):
net = output['case']
soln = output['result']['solution']
if table_names is None:
table_names = 'bus branch gen dcline storage shunt load gmd_bus gmd_branch'.split()
for tname in table_names:
# print(f'Table {tname}')
for oid, obj in net[tname].items():
if tname not in soln:
continue
soln_obj = soln[tname][oid]
for fieldname, val in soln_obj.items():
if fieldname in obj:
soln_fieldname = fieldname + '_soln'
obj[soln_fieldname] = val
else:
obj[fieldname] = val
return net
# In[ ]:
tnames = 'bus branch gen dcline storage shunt load gmd_bus gmd_branch'.split()
merge_results(output, table_names=tnames)
# In[23]:
tables = {}
for tname in tnames:
tables[tname] = pd.DataFrame(list(output['case'][tname].values()))
buses = tables['bus']
branches = tables['branch']
gens = tables['gen']
loads = tables['load']
gmd_buses = tables['gmd_bus']
gmd_branches = tables['gmd_branch']
# In[25]:
# In[ ]: