forked from nhcb/entsog-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
106 lines (73 loc) · 4.59 KB
/
tests.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
from entsog import EntsogRawClient, EntsogPandasClient
import pandas as pd
import json
from entsog.mappings import BalancingZone
from entsog.mappings import Country
def get_area():
client = EntsogRawClient()
data = json.loads(client.query_operator_point_directions(limit = -1))
df = pd.json_normalize(data['operatorpointdirections'])
df_drop = df.drop_duplicates(subset=['tSOCountry'])
c = {}
for idx, item in df_drop.iterrows():
country = item['tSOCountry']
filtered = df[df['tSOCountry'] == country]
operatorKey = filtered.loc[:,'operatorKey'].drop_duplicates()
#print(operatorKey)
operatorLabel = filtered.loc[:,'operatorLabel'].drop_duplicates()
if country is None:
country = 'misc'
print(f"{country} = {list(operatorKey)}, {list(operatorLabel)} ,")
client = EntsogPandasClient()
start = pd.Timestamp(2021, 1, 1)
end = pd.Timestamp(2021,1, 6)
country_code = 'DE'
# data = client.query_interruptions(country_code= 'DE',start = start, end = end, limit = -1)
# data = client.query_interruptions(country_code= 'DE',start = start, end = end, limit = -1)
# print(data)
# op = client.query_operator_point_directions()
# print(op)
# client.query_connection_points().to_csv(f'data/query_connection_points.csv',sep = ';')
# client.query_operators(country_code).to_csv(f'data/query_operators.csv',sep = ';')
# client.query_balancing_zones().to_csv(f'data/query_balancing_zones.csv',sep = ';')
# client.query_operator_point_directions(country_code).to_csv(f'data/query_operator_point_directions_{country_code}.csv',sep = ';')
# client.query_interconnections(country_code).to_csv(f'data/query_interconnections_{country_code}.csv',sep = ';')
# client.query_aggregate_interconnections().to_csv(f'data/query_aggregate_interconnections.csv',sep = ';')
# client.query_urgent_market_messages(country_code).to_csv(f'data/query_urgent_market_messages_{country_code}.csv',sep = ';')
# client.query_tariffs(start = start, end = end, country_code = country_code).to_csv(f'data/query_tariffs_{country_code}.csv',sep = ';')
# client.query_tariffs_sim(start = start, end = end, country_code = country_code).to_csv(f'data/query_tariffs_sim_{country_code}.csv',sep = ';')
# client.query_aggregated_data(start = start, end = end, country_code = country_code).to_csv(f'data/query_aggregated_data_{country_code}.csv',sep = ';')
# client.query_interruptions(start = start, end = end, country_code = country_code, limit = 1_000).to_csv(f'data/query_interruptions_{country_code}.csv',sep = ';')
# client.query_CMP_auction_premiums(start = start, end = end, country_code = country_code).to_csv(f'data/query_CMP_auction_premiums_{country_code}.csv',sep = ';')
# client.query_CMP_unavailable_firm_capacity(start = start, end = end, country_code = country_code).to_csv(f'data/query_CMP_unavailable_firm_capacity_{country_code}.csv',sep = ';')
# client.query_CMP_unsuccesful_requests(start = start, end = end, country_code = country_code).to_csv(f'data/query_CMP_unsuccesful_requests_{country_code}.csv',sep = ';')
#client.query_operational_data(start = start, end = end, indicators = ['nominations','allocation', 'physical_flow']).to_csv(f'data/query_operational_data_{country_code}.csv',sep = ';')
# collection = []
# PERIOD_TYPE='day'
# for c in Country:
# try:
# country = c.code
# print(country)
# data = client.query_aggregated_data(start = start, end = end, country_code = country,period_type= PERIOD_TYPE, group_type = 'country',entry_exit = False)
# collection.append(data)
# except:
# next
# big = pd.concat(collection)
#big.to_csv('data/query_aggregated_data_ALL_COUNTRIES_22.csv',sep=';')
#client.query_aggregated_data(start = start, end = end, country_code = country_code,period_type='hour', group_type = 'point',entry_exit = False).to_csv(f'data/query_aggregated_data_{country_code}.csv',sep = ';')
balancing_zone = 'DE_GASPOOL'
#client.query_aggregated_data(start = start, end = end, balancing_zone = balancing_zone, group_type = 'balancing_zone',entry_exit = True).to_csv(f'data/query_aggregated_data_{balancing_zone}.csv',sep = ';')
#client.get_grouped_operational_aggregates(start = start, end = end, indicators = ['physical_flow'], country_code= country_code, period_type= 'day', groups = ['country'])['country'].to_csv(f'data/get_operational_aggregates_{country_code}.csv',sep = ';')
import time
tik = time.time()
data = client.query_tariffs_sim(
start = start,
end = end,
country_code= country_code,
verbose = False,
melt = True
)
tok = time.time()
print(data)
print(f'Script took: {(tok-tik)/60} minutes')
#get_area()