Skip to content

Commit

Permalink
Merge pull request #27 from openclimatefix/pvnet_gsp_sum_properties
Browse files Browse the repository at this point in the history
Add properties only when not empty
  • Loading branch information
dfulu authored Nov 13, 2023
2 parents 414acc2 + 601274a commit a4efeae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pvnet_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,24 @@ def convert_dataarray_to_forecasts(

forecast_value_sql.adjust_mw = 0.0

forecast_value_sql.properties = {}
properties = {}

if "forecast_mw_plevel_10" in gsp_forecast_values_da.output_label:
val = this_da.sel(output_label="forecast_mw_plevel_10").item()
# `val` can be NaN if PVNet has probabilistic outputs and PVNet_summation doesn't,
# or if PVNet_summation has probabilistic outputs and PVNet doesn't.
# Do not log the value if NaN
if not np.isnan(val):
forecast_value_sql.properties["10"] = val
properties["10"] = val

if "forecast_mw_plevel_90" in gsp_forecast_values_da.output_label:
val = this_da.sel(output_label="forecast_mw_plevel_90").item()

if not np.isnan(val):
forecast_value_sql.properties["90"] = val
properties["90"] = val

if len(properties)>0:
forecast_value_sql.properties = properties

forecast_values.append(forecast_value_sql)

Expand Down

0 comments on commit a4efeae

Please sign in to comment.