Example #1
0
from statkraft.ltm.io.run_repository import RunRepository
from statkraft.ltm.scripting import plot_ts, plot_percentiles
import matplotlib.pyplot as plt

rr = RunRepository()
labels = ["operational", "daily", "samtap sk"]
run_id = sorted(rr.search(labels=labels))[-1] # Pick newest
run = rr.recreate(run_id=run_id)

no1 = run.model.market.areas["NO1"] # shortcut variable
st1 = no1.power_price
mean = st1.mean()
plot_percentiles(no1.power_price.percentiles())
plt.figure()
plot_ts(no1.power_price.mean())

plt.show()
m = st1.mean
print(m)
Example #2
0
from statkraft.ltm.io.run_repository import RunRepository
import shyft.api as sa
from statkraft.ltm.scripting import plot_ts, plot_percentiles
from matplotlib import pyplot as plt
from statkraft.ltm.io.converter import to_pandas
import pandas as pd

rr = RunRepository()
t0 = sa.utctime_now()
run_id = rr.find_closest_operational_run(t0)

run = rr.recreate(run_id = run_id)
time_axis = sa.TimeAxis(run.start_utc, sa.Calendar.DAY,365)


prices = {}
df_tot = pd.DataFrame()

for area_name, area in run.model.areas.items():
    df, pip = to_pandas(area.power_price.mean(time_axis = time_axis))
    prices[area_name] = df.magnitude



Example #3
0
from statkraft.ltm.io.run_repository import RunRepository
import shyft.api as sa
from statkraft.ltm.state import quantity

t0 = sa.utctime_now()
labels = ["norway", "operational", "season"]

rr = RunRepository()
run_id = rr.find_closest_operational_run(t=t0, labels=labels)

run = rr.recreate(run_id=run_id)

time_axis = run.fine_time_axis
min_share = 0.01
prod_price_area = {}
for key, val in run.model.market.areas.items():
    for m_area in val.aggregation_list:
        prod = quantity(0, "GWh")
        m_area_hyd = m_area.detailed_hydro
        if not m_area_hyd is None:
            for pws in m_area_hyd.power_stations.values():
                if pws.statkraft_share > min_share:
                    print(pws)
                    prod += pws.production.mean(time_axis=time_axis,
                                                unit="GWh")
Example #4
0
import matplotlib.pyplot as plt
import shyft.api as sa
from statkraft.ltm.io.run_repository import RunRepository
from statkraft.ltm.scripting import plot_ts
from statkraft.ltm.state import quantity

rr = RunRepository()
rid = rr.find_closest_operational_run(sa.utctime_now())
run = rr.recreate(run_id=rid)

time_axis = sa.TimeAxis(run.start_utc, sa.Calendar.DAY, 52 * 7)

tsv = quantity(sa.TsVector(), "EUR/MWh")

legend_list = []
for area_name, area in run.model.areas.items():
    legend_list.append(area_name)
    tsv.extend(area.power_price.mean(time_axis=time_axis).magnitude)

plot_ts(tsv)
plt.legend(legend_list)
plt.show()
Example #5
0
from statkraft.ltm.io.run_repository import RunRepository
import shyft.api as sa
from statkraft.ltm.state import quantity
from statkraft.ltm.scripting import plot_ts
import matplotlib.pyplot as plt
from statkraft.ltm.io.converter import to_pandas

rr = RunRepository()
t0 = sa.utctime_now() - sa.Calendar.DAY * 2
res = rr.search(labels=["operational", "norway"], created_from=t0)
areas = ["NO1", "NO2", "NO5"]
tsv = quantity(sa.TsVector(), "GWh")

tot_cons_list = []
legend_list = []
for key in res.keys():
    run_info = res[key]
    run = rr.recreate(run_id=key)
    legend_list.append(key)
    time_axis = sa.TimeAxis(sa.utctime_now(), sa.Calendar.DAY, 365)
    tot_cons = quantity(sa.TsVector(), "GWh")
    for key1 in run.model.market.areas.keys():
        this_area = run.model.market.areas[key1]
        if key1 in areas:
            cons = this_area.consumption.mean(unit="GWh", time_axis=time_axis)
            tot_cons += cons
    tot_cons_list.append(tot_cons)

diff_cons = tot_cons_list[0] - tot_cons_list[1]
tsv.extend(diff_cons.magnitude)
Example #6
0
import matplotlib.pyplot as plt
import shyft.api as sa
from statkraft.ltm.io.run_repository import RunRepository
from statkraft.ltm.scripting import plot_ts

calendar = sa.Calendar("Europe/Oslo")
utc_start = calendar.time(2018, 7, 1)
time_axis = sa.TimeAxis(calendar, utc_start, calendar.QUARTER, 1)

now = sa.utctime_now()
then = now - calendar.WEEK

rr = RunRepository()
rid1 = rr.find_closest_operational_run(now)
rid2 = rr.find_closest_operational_run(then)

run1 = rr.recreate(run_id=rid1)
run2 = rr.recreate(run_id=rid2)

sp1 = run1.model.market.areas["NO2"].power_price.mean(time_axis=time_axis)
sp2 = run2.model.market.areas["NO2"].power_price.mean(time_axis=time_axis)

plot_ts(sp1 - sp2)
plt.legend([f"NO2 price difference: run[{rid1}] - run[{rid2}]"])
Example #7
0
from statkraft.ltm.io.run_repository import RunRepository
import shyft.api as sa
from statkraft.ltm.state import quantity

t0 = sa.utctime_now()
rr = RunRepository()
run_id = rr.find_closest_operational_run(t0, labels=['operational', 'norway', 'season'])

run = rr.recreate(run_id=run_id)