-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathplot_result.py
131 lines (87 loc) · 3.78 KB
/
plot_result.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
import tkinter as tk
from tkinter.ttk import *
from tkinter import ttk
from pandas import DataFrame
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import os
import sys
import matplotlib
import numpy as np
import pandas as pd
from matplotlib import interactive
import matplotlib.ticker as plticker
os.chdir(sys.argv[1])
print("Plot Result")
print(sys.argv[2].split(':')) #Price
print(sys.argv[3].split(':')) #Total Load
print(len(sys.argv[2].split(':')))
print(len(sys.argv[3].split(':')))
root_name = sys.argv[1].replace("/", " ").replace("_", " ")[8:] + " Simulation Result"
root= tk.Tk()
root.title(root_name)
lbl = Label(root, text=root_name, font=("Times", 18), foreground="#000280")
lbl.pack()
def plot_price(file_list):
figure1 = plt.Figure(figsize=(6,5), dpi=100)
ax1 = figure1.add_subplot(111)
bar1 = FigureCanvasTkAgg(figure1, root)
bar1.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
legend_list = []
figure2 = plt.Figure(figsize=(6,5), dpi=100)
ax2 = figure2.add_subplot(111)
bar2 = FigureCanvasTkAgg(figure2, root)
bar2.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
for i in range(1, len(file_list)-1):
data_loading= pd.read_csv(str(file_list[i]), delimiter=',', skiprows=9,names=["timestamp","capacity_reference_bid_price","current_market.clearing_price","current_market.clearing_quantity"])
data_loading.head(5)
#print(data_loading)
if i == 1:
my_xticks = data_loading["timestamp"]
with open(str(file_list[i])) as f:
row_count = sum(1 for line in f) - 9
y_1 = []
for k in range(0, row_count):
y_1.append(my_xticks.values[k][11:19])
ax1.plot(y_1, 'current_market.clearing_price', data=data_loading, linewidth = 4)
ax2.plot(y_1, 'current_market.clearing_quantity', data=data_loading, linewidth = 4)
legend_list.append(str(file_list[i]).replace('.csv',''))
ax1.set_title('Clearing Price')
plt.setp(ax1.get_xticklabels(), rotation=45, horizontalalignment='right')
ax1.xaxis.set_major_locator(loc)
ax1.set_xlabel('Time')
ax1.set_ylabel('Price $')
ax2.set_title('Clearing Quantity')
plt.setp(ax2.get_xticklabels(), rotation=45, horizontalalignment='right')
ax2.xaxis.set_major_locator(loc)
ax2.set_xlabel('Time')
ax2.set_ylabel('Price $')
def plot_total_load(file_list):
figure2 = plt.Figure(figsize=(6,5), dpi=100)
ax2 = figure2.add_subplot(111)
line2 = FigureCanvasTkAgg(figure2, root)
line2.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
legend_list = []
for i in range(1, len(file_list)-1):
data_loading= pd.read_csv(str(file_list[i]), delimiter=',', skiprows=9,names=["timestamp","power_out_real"])
data_loading.head(5)
if i == 1:
my_xticks = data_loading["timestamp"]
with open(str(file_list[i])) as f:
row_count = sum(1 for line in f) - 9
y_1 = []
for k in range(0, row_count):
y_1.append(my_xticks.values[k][11:19])
ax2.plot(y_1, 'power_out_real', data=data_loading, linewidth = 4)
legend_list.append(str(file_list[i]).replace('.csv',''))
ax2.set_title('Total Load')
plt.setp(ax2.get_xticklabels(), rotation=45, horizontalalignment='right')
ax2.xaxis.set_major_locator(loc)
ax2.set_xlabel('Time')
ax2.set_ylabel('kWh')
loc = plticker.MultipleLocator(base=100) # this locator puts ticks at regular intervals
if(len(sys.argv[2].split(':'))>2):
plot_price(sys.argv[2].split(':'))
if(len(sys.argv[3].split(':'))>2):
plot_total_load(sys.argv[3].split(':'))
root.mainloop()