-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprocessFiles.py
More file actions
79 lines (62 loc) · 2.4 KB
/
processFiles.py
File metadata and controls
79 lines (62 loc) · 2.4 KB
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
# Read in all of the REDUCED scenarios,
# write the private land ownership, save back to csv
# Written by Kristi Potter - 1/17/2020
import pandas as pd
import numpy as np
import pathlib
import os, sys
import json
# Set the path to the data
DATA_PATH = pathlib.Path(__file__).parent.joinpath("./data/").resolve()
SCENARIO_PATH = DATA_PATH.joinpath("50Scen_3days 2")
# Process the network
if True:
# Read in the network
bus = pd.read_csv(DATA_PATH.joinpath("RTS/bus.csv"))
bus = bus[['Bus ID','Bus Name','lat','lng']]
# Iterate over the bus IDs and add columns
ids = bus['Bus ID'].to_list()
scenarioDirs = ['details50_AC_72hrs',
'details50_DC_72hrs',
'details50_CP_72hrs',
'details50_ACCP_72hrs',
'details50_DCCP_72hrs',
'details50_cp_ac_conseq',
'details50_cp_dc_conseq']
#dataFiles = ['real_thermal_set_points.csv','real_renewable_setpoints.csv',
# 'reactive_thermal_set_points.csv']
dataFiles = ['real_renewable_spill.csv']
for s in scenarioDirs:
for f in dataFiles:
print("file", f)
newFilename = f.split(".")[0]+"_processed."+f.split(".")[1]
print(newFilename)
if(os.path.exists(newFilename)):
continue
bd = pd.read_csv(SCENARIO_PATH.joinpath(s+"/"+f))
newBD = {}
newBD['DateTime'] = bd['DateTime'].to_list()
# Sum for all the ids
for i in ids:
cols = [col for col in bd.columns if str(i) in col]
temp = bd[cols]
if(temp.empty):
l = [0]*len(bd)
newBD[i]=l
else:
newBD[i] = temp.sum(axis=1).to_list()
# Create a dataframe and transpose
df = pd.DataFrame.from_dict(newBD, orient='index').T
print("HERE")
# Write to file
print(SCENARIO_PATH.joinpath(s+"/"+newFilename))
df.to_csv(SCENARIO_PATH.joinpath(s+"/"+newFilename), index=False)
#break
#break
# Process the max wind generation
else:
# Read in the generator info
gen = pd.read_csv(DATA_PATH.joinpath("RTS/generator_info.csv"))
gen = gen[['BusNum', 'GenMWMax']]
gen =gen.groupby(['BusNum']).sum()
gen.to_csv(DATA_PATH.joinpath("RTS/maxGen.csv"))