-
Notifications
You must be signed in to change notification settings - Fork 6
/
mainMISO.py
146 lines (116 loc) · 4.02 KB
/
mainMISO.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
from lib.framework.MISO.query import *
import datetime
data_dir = os.path.join(os.getcwd(), 'data', 'MISO')
if os.path.isdir(data_dir):
pass
else:
os.makedirs(data_dir)
ind = 1
while ind == 1:
print('\nPlease enter the start date and duration of the desired data set.')
month = int(input('Month: '))
day = int(input('Day: '))
year = int(input('Year (4-digit format): '))
try:
datetime.datetime(year=year, month=month, day=day)
ind = 0
except:
print('\nWARNING: The Date Does NOT Exist. Please Try Again!!')
duration = int(input('Duration (in days): '))
start = pd.Timestamp(year, month, day).date()
end = start + pd.Timedelta(days=duration)
datelist = []
while start < end:
datelist.append(start)
start += pd.Timedelta(days=1)
date = []
for d in datelist:
date.append(str(d.year) + '{:02d}'.format(d.month) + '{:02d}'.format(d.day))
data_type = int(input('\nWhat type of data? (Answer 1, 2, or 3)\n'
'(1) Historical Locational Marginal Prices (LMP)\n'
'(2) Historical Marginal Clearing Prices (MCP)\n'
'(3) Summary Reports\n'))
if data_type == 1:
lmp = int(input('\nWhat type of LMP? (Answer 1, 2, 3, 4, 5, or 6)\n'
'(1) Day-Ahead EPNode LMPs\n'
'(2) Day-Ahead Market ExAnte LMPs\n'
'(3) Day-Ahead Market ExPost LMPs\n'
'(4) Real-Time EPNode LMPs\n'
'(5) Real-Time 5-min ExAnte LMPs\n'
'(6) Real-Time Final Market LMPs\n'))
if lmp == 1:
query_name = 'DA_Load_EPNodes'
extension = '.zip'
fileType = 'zip'
elif lmp == 2:
query_name = 'da_exante_lmp'
extension = '.csv'
fileType = 'csv'
elif lmp == 3:
query_name = 'da_expost_lmp'
extension = '.csv'
fileType = 'csv'
elif lmp == 4:
query_name = 'RT_Load_EPNodes'
extension = '.zip'
fileType = 'zip'
elif lmp == 5:
query_name = '5min_exante_lmp'
extension = '.xls'
fileType = 'csv'
elif lmp == 6:
query_name = 'rt_lmp_final'
extension = '.csv'
fileType = 'csv'
elif data_type == 2:
mcp = int(input('\nWhat type of MCP? (Answer 1, 2, 3, 4, 5, or 6)\n'
'(1) ASM Day-Ahead Market ExAnte MCPs\n'
'(2) ASM Day-Ahead Market ExPost MCPs\n'
'(3) ASM Real-Time 5-min ExAnte MCPs\n'
'(4) ASM Real-Time Final Market MCPs\n'
'(5) Day-Ahead ExAnte Ramp MCPs\n'
'(6) Day-Ahead ExPost Ramp MCPs\n'))
if mcp == 1:
query_name = 'asm_exante_damcp'
extension = '.csv'
fileType = 'csv'
elif mcp == 2:
query_name = 'asm_expost_damcp'
extension = '.csv'
fileType = 'csv'
elif mcp == 3:
query_name = '5min_exante_mcp'
extension = '.xls'
fileType = 'csv'
elif mcp == 4:
query_name = 'asm_rtmcp_final'
extension = '.csv'
fileType = 'csv'
elif mcp == 5:
query_name = 'da_exante_ramp_mcp'
extension = '.xls'
fileType = 'csv'
elif mcp == 6:
query_name = 'da_expost_ramp_mcp'
extension = '.xls'
fileType = 'csv'
elif data_type == 3:
summary = int(input('\nWhat type of summary? (Answer 1 or 2)\n'
'(1) Daily Forecast and Actual Load by Local Resource Zone\n'
'(2) Daily Regional Forecast and Actual Load\n'))
if summary == 1:
query_name = 'df_al'
extension = '.xls'
fileType = 'csv'
elif summary == 2:
query_name = 'rf_al'
extension = '.xls'
fileType = 'csv'
print('\nDownloading...\n')
for d in date:
params = {'query_name': query_name,
'date': d,
'extension': extension}
write_request(params, type=fileType)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/MISO\'\n')