-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_data_PLD.py
111 lines (82 loc) · 4.38 KB
/
load_data_PLD.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
"""
Este arquivo carrega perfis de carga e de geração PV para serem utilizadas pelos prosumers
"""
import pandas as pd
import numpy as np
import random
import os
path = os.path.dirname(os.path.abspath(__file__))
GRID_DATA_PATH = path + '/1-MVLV-urban-5.303-1-no_sw'
MARKET_DATA_PATH = path + '/market-data'
DAYS = 30
coordinates_df = pd.read_csv('{}/Coordinates.csv'.format(GRID_DATA_PATH), delimiter=';') # data frame com as coordenadas da rede
line_df = pd.read_csv('{}/Line.csv'.format(GRID_DATA_PATH), delimiter=';') # data frame com as linhas da rede de distribuicao
node_df = pd.read_csv('{}/Node.csv'.format(GRID_DATA_PATH), delimiter=';') # data frame com os nodes da rede de distribuição
line_type = pd.read_csv('{}/LineType.csv'.format(GRID_DATA_PATH), delimiter=';') # data frame com os tipos de linhas da rede de distribuição
load_df = pd.read_csv('{}/Load.csv'.format(GRID_DATA_PATH), delimiter=';')[138:242] # data frame com cargas em cada node da rede de distribuição
load_profile_df = pd.read_csv('{}/LoadProfile.csv'.format(GRID_DATA_PATH), delimiter=';') # perfis de carga associados aos nodes da rede
gen_df = pd.read_csv('{}/RES.csv'.format(GRID_DATA_PATH), delimiter=';')[134:] # data frame com geradores em cada node da rede de distribuição
gen_profile_df = pd.read_csv('{}/RESProfile.csv'.format(GRID_DATA_PATH), delimiter=';') # perfis de geração associados aos nodes da rede
spot_prices_df = pd.read_excel('{}/PLD_NE_12_meses.xlsx'.format(MARKET_DATA_PATH))
def get_load_data(load_index=None):
month_delta = 24 * 4 * 30 * 1
if load_index != None:
load = load_df.iloc[load_index % 100]
start_day = 15 * 24 * 4 + month_delta
else:
load_index = random.randint(0, len(load_df) - 1)
load = load_df.iloc[load_index]
start_day = random.randint(0, 30) * 24 * 4 + month_delta
end_day = start_day + 30 * 24 * 4
load_p_data = load_profile_df['{}_pload'.format(load.profile)][start_day:end_day]
load_q_data = load_profile_df['{}_qload'.format(load.profile)][start_day:end_day]
load_p_data = pd.Series(load_p_data.values, index=range(24 * 4 * DAYS))
load_q_data = pd.Series(load_q_data.values, index=range(24 * 4 * DAYS))
loads_df = pd.concat([load_p_data, load_q_data], axis=1)
loads_df.columns = ['pload', 'qload']
return loads_df
def get_gen_data(gen_index=None):
month_delta = 24 * 4 * 30 * 1
if gen_index != None:
gen = gen_df.iloc[gen_index % 12]
start_day = 15 * 24 * 4 + month_delta
else:
gen_index = random.randint(0, len(gen_df) - 1)
gen = gen_df.iloc[gen_index]
start_day = random.randint(0, 30) * 24 * 4 + month_delta
end_day = start_day + 30 * 24 * 4
gen_p_data = gen_profile_df[gen.profile][start_day:end_day]
gen_p_data = pd.Series(gen_p_data.values, index=range(24 * 4 * DAYS))
gens_df = pd.DataFrame(gen_p_data, columns=['pgen'])
return gens_df
def get_spot_prices_data(spot_index=None):
# PARA A VARIÁVEL month_delta FOI DEFINIDO COM 5424 PARA REPRESENTAR O DIA 17/11/2023 QUE TEVE UMA VARIAÇÃO DO PLD. ESTA ESTRATÉGIA SERVE PARA CONSIDERAR A DATA DE MAIOR VARIAÇÃO DIÁRIA DO PLD
# PARA A VARIÁVEL month_delta FOI DEFINIDO COM 5448 PARA REPRESENTAR O DIA 18/11/2023 QUE TEVE UMA VARIAÇÃO DO PLD.
# PARA A VARIÁVEL month_delta FOI DEFINIDO COM 6168 PARA REPRESENTAR O DIA 18/12/2023 QUE TEVE UMA VARIAÇÃO DO PLD. DESPACHO UTE PECÉM (4200)
if spot_index:
#month_delta = 24 * 30 * 6
month_delta = 5424
start_day = (spot_index % 30) * 24 + month_delta
end_day = start_day + 30 * 24
else:
#month_delta = 24 * 30 * 6
month_delta = 5424
start_day = random.randint(0, 30) * 24 + month_delta
end_day = start_day + 30 * 24
spot_p_data = spot_prices_df.SpotPriceBRL[start_day:end_day]
# converte os dados de preços da base horária para base de 15min
aux = np.array([])
for i in spot_p_data:
aux = np.concatenate((aux, np.ones(4) * i))
spot_p_data = pd.Series(aux, index=range(24 * 4 * DAYS))
spot_df = pd.DataFrame(spot_p_data, columns=['Price'])
return spot_df
if __name__ == '__main__':
# LOAD DATA
loads = list()
for load_idx in range(10):
loads.append(get_load_data(random.uniform(3.0, 5.0)))
# PLOT DATA
for l in loads:
l.pload[:2 * 24 * 4].plot()
sum(loads).pload[:2 * 24 * 4].plot()