@@ -212,7 +212,7 @@ def get_all_gsp_ids_latest_forecast(
212
212
start_target_time : Optional [datetime ] = None ,
213
213
preload_children : Optional [bool ] = False ,
214
214
historic : bool = False ,
215
- forecast_horizon_hours : Optional [int ] = None ,
215
+ forecast_horizon_minutes : Optional [int ] = None ,
216
216
) -> List [ForecastSQL ]:
217
217
"""
218
218
Read forecasts
@@ -223,6 +223,9 @@ def get_all_gsp_ids_latest_forecast(
223
223
Filter: forecast values target time should be larger than this datetime
224
224
:param preload_children: Option to preload children. This is a speed up, if we need them.
225
225
:param historic: Option to load historic values or not
226
+ :param forecast_horizon_minutes: Optional filter on forecast horizon. For example
227
+ forecast_horizon_minutes=120, means load the forecast than was made 2 hours before the
228
+ target time. Note this only works for non-historic data.
226
229
227
230
return: List of forecasts objects from database
228
231
"""
@@ -236,7 +239,7 @@ def get_all_gsp_ids_latest_forecast(
236
239
preload_children = preload_children ,
237
240
historic = historic ,
238
241
gsp_ids = list (range (0 , N_GSP + 1 )),
239
- forecast_horizon_hours = forecast_horizon_hours ,
242
+ forecast_horizon_minutes = forecast_horizon_minutes ,
240
243
)
241
244
242
245
@@ -246,7 +249,7 @@ def get_latest_forecast_for_gsps(
246
249
start_target_time : Optional [datetime ] = None ,
247
250
preload_children : Optional [bool ] = False ,
248
251
historic : bool = False ,
249
- forecast_horizon_hours : Optional [int ] = None ,
252
+ forecast_horizon_minutes : Optional [int ] = None ,
250
253
gsp_ids : List [int ] = None ,
251
254
):
252
255
"""
@@ -259,8 +262,8 @@ def get_latest_forecast_for_gsps(
259
262
:param preload_children: Option to preload children. This is a speed up, if we need them.
260
263
:param historic: Option to load historic values or not
261
264
:param gsp_ids: Option to filter on gsps. If None, then only the lastest forecast is loaded.
262
- :param forecast_horizon_hours : Optional filter on forecast horizon. For example
263
- forecast_horizon_hours=2 , means load the forecast than was made 2 hours before the
265
+ :param forecast_horizon_minutes : Optional filter on forecast horizon. For example
266
+ forecast_horizon_minutes=120 , means load the forecast than was made 2 hours before the
264
267
target time. Note this only works for non-historic data.
265
268
266
269
return: List of forecasts objects from database
@@ -301,13 +304,13 @@ def get_latest_forecast_for_gsps(
301
304
302
305
from sqlalchemy import text
303
306
304
- if forecast_horizon_hours is not None :
307
+ if forecast_horizon_minutes is not None :
305
308
assert historic is False , Exception (
306
309
"Loading a forecast horizon only works on non latest data."
307
310
)
308
311
query = query .join (ForecastValueSQL ).filter (
309
312
ForecastValueSQL .target_time - ForecastValueSQL .created_utc
310
- >= text (f"interval '{ forecast_horizon_hours } hour'" )
313
+ >= text (f"interval '{ forecast_horizon_minutes } hour'" )
311
314
)
312
315
313
316
query = query .join (LocationSQL )
0 commit comments