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)
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)