forked from LLNL/ISO-DART
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainCAISO.py
372 lines (317 loc) · 15.7 KB
/
mainCAISO.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
import shutil
from lib.framework.CAISO.query import *
import datetime
raw_dir = os.path.join(os.getcwd(), 'raw_data')
xml_dir = os.path.join(os.getcwd(), 'raw_data', 'xml_files')
data_dir = os.path.join(os.getcwd(), 'data', 'CAISO')
if os.path.isdir(raw_dir):
pass
else:
os.makedirs(raw_dir)
if os.path.isdir(xml_dir):
pass
else:
os.makedirs(xml_dir)
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)
step_size = 1 # in days
data_type = int(input('\nWhat type of data? (Answer 1, 2, 3, or 4)\n'
'(1) Pricing Data\n'
'(2) System Demand Data\n'
'(3) Energy Data\n'
'(4) Ancillary Services (AS) Data\n'))
if data_type == 1:
price = int(input('\nWhat type of pricing data? (Answer 1, 2, 3, 4, or 5)\n'
'(1) Locational Marginal Prices (LMP)\n'
'(2) Ancillary Services (AS) Clearing Prices\n'
'(3) Intertie Constraint Shadow Prices\n'
'(4) Fuel Prices\n'
'(5) Green House Gas (GHG) Allowance Prices\n'))
if price == 1:
market = int(input('\nWhich energy market? (Answer 1, 2, 3, or 4)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Hour-Ahead Scheduling Process (HASP)\n'
'(3) Real-Time Market (RTM)\n'
'(4) Real-Time Pricing Day (RTPD)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_LMP().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_LMP.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
HASP_LMP().get_csv(start, end, step_size=step_size)
order_separate_csv(HASP_LMP.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 3:
print('\nDownloading from...\n')
RTM_LMP().get_csv(start, end, step_size=step_size)
order_separate_csv(RTM_LMP.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 4:
print('\nDownloading from...\n')
RTPD_LMP().get_csv(start, end, step_size=step_size)
order_separate_csv(RTPD_LMP.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif price == 2:
market = int(input('\nWhich energy market? (Answer 1 or 2)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Real-Time Market (RTM)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_AS().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_AS.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
RTM_AS().get_csv(start, end, step_size=step_size)
order_separate_csv(RTM_AS.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif price == 3:
print('\nDownloading from...\n')
IntertieConstraintShadowPrice().get_csv(start, end, step_size=step_size)
order_separate_csv(IntertieConstraintShadowPrice.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif price == 4:
print('\nDownloading from...\n')
FuelPrice().get_csv(start, end, step_size=step_size)
copy_csv(FuelPrice.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif price == 5:
print('\nDownloading from...\n')
GHG().get_csv(start, end, step_size=step_size)
copy_csv(GHG.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif data_type == 2:
system_demand = int(input('\nWhat type of system demand data? (Answer 1 or 2)\n'
'(1) CAISO Demand Forecast\n'
'(2) Advisory CAISO Demand Forecast\n'))
if system_demand == 1:
market = int(input('\nWhich energy market? (Answer 1, 2, 3, or 4)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Two Day-Ahead Market (2DA)\n'
'(3) Seven Day-Ahead Market (7DA)\n'
'(4) Real-Time Market (RTM)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_DF().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_DF.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
twoDayDA_DF().get_csv(start, end, step_size=step_size)
order_separate_csv(twoDayDA_DF.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 3:
print('\nDownloading from...\n')
sevenDayDA_DF().get_csv(start, end, step_size=step_size)
order_separate_csv(sevenDayDA_DF.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 4:
print('\nDownloading from...\n')
RTM_DF().get_csv(start, end, step_size=step_size)
order_separate_csv(RTM_DF.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif system_demand == 2:
print('\nDownloading from...\n')
AdvisoryDemandForecast().get_csv(start, end, step_size=step_size)
try:
order_separate_csv(AdvisoryDemandForecast.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
except:
print("There is no data available to return.")
elif data_type == 3:
load = int(input('\nWhat type of energy data? (Answer 1, 2, 3, 4, 5, 6, 7, or 8)\n'
'(1) Market Power Mitigation (MPM) Status\n'
'(2) Flexible Ramp Requirements\n'
'(3) Flexible Ramp Aggregated Awards\n'
'(4) Flexible Ramp Surplus Demand Curves (DC)\n'
'(5) EIM Transfer\n'
'(6) EIM Transfer Limits\n'
'(7) Wind and Solar Summary\n'
'(8) System Load and Resource Schedules\n'))
if load == 1:
market = int(input('\nWhich energy market? (Answer 1 or 2)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Hour-Ahead Scheduling Process (HASP)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_MPM().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_MPM.name, market=DAM_MPM.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
HASP_MPM().get_csv(start, end, step_size=step_size)
order_separate_csv(HASP_MPM.name, market=HASP_MPM.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 2:
print('\nDownloading from...\n')
FlexRampReq().get_csv(start, end, step_size=step_size)
src = os.path.join(RAW_DIR, '{}.csv'.format(FlexRampReq.name))
dst = os.path.join(DATA_DIR, 'CAISO', '{}_to_{}_{}.csv'.format(start, end, FlexRampReq.name))
shutil.copyfile(src, dst)
os.remove(src)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 3:
print('\nDownloading from...\n')
FlexRampAggAward().get_csv(start, end, step_size=step_size)
src = os.path.join(RAW_DIR, '{}.csv'.format(FlexRampAggAward.name))
dst = os.path.join(DATA_DIR, 'CAISO', '{}_to_{}_{}.csv'.format(start, end, FlexRampAggAward.name))
shutil.copyfile(src, dst)
os.remove(src)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 4:
print('\nDownloading from...\n')
FlexRampDC().get_csv(start, end, step_size=step_size)
src = os.path.join(RAW_DIR, '{}.csv'.format(FlexRampDC.name))
dst = os.path.join(DATA_DIR, 'CAISO', '{}_to_{}_{}.csv'.format(start, end, FlexRampDC.name))
shutil.copyfile(src, dst)
os.remove(src)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 5:
print('\nDownloading from...\n')
EIMTransfer().get_csv(start, end, step_size=step_size)
src = os.path.join(RAW_DIR, '{}.csv'.format(EIMTransfer.name))
dst = os.path.join(DATA_DIR, 'CAISO', '{}_to_{}_{}.csv'.format(start, end, EIMTransfer.name))
shutil.copyfile(src, dst)
os.remove(src)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 6:
print('\nDownloading from...\n')
EIMTransferLimit().get_csv(start, end, step_size=step_size)
order_separate_csv(EIMTransferLimit.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 7:
print('\nDownloading from...\n')
WindSolarSummary().get_csv(start, end, step_size=step_size)
order_separate_csv(WindSolarSummary.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif load == 8:
market = int(input('\nWhich energy market? (Answer 1, 2, 3, or 4)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Residual Unit Commitment (RUC)\n'
'(3) Hour-Ahead Scheduling Process (HASP)\n'
'(4) Real-Time Market (RTM)\n'))
if market == 1:
print('\nDownloading from...\n')
DamSystemLoad().get_csv(start, end, step_size=step_size)
order_separate_csv(DamSystemLoad.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
RucSystemLoad().get_csv(start, end, step_size=step_size)
order_separate_csv(RucSystemLoad.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 3:
print('\nDownloading from...\n')
HaspSystemLoad().get_csv(start, end, step_size=step_size)
order_separate_csv(HaspSystemLoad.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 4:
print('\nDownloading from...\n')
RtmSystemLoad().get_csv(start, end, step_size=step_size)
order_separate_csv(RtmSystemLoad.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif data_type == 4:
ancillary = int(input('\nWhat type of ancillary services data? (Answer 1, 2, or 3)\n'
'(1) Ancillary Services (AS) Requirements\n'
'(2) Ancillary Services (AS) Results\n'
'(3) Actual Operating Reserves\n'))
if ancillary == 1:
market = int(input('\nWhich energy market? (Answer 1, 2, or 3)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Hour-Ahead Scheduling Process (HASP)\n'
'(3) Real-Time Market (RTM)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_AS_REQ().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_AS_REQ.name, market=DAM_AS_REQ.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
HASP_AS_REQ().get_csv(start, end, step_size=step_size)
order_separate_csv(HASP_AS_REQ.name, market=HASP_AS_REQ.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 3:
print('\nDownloading from...\n')
RTM_AS_REQ().get_csv(start, end, step_size=step_size)
try:
order_separate_csv(RTM_AS_REQ.name, market=RTM_AS_REQ.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
except:
print('There is no data available to return.')
elif ancillary == 2:
market = int(input('\nWhich energy market? (Answer 1, 2, or 3)\n'
'(1) Day-Ahead Market (DAM)\n'
'(2) Hour-Ahead Scheduling Process (HASP)\n'
'(3) Real-Time Market (RTM)\n'))
if market == 1:
print('\nDownloading from...\n')
DAM_AS_RES().get_csv(start, end, step_size=step_size)
order_separate_csv(DAM_AS_RES.name, market=DAM_AS_RES.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 2:
print('\nDownloading from...\n')
HASP_AS_RES().get_csv(start, end, step_size=step_size)
order_separate_csv(HASP_AS_RES.name, market=HASP_AS_RES.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif market == 3:
print('\nDownloading from...\n')
RTM_AS_RES().get_csv(start, end, step_size=step_size)
order_separate_csv(RTM_AS_RES.name, market=RTM_AS_RES.market)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
elif ancillary == 3:
print('\nDownloading from...\n')
AS_OpRes().get_csv(start, end, step_size=step_size)
order_separate_csv(AS_OpRes.name)
print('\nYour data has been successfully downloaded!\n'
'Check your directory \'data/CAISO\'\n')
shutil.rmtree(raw_dir)