@@ -201,12 +201,16 @@ async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData
201201 if reporting_data .empty and reporting_data_higher_fs .empty :
202202 raise NoDataAvailableError ("No reporting data available. Cannot proceed." )
203203
204- weather_data = transform_weather_data (
205- data = weather_data ,
206- weather_feature_names_mapping = config .weather_feature_names_mapping ,
207- time_zone = config .time_zone ,
208- verbose = config .verbose ,
209- )
204+ if not weather_data .empty :
205+ weather_data = transform_weather_data (
206+ data = weather_data ,
207+ weather_feature_names_mapping = config .weather_feature_names_mapping ,
208+ time_zone = config .time_zone ,
209+ verbose = config .verbose ,
210+ )
211+ lat_lon_pairs = _create_lat_lon_pairs (
212+ weather_data ["latitude" ].unique (), weather_data ["longitude" ].unique ()
213+ )
210214
211215 reporting_data = transform_reporting_data (
212216 data = reporting_data ,
@@ -232,10 +236,6 @@ async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData
232236 lambda x : abs (x ) if np .issubdtype (type (x ), np .number ) else x
233237 )
234238
235- lat_lon_pairs = _create_lat_lon_pairs (
236- weather_data ["latitude" ].unique (), weather_data ["longitude" ].unique ()
237- )
238-
239239 # display the results for each microgrid separately
240240 production_legend_label = tm .translate ("production" )
241241 patch_label = tm .translate ("current value" )
@@ -314,25 +314,31 @@ async def run_workflow(user_config_changes: dict[str, Any]) -> SolarAnalysisData
314314 [k for k in config .baseline_models if k != "weather-based-forecast" ],
315315 )
316316 if "weather-based-forecast" in config .baseline_models :
317- closest_grid_point = _find_closest_grid_point (
318- all_client_site_info [mid ]["latitude" ],
319- all_client_site_info [mid ]["longitude" ],
320- lat_lon_pairs ,
321- )
322- prediction_models .update (
323- prepare_prediction_models (
324- weather_data [
325- (weather_data ["latitude" ] == closest_grid_point [0 ])
326- & (weather_data ["longitude" ] == closest_grid_point [1 ])
327- & (
328- weather_data ["validity_ts" ]
329- <= config .end_timestamp + datetime .timedelta (hours = 1 )
330- )
331- ],
332- model_specs ,
333- ["weather-based-forecast" ],
317+ if weather_data .empty :
318+ reason = NoDataAvailableError ("No weather data available." )
319+ print (
320+ f"{ type (reason ).__name__ } : { reason } Skipping weather-based-forecast model."
321+ )
322+ else :
323+ closest_grid_point = _find_closest_grid_point (
324+ all_client_site_info [mid ]["latitude" ],
325+ all_client_site_info [mid ]["longitude" ],
326+ lat_lon_pairs ,
327+ )
328+ prediction_models .update (
329+ prepare_prediction_models (
330+ weather_data [
331+ (weather_data ["latitude" ] == closest_grid_point [0 ])
332+ & (weather_data ["longitude" ] == closest_grid_point [1 ])
333+ & (
334+ weather_data ["validity_ts" ]
335+ <= config .end_timestamp + datetime .timedelta (hours = 1 )
336+ )
337+ ],
338+ model_specs ,
339+ ["weather-based-forecast" ],
340+ )
334341 )
335- )
336342 # NOTE: the below is a hack until PV lib simulation is properly set up
337343 # (i.e. needs user input for the PV system parameters)
338344 if "simulation" in prediction_models :
0 commit comments