Tusen takk for denne (og til han som har laget det)! Jeg kan ingenting om R, men siden han automatisk publiserer csv/json daglig er det lett å hente inn forecast for månedspris og strømstøtte fra modellen hans med f.eks. pandas og pyscript:
import pandas as pd
@pyscript_compile
def read_csv():
# Separate function for blocking I/O, using @pyscript_compile
url = "https://raw.githubusercontent.com/martinju/stromstotte/master/data/current_estimated_compensation.csv"
try:
df = pd.read_csv(url)
df = df[df["area"] == "NO2"] # Only look at region NO2
df = df.set_index("type")
out = {}
out["mean"] = df.loc["mean"]["mean_price"]
out["quantile_0.025"] = df.loc["quantile_0.025"]["mean_price"]
out["quantile_0.975"] = df.loc["quantile_0.975"]["mean_price"]
return out, None
except Exception as exc:
return None, exc
@time_trigger("cron(@daily)")
def get_forecast():
result, exception = task.executor(read_csv)
if exception:
raise exception
else:
pyscript.forecast_monthly_electricity_price_mean = round(result["mean"], 3)
pyscript.forecast_monthly_electricity_price_quantile_0_025 = round(result["quantile_0.025"], 3)
pyscript.forecast_monthly_electricity_price_quantile_0_975 = round(result["quantile_0.975"], 3)