Skip to content

Commit cf772e5

Browse files
authored
Fetch ned-nl data up to midnight today and discard future timestamps for historic
1 parent beccbca commit cf772e5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

solar_consumer/data/fetch_nl_data.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def fetch_nl_data(historic_or_forecast: str = "generation"):
6868

6969
# Define date range
7070
if historic_or_forecast == "generation":
71-
end_date = now
71+
end_date = now.replace(hour=0) + timedelta(days=1) # to ~ midnight tonight
7272
start_date = end_date - timedelta(days=2)
7373
else:
7474
# For forecast data, set start_date to 2 hours in the past from the current time
@@ -174,6 +174,10 @@ def fetch_nl_data(historic_or_forecast: str = "generation"):
174174
)
175175

176176
# remove any future data
177+
if historic_or_forecast == "generation":
178+
# we pull a bit of future data, so update to only return historic values
179+
end_date = now
180+
177181
all_data = all_data[all_data["target_datetime_utc"] <= end_date]
178182
all_data = all_data[all_data["target_datetime_utc"] >= start_date]
179183

0 commit comments

Comments
 (0)