Skip to content

Commit

Permalink
update ev module
Browse files Browse the repository at this point in the history
  • Loading branch information
pluflou committed Jun 7, 2024
1 parent 40dfbe8 commit 1284c2e
Show file tree
Hide file tree
Showing 1,082 changed files with 81,253 additions and 2 deletions.
36 changes: 34 additions & 2 deletions sg2t/io/loadshapes/ev.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""Class for obtaining loadshapes from the SPEECh model.
https://github.com/slacgismo/speech/tree/main.
"""

import os
from pathlib import Path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from sg2t.transportation.speech import DataSetConfigurations
from sg2t.transportation.speech import SPEECh
from sg2t.transportation.speech import SPEEChGeneralConfiguration
Expand All @@ -14,7 +18,14 @@ def __init__(self, total_evs):
self.total_evs = total_evs # Input number of EVs in simulation
self.weekday_option = 'weekday'
self.dataset = 'Original16' # 'NewData' not implemented yet
self.path_to_data = 'inputs/'
# TODO: simplify below
path = os.path.dirname(os.path.abspath(__file__))
self.path_to_data = os.path.abspath(os.path.join(
path,
os.pardir,
os.pardir,
"transportation/data/")
) +"/"
self.ng = 16 # default number of groups for Original16 dataset
self.g_weights = None # weight for each group
# self.b_weights = None # weight for each behavior
Expand Down Expand Up @@ -84,3 +95,24 @@ def _format_data(self, loadshapes):
loadshapes["Hour"] = pd.date_range("00:00", "23:45", freq="1H").hour
loadshapes.set_index('Hour', inplace=True)
return loadshapes

def plot_loadshapes(self, figsize=(8, 5)):
x = self.loadshapes.index

scaling = 1 / 1000
unit = 'MW'
if np.max(
scaling * self.config.total_load_segments) > 1000: # if any scaled value is over 1000
scaling = (1 / 1000) * (1 / 1000)
unit = 'GW'

plt.figure(figsize=figsize)
for key in self.loadshapes.columns:
val = self.loadshapes[key]
plt.plot(x, scaling * val, label=key)

plt.legend()
plt.xlim([0, np.max(x)])

plt.ylabel(unit)
plt.xlabel('Hour')
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
5427604.999911716,-4423.1343291424255,-4512077.7005741075
-4423.1343291424255,22.214306656566677,2042.6502341254422
-4512077.7005741075,2042.6502341254418,12096902.747699598
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
0.19717023544648107,0.008214606101277739,242.7799219762115
0.008214606101277834,46.062564914729194,-6285.984168920373
242.77992197621154,-6285.984168920372,28392789.943031903
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
324899221.27789485,-70370.46108680914,-97650151.24266599
-70370.46108680914,65.70252551838946,33728.902920621294
-97650151.24266599,33728.902920621294,73312736.01557791
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
458077284.2970919,-12159.914943071615,651153696.4210049
-12159.914943071613,23.244786943830334,22250.677418111238
651153696.4210049,22250.677418111234,1852879654.9859467
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
1569.8036547971305,55.61300177040489,-10648.148038730826
55.61300177040489,46.67778266496539,5484.496934445689
-10648.148038730827,5484.496934445689,75197609.98457795
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
542657894.2758173,-26884.511500791836,-16264012.922941841
-26884.511500791836,13.838536651093415,7431.590695768534
-16264012.922941841,7431.590695768533,4028335.0560377766
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
57514848.94463027,3982.672136296065,-49032855.38994808
3982.6721362960657,45.51228679089097,-13599.47041459266
-49032855.38994808,-13599.47041459266,193709064.85870567
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
17539169.408156335,2255.510678620554,-1614821.739523228
2255.510678620554,19.102437968892566,2030.8386802836258
-1614821.7395232278,2030.8386802836258,3141351.2085341373
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0,1,2
4654.410248288734,8.798567291085696,18313.017917430523
82800.27015056102,12.125908187266397,28492.26078406729
25912.397186734437,13.096394402036474,16721.894782812735
18989.440100212545,7.450942632360632,56581.27142125942
23.165744454196616,12.541362571129396,22440.293119934504
29668.0853458019,6.556653268164985,3571.023198701791
73903.12732842473,12.188203614414666,39649.111945755925
10542.541520263618,11.597502360731903,10729.867204705535
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0
0.30613221155143894
0.020027120438926276
0.09482849036194142
0.016987936539619688
0.2616549900658496
0.06852865407392657
0.03925621697756745
0.19258437999073053
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
518.1757341604573,31.96503865432308,47880.579206383336
31.965038654323088,34.99596220251478,3658.802540043841
47880.57920638333,3658.802540043841,51010430.74323348
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
47631949.384477906,-13626.93834160322,-30214171.424688157
-13626.938341603221,31.689123315544844,4145.736061837138
-30214171.424688157,4145.736061837139,126668691.07805008
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
5388266.10478477,566.0901597780444,-7828100.918125936
566.0901597780444,27.29557755238832,12567.971839527509
-7828100.918125937,12567.971839527509,49282251.21716063
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
516519398.2026771,-47715.79824834635,-23399045.103980742
-47715.79824834634,28.73265559681055,18529.62583053983
-23399045.103980742,18529.62583053983,17532808.729566578
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
345483068.32158375,-10108.949707268323,256650002.3587853
-10108.949707268323,18.40123024513886,4848.278283714562
256650002.3587853,4848.278283714563,1365930042.436096
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0,1,2
10.733220857245666,11.848919988447648,20410.597922312336
76936.5791476946,10.350190400190662,32795.71314128168
3761.97545586997,11.064397525324061,15190.079447258877
39257.00230846194,8.595743460468954,6750.616081624155
40541.539353285814,8.642694667094567,41238.020870807
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0
0.47558671747871034
0.08708395008047821
0.28970853176147265
0.11103170406564282
0.03658909661369425
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
1.0000000000000025e-06,2.403185861665285e-26,1.4475660719677952e-23
2.403185861665285e-26,1e-06,1.3410635388757172e-28
1.4475660719677952e-23,1.3410635388757172e-28,1e-06
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
1.0000000000000023e-06,1.2601579644362503e-24,1.6345088904047791e-21
1.2601579644362503e-24,1e-06,9.208846663187983e-25
1.6345088904047791e-21,9.208846663187983e-25,1.0000000000000012e-06
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
1.0000000000000002e-06,6.979336418416155e-25,5.360130369343607e-22
6.979336418416155e-25,1e-06,1.395867283683231e-24
5.360130369343607e-22,1.395867283683231e-24,1.000000000000001e-06
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
35910.250000999964,637.63992775,375494.2499999996
637.63992775,11.32224680617026,6667.459191749999
375494.2499999996,6667.459191749999,3926342.2500009956
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0,1,2
23143.99999999995,0.2083429999999995,127.99999999999972
21450.999999999953,11.991960999999973,15550.999999999965
7199.999999999984,19.570600999999957,14399.999999999967
23552.499999999975,15.153368499999987,8915.49999999999
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0
0.20000000000000046
0.20000000000000046
0.20000000000000046
0.40000000000000047
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
49124658.53387208,-4195.376027734627,-50729186.345786616
-4195.376027734627,236.7151994465092,6483.837593270478
-50729186.345786616,6483.837593270478,81536125.73805843
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
242656288.3573288,-2143.2365029595258,-4824683.969392129
-2143.2365029595244,7.6116050615199065,4877.284105658925
-4824683.969392129,4877.284105658925,11888094.102424303
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
333052027.2554984,46487.474110197356,133109807.91957186
46487.474110197356,211.4642055254037,-195407.35698904298
133109807.91957185,-195407.35698904295,2407217052.8290315
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
436428903.00657755,-51366.306574729446,-77838060.52611293
-51366.306574729446,102.2313635061048,6863.202303237591
-77838060.52611294,6863.202303237591,65185222.71444112
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
0.18190252028938278,-0.044562566242172405,-126.3836493834464
-0.044562566242172454,140.3891395322572,-1462.6944016304485
-126.38364938344637,-1462.694401630447,102603965.36118487
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
74580388.65425089,3218.488808312668,-73967277.34837618
3218.4888083126684,20.442581720070535,-9515.531425096142
-73967277.34837618,-9515.531425096144,176510493.76515657
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
0.18135656902099603,0.09112465279367996,11.870599756616047
0.09112465279367991,140.5766754835377,1955.757413510439
11.870599756616057,1955.7574135104387,66402453.14122801
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
265258433.99616504,870.1877619783413,66197.83034448735
870.1877619783417,20.094974264245224,9904.643592809745
66197.83034448716,9904.643592809745,5272486.257924987
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0,1,2
73622.2913389279,25.741661189108466,40530.83491283007
48277.52140828408,4.614641084868227,7128.593013391799
57213.303794207655,16.9629821757307,109294.39062509156
28448.29408257175,12.99047619294794,19786.70799043154
0.2390429689524963,14.030254519023142,28802.610063419033
70785.21650404377,8.686960970288645,46401.39688208638
82800.23687832085,14.23433351563686,29334.04377378031
51652.761921072844,5.486642805924515,3255.7427026253395
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0
0.1310767786024119
0.11584688830846893
0.049500081571190076
0.09236091259961303
0.037361473613304524
0.2502115156926603
0.22645425157854143
0.09718809803380037
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
0.17754060530363008,-0.02311444977124056,-20.56132572375033
-0.02311444977124053,135.63438738698756,-492.9113551288303
-20.56132572375033,-492.9113551288301,19169924.016552076
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
507918721.47029424,-26708.470772943692,-113975063.73102123
-26708.4707729437,106.97168258478048,12444.355141260194
-113975063.73102123,12444.355141260192,91211954.35947275
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
61201872.66999115,8006.165938799348,-58160330.7395619
8006.165938799348,176.9946455936246,-16310.105848293775
-58160330.7395619,-16310.105848293775,146770531.27954686
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
250056803.27717656,15918.481536870393,125991005.88407631
15918.481536870393,140.3378996268104,27545.856498721605
125991005.88407631,27545.856498721605,2151371035.8606553
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
307016995.3926255,4484.484608326184,-855652.7260107251
4484.484608326184,12.98150319240158,7768.197365828879
-855652.7260107248,7768.197365828879,12271825.051035516
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0,1,2
82800.23073498033,14.821814964640563,28978.460890834478
22521.40800174976,12.511344247641926,21120.533061144517
73011.34076378509,15.926730955274579,43911.111738057174
58599.04768250465,11.723515784191877,109322.59343734045
51291.43185489597,5.098697808837237,5234.648940468582
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0
0.27438057154339796
0.113267095522598
0.40824126229299396
0.05682861695366341
0.1472824536873453
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
4021.450588208024,-198.7306146865923,230939.14455231847
-198.7306146865923,173.57668858680066,-1440.7736432718361
230939.14455231847,-1440.7736432718361,22716261.361538835
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
58551347.18968506,33613.94836906886,9564122.664625458
33613.94836906886,81.16124230522357,24231.950018562668
9564122.664625458,24231.950018562668,23074416.669220444
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
1.0000000000000048e-06,3.683538665275193e-24,2.6152142246476466e-20
3.683538665275193e-24,1e-06,2.0162527430980005e-23
2.6152142246476466e-20,2.0162527430980005e-23,1.000000000000143e-06
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
6854702.853374174,-8860.59637443607,-1240812.2632433125
-8860.596374436072,283.7776617193952,120.00430878242064
-1240812.2632433125,120.00430878242076,4426142.436706087
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
4132248.721552237,-2359.519338985644,-445484.2779469601
-2359.5193389856445,13.212016515987019,-3305.5454154554
-445484.2779469601,-3305.5454154554,8063625.990738385
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
23879832.146974258,74.60349766193757,13170623.467940317
74.60349766193944,138.27699101316932,67858.43393781263
13170623.467940317,67858.43393781263,47856581.72834424
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
262920352.15051526,1491.0376244766544,-9817249.841844155
1491.0376244766535,5.9189030116609604,5352.869368093045
-9817249.841844155,5352.869368093045,7023589.138965767
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
6499950.250000993,636.8650999999994,-8911777.24999999
636.8650999999994,0.06240103999999994,-873.175899999999
-8911777.24999999,-873.175899999999,12218520.250000987
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0,1,2
14.422775921817955,21.163512822836847,24690.55841050219
50977.67455036758,11.78640738033,9604.207593171415
31316.99999999993,24.280198999999946,172799.99999999962
81743.17043789626,31.560666539655728,29298.69070627078
31864.64212331906,8.577970283876247,7867.664992687953
4078.513066774739,20.377974990948825,15020.202440992547
53957.12414529645,3.0361262864497927,3012.488803909583
61653.499999999935,5.162099999999995,51067.49999999994
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0
0.6322389703591752
0.09331657684524584
0.00423728813559323
0.04660957605572114
0.06021183479502639
0.03301515061364943
0.12189602692440224
0.00847457627118645
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
0.18072303720581323,-0.04445048286951745,17.951397328856043
-0.04445048286951744,118.37728244930827,4538.909269449846
17.951397328856032,4538.909269449847,73229860.63371886
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
10003.132090696428,-27.17884992611907,-99932.43637008854
-27.17884992611908,151.8449697583197,-13168.594207723669
-99932.43637008854,-13168.594207723674,107612378.05639607
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
191115068.77832076,-7400.2804089269885,-69207016.44044721
-7400.2804089269885,184.74543070426392,-3766.23004312087
-69207016.4404472,-3766.2300431208714,294171989.9512985
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
416783150.5827098,1278.8582743746094,-48708985.602602005
1278.8582743746088,28.466155360599657,3507.680541634729
-48708985.602602005,3507.680541634729,37019589.528926626
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
67347065.05941054,1718.7438931246056,-78841681.19260685
1718.7438931246054,19.668275253692777,-5144.392319726355
-78841681.19260685,-5144.392319726355,202592015.4756529
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
293732342.56046784,-300.3431127562191,-2051005.7058191085
-300.34311275621934,5.753674577315438,3149.6841947007156
-2051005.7058191085,3149.6841947007156,3246976.4890495394
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
692184528.1595864,87224.12010221992,281196636.88442975
87224.12010221994,253.98170224704634,-56902.291176207866
281196636.88442975,-56902.29117620786,632240352.8901427
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,1,2
39912971.47122877,-6431.133108834167,-43819923.6251239
-6431.133108834168,206.42434222252086,9345.513209972787
-43819923.6251239,9345.513209972787,69064293.03928271
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0,1,2
82800.23587928114,13.936564549827459,29548.138709442144
46.25833115747905,14.5928011954553,28462.106188761503
64172.4842005193,13.709091506090852,158295.49558640132
44180.800025499506,8.903066399669514,12356.059176580844
72426.75970015445,8.72925940470724,45049.81923013194
48607.019416870455,3.703334975892725,2974.5964183148335
46367.331021698745,22.972277611176978,53451.334622593735
75111.37628376308,22.920601560170596,38863.04382157132
Loading

0 comments on commit 1284c2e

Please sign in to comment.