You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
def get_power_profiles(start, end, country, in_local_time=True):
|
|
start = timestamp_to_utc(start)
|
|
end = timestamp_to_utc(end)
|
|
engine = db_engine("rop_test")
|
|
connection, table = create_connection(engine, "ImbalancePrices")
|
|
start = start.floor("15T")
|
|
query = (
|
|
select([table])
|
|
.where(
|
|
table.columns.QuarterStartTime >= start.strftime("%Y-%m-%d %H:%M"),
|
|
table.columns.QuarterStartTime < end.strftime("%Y-%m-%d %H:%M"),
|
|
table.columns.CountryIsoCode == country,
|
|
)
|
|
.order_by(table.columns.QuarterStartTime)
|
|
)
|
|
result = connection.execute(query).fetchall()
|
|
if len(result) == 0:
|
|
raise Exception("Day-ahead prices data not yet available.")
|
|
|
|
data = pd.DataFrame(result, columns=result[0].keys())
|
|
|
|
if in_local_time:
|
|
data["QuarterStartTime"] = dt_column_to_local_time(data["QuarterStartTime"])
|
|
|
|
data.drop(columns=["Id", "CountryIsoCode"], inplace=True)
|
|
data.rename(
|
|
columns={
|
|
"QuarterStartTime": "datetime",
|
|
"TakeFromGridPrice": "NEG",
|
|
"FeedToGridPrice": "POS",
|
|
},
|
|
inplace=True,
|
|
)
|
|
return data.set_index("datetime")[["POS", "NEG"]] |