From 9b5aac88e0a4e4919f64550aadc0cd072f58f059 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 26 Sep 2023 16:45:34 +0100 Subject: [PATCH] and national creation utc limit, start and end target times --- src/national.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/national.py b/src/national.py index f7e4613..51b9f1d 100644 --- a/src/national.py +++ b/src/national.py @@ -39,6 +39,9 @@ def get_national_forecast( forecast_horizon_minutes: Optional[int] = None, user: Auth0User = Security(get_user()), include_metadata: bool = False, + start_datetime_utc: Optional[str] = None, + end_datetime_utc: Optional[str] = None, + creation_limit_utc: Optional[str] = None, ) -> Union[NationalForecast, List[NationalForecastValue]]: """Get the National Forecast @@ -55,6 +58,10 @@ def get_national_forecast( #### Parameters - **forecast_horizon_minutes**: optional forecast horizon in minutes (ex. 60 returns the forecast made an hour before the target time) + - **start_datetime_utc**: optional start datetime for the query. + - **end_datetime_utc**: optional end datetime for the query. + - **creation_utc_limit**: optional, only return forecasts made before this datetime. + Note you can only go 7 days back at the moment """ logger.debug("Get national forecasts") @@ -68,7 +75,14 @@ def get_national_forecast( ) forecast = get_latest_forecast_for_gsps( - session=session, gsp_ids=[0], model_name="blend", historic=True, preload_children=True + session=session, + gsp_ids=[0], + model_name="blend", + historic=True, + preload_children=True, + start_target_time=start_datetime_utc, + end_target_time=end_datetime_utc, + start_created_utc=creation_limit_utc, ) forecast = forecast[0] @@ -76,7 +90,12 @@ def get_national_forecast( forecast_values = forecast.forecast_values else: forecast_values = get_latest_forecast_values_for_a_specific_gsp_from_database( - session=session, gsp_id=0, forecast_horizon_minutes=forecast_horizon_minutes + session=session, + gsp_id=0, + forecast_horizon_minutes=forecast_horizon_minutes, + start_datetime_utc=start_datetime_utc, + end_datetime_utc=end_datetime_utc, + creation_utc_limit=creation_limit_utc, ) logger.debug(