Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add properties only when not empty #27

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading