Skip to content

Commit

Permalink
and national creation utc limit, start and end target times
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Sep 26, 2023
1 parent c996960 commit 9b5aac8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/national.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -68,15 +75,27 @@ 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]

forecast = NationalForecast.from_orm_latest(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(
Expand Down

0 comments on commit 9b5aac8

Please sign in to comment.