-
Notifications
You must be signed in to change notification settings - Fork 0
/
getData.py
61 lines (51 loc) · 2.28 KB
/
getData.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
import pandas as pd
# to get and store data
import entsoeAPI as e
import datetime
import time
import util as u
# import logging
# logging.basicConfig(filename='app.log', format='%(name)s - %(levelname)s - %(message)s',level="INFO")
# TODO this code requires some changes to save files in data folder check updateDate.py
def getCountryList():
compList1 = ["DE","FR", "BE","BG","HR","CZ","DK","EE","FI","GR","HU","IT","XK",]
compList2 = ["LV","LT","LU","ME","NL","MK","NO","PL","PT","RO","SK","SI","ES","SE","CH"]
# l15=["DE","HU","NL","LU"]
return compList1 + compList2
def generateInitialFileName(options,type):
f = options["country"]+"-"+type
return f
def saveHistoricalActualData(options):
fname = generateInitialFileName(options,"actual")
try:
data = e.get_actual_percent_renewable(options["country"],options["start"],options["end"],options["interval60"])
data.to_csv("./test/raw-"+fname+".csv")
except Exception as error :
print(error)
def saveHistoricalForecastData(options):
fname = generateInitialFileName(options,"forecast")
try:
data = e.get_forecast_percent_renewable(options["country"],options["start"],options["end"])
data.to_csv("./data/"+fname+".csv")
except Exception as error :
print(error)
def getTestData():
cont = getCountryList()
for c in cont :
print(c)
saveHistoricalActualData({"start":"202301010000","end":"202301070000","country":c,"interval60":False})
saveHistoricalForecastData({"start":"202301010000","end":"202301070000","country":c})
print("====done====")
# getActualDataForAllCountries()
# getTestData()
def saveHistoricalActualData1(options):
"""The new method"""
fname = generateInitialFileName(options,"actual")
try:
data,duration = e.get_actual_energy_production(options["country"],options["start"],options["end"],options["interval60"])
data = u.calculate_energy_values(data)
data.to_csv("./data/"+fname+"-"+str(int(duration))+".csv")
except Exception as error :
print(error)
# saveHistoricalActualData1({"start":"202001010000","end":"202001100000","country":"DE","interval60":False})
# saveHistoricalActualData1({"start":"202001010000","end":"202312310000","country":"DE","interval60":False})