Skip to content

Commit 11f4b03

Browse files
authored
2026.01.0.rc1 (#503)
* added knmi weerstation to logging added flexibel start_day training * implemenetd week_nr and angle_of_inc as feature * catch error when solar_entitie is not encapsulated in a list * catch error when one solar_entity is not encapsulated in a list * catch error when one solar_entity is not encapsulated in a list in da_report * implemented solar_name with possible spaces * calculate tilt, azimuth and capacity of device from settings in string * calculate tilt, azimuth and capacity of device from settings in string * commented line wich removes data with irradiance and solar_kwh both == 0 * fixed error when there more entities for one solar device * reformat files * 2026.01.0.rc1
1 parent 3129b4f commit 11f4b03

File tree

11 files changed

+514
-268
lines changed

11 files changed

+514
-268
lines changed

dao/prog/da_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ def calc_baseloads():
588588
@staticmethod
589589
def train_ml_predictions():
590590
from dao.prog.solar_predictor import SolarPredictor
591+
591592
solar_predictor = SolarPredictor()
592593
solar_predictor.run_train()
593594

dao/prog/da_graph.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ def build(self, df, options, show=True):
143143
stacked = False
144144
for serie in g_options["series"]:
145145
s_type = serie["type"]
146-
if s_type == "bar" or s_type== "stacked":
146+
if s_type == "bar" or s_type == "stacked":
147147
count_bar += 1
148-
if s_type =="stacked":
148+
if s_type == "stacked":
149149
if stacked:
150150
count_bar -= 1
151151
else:
152152
stacked = True
153-
bar_width = 1/(count_bar+1)
153+
bar_width = 1 / (count_bar + 1)
154154
nr_bar = 0
155155
stacked = False
156156
for serie in g_options["series"]:
@@ -192,15 +192,15 @@ def build(self, df, options, show=True):
192192
ymin_right = math.floor(min(ymin_right, min(data_array)))
193193
if s_type == "bar" or s_type == "stacked":
194194
nr_bar += 1
195-
if s_type =="stacked":
195+
if s_type == "stacked":
196196
if stacked:
197197
nr_bar -= 1
198198
else:
199199
stacked = True
200200

201201
if s_type == "bar":
202202
plot = ax_serie.bar(
203-
ind + (nr_bar-count_bar)*bar_width + bar_width,
203+
ind + (nr_bar - count_bar) * bar_width + bar_width,
204204
data_array,
205205
label=label,
206206
width=width,

dao/prog/da_prices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_prices(self, source):
4444
end = start + datetime.timedelta(days=2)
4545

4646
if len(sys.argv) <= 2:
47-
present = self.db_da.get_time_latest_record("da")
47+
present = self.db_da.get_time_border_record("da")
4848
if not (present is None):
4949
tz = pytz.timezone("CET")
5050
present = tz.normalize(tz.localize(present))

dao/prog/da_report.py

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -723,39 +723,45 @@ def __init__(
723723
"haxis": {"values": "uur", "title": "uren van de dag"},
724724
"graphs": [
725725
{
726-
"vaxis": [{"title": "J/cm2"},{"title": "kWh"}],
726+
"vaxis": [{"title": "J/cm2"}, {"title": "kWh"}],
727727
"series": [
728-
{"column": "prognose_straling",
729-
"title": "Straling prognose",
730-
"type": "line",
731-
"color": "purple"},
732-
{"column":"gemeten_straling",
728+
{
729+
"column": "prognose_straling",
730+
"title": "Straling prognose",
731+
"type": "line",
732+
"color": "purple",
733+
},
734+
{
735+
"column": "gemeten_straling",
733736
"title": "Straling gemeten",
734737
"source": "da",
735738
"type": "line",
736-
"color": "red"
739+
"color": "red",
737740
},
738-
{"column": "gemeten_prod",
741+
{
742+
"column": "gemeten_prod",
739743
"title": "Productie gemeten",
740-
"vaxis" : "right",
744+
"vaxis": "right",
745+
"type": "bar",
746+
"color": "blue",
747+
},
748+
{
749+
"column": "prognose_dao",
750+
"vaxis": "right",
741751
"type": "bar",
742-
"color": "blue",
752+
"title": "Prod. progn. DAO",
753+
"color": "yellow",
743754
},
744-
{"column": "prognose_dao",
745-
"vaxis": "right",
746-
"type": "bar",
747-
"title": "Prod. progn. DAO",
748-
"color": "yellow",
755+
{
756+
"column": "prognose_ml",
757+
"vaxis": "right",
758+
"type": "bar",
759+
"title": "Prod. progn. ml",
760+
"color": "green",
749761
},
750-
{"column": "prognose_ml",
751-
"vaxis": "right",
752-
"type": "bar",
753-
"title": "Prod. progn. ml",
754-
"color": "green"
755-
}
756-
]
762+
],
757763
}
758-
]
764+
],
759765
}
760766

761767
"""
@@ -2971,23 +2977,27 @@ def get_price_data(self, start, end, interval: str = "1hour"):
29712977
]
29722978
return df
29732979

2974-
def calc_solar_data(self, device: dict, day:datetime.date, active_view:str):
2975-
result = pd.DataFrame(columns=["uur", "straling", "werkelijk", "prognose DAO", "prognose ML"])
2980+
def calc_solar_data(self, device: dict, day: datetime.date, active_view: str):
2981+
result = pd.DataFrame(
2982+
columns=["uur", "straling", "werkelijk", "prognose DAO", "prognose ML"]
2983+
)
29762984
start = datetime.datetime(day.year, day.month, day.day)
29772985
end = start + datetime.timedelta(days=1)
29782986

29792987
# prognose straling
29802988
result = self.get_da_data("gr", start, end, "uur", "uur", "prognoses")
2981-
result.rename({"gr" : "prognose_straling"}, inplace=True, axis=1)
2982-
result.drop(columns=["vanaf","tot"], inplace=True)
2989+
result.rename({"gr": "prognose_straling"}, inplace=True, axis=1)
2990+
result.drop(columns=["vanaf", "tot"], inplace=True)
29832991

29842992
# gemeten straling
29852993
rad_real = self.get_da_data("gr", start, end, "uur", "uur", "values")
29862994
result["gemeten_straling"] = rad_real["gr"]
29872995

29882996
# gemeten productie
29892997
sensors = self.config.get(["entities sensors"], device, [])
2990-
count=0
2998+
if not isinstance(sensors, list):
2999+
sensors = [sensors]
3000+
count = 0
29913001
for sensor in sensors:
29923002
df_sensor = self.get_sensor_data(sensor, start, end, "gemeten")
29933003
if count == 0:
@@ -2998,32 +3008,52 @@ def calc_solar_data(self, device: dict, day:datetime.date, active_view:str):
29983008
result["gemeten_prod"] = df_solar["gemeten"]
29993009

30003010
# voorspelling DAO
3001-
pred_dao= []
3011+
pred_dao = []
30023012
for row in result.itertuples():
3003-
prod = self.calc_prod_solar(device, row.tijd.timestamp(), row.prognose_straling, 1)
3013+
prod = self.calc_prod_solar(
3014+
device, row.tijd.timestamp(), row.prognose_straling, 1
3015+
)
30043016
pred_dao.append(prod)
30053017
result["prognose_dao"] = pred_dao
30063018

30073019
# voorspelling ML
30083020
from dao.prog.solar_predictor import SolarPredictor
3021+
30093022
solar_predictor = SolarPredictor()
3010-
solar_prog = solar_predictor.predict_solar_device(device["name"], start, end)
3023+
solar_prog = solar_predictor.predict_solar_device(device, start, end)
30113024
solar_prog.index = pd.to_datetime(solar_prog["date_time"]).dt.tz_localize(None)
30123025
result["prognose_ml"] = solar_prog["prediction"]
30133026

30143027
result.drop(columns=["tijd"], inplace=True)
3015-
result = result[['uur', 'gemeten_straling', 'prognose_straling',
3016-
"gemeten_prod", "prognose_dao", "prognose_ml"]]
3017-
if active_view=="tabel":
3018-
r2_radiation = calc_r2(result["gemeten_straling"], result["prognose_straling"])
3028+
result = result[
3029+
[
3030+
"uur",
3031+
"gemeten_straling",
3032+
"prognose_straling",
3033+
"gemeten_prod",
3034+
"prognose_dao",
3035+
"prognose_ml",
3036+
]
3037+
]
3038+
if active_view == "tabel":
3039+
r2_radiation = calc_r2(
3040+
result["gemeten_straling"], result["prognose_straling"]
3041+
)
30193042
r2_dao = calc_r2(result["gemeten_prod"], result["prognose_dao"])
30203043
r2_ml = calc_r2(result["gemeten_prod"], result["prognose_ml"])
30213044
result.loc["Total"] = result.sum(axis=0, numeric_only=True)
30223045
result.at[result.index[-1], "uur"] = "Totaal"
30233046
result.columns = [
3024-
["", "Straling", "Straling", "Productie","Productie", "Productie"],
3025-
["uur", "gemeten", "prognose", "gemeten", "prognose dao", "prognose ml"],
3026-
["", "J/cm2", "J/cm2", "kWh", "kWh", "kWh"]
3047+
["", "Straling", "Straling", "Productie", "Productie", "Productie"],
3048+
[
3049+
"uur",
3050+
"gemeten",
3051+
"prognose",
3052+
"gemeten",
3053+
"prognose dao",
3054+
"prognose ml",
3055+
],
3056+
["", "J/cm2", "J/cm2", "kWh", "kWh", "kWh"],
30273057
]
30283058
row = ["R²", "", r2_radiation, "", r2_dao, r2_ml]
30293059
result.loc[result.shape[0]] = row
@@ -3044,8 +3074,11 @@ def get_heatpump_run_hours(self, entity):
30443074
)
30453075
else:
30463076
sensor_data = self.get_sensor_sum(
3047-
sensor_list=self.wp_consumption_sensors, vanaf=vanaf, tot=now, col_name="hp"
3048-
)
3077+
sensor_list=self.wp_consumption_sensors,
3078+
vanaf=vanaf,
3079+
tot=now,
3080+
col_name="hp",
3081+
)
30493082
if len(sensor_data) == 0:
30503083
return -2
30513084
count = 0
@@ -3173,7 +3206,7 @@ def get_api_data(self, field: str, _periode: str, cumulate: bool = False):
31733206
result = '{ "message":"Success", "data": ' + data_json + " }"
31743207
return result
31753208

3176-
def make_graph(self, df, period, _options=None, _title:str|None=None):
3209+
def make_graph(self, df, period, _options=None, _title: str | None = None):
31773210
if _options:
31783211
options = _options
31793212
else:

0 commit comments

Comments
 (0)