Skip to content

Commit

Permalink
Edit scaled volume parameter
Browse files Browse the repository at this point in the history
Fixed scaled volume parameter when there is no rain
  • Loading branch information
EsmailGhaemi authored Dec 26, 2023
1 parent 97e9a2b commit a2b6761
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions pysteps/verification/salscores.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,24 @@ def _sal_scaled_volume(precip_objects):
for _, precip_object in precip_objects.iterrows():
intensity_sum = np.nansum(precip_object.intensity_image)
max_intensity = precip_object.max_intensity
volume_scaled = intensity_sum / max_intensity
tot_vol = intensity_sum * volume_scaled
if intensity_sum == 0:
intensity_vol = 0

Check warning on line 395 in pysteps/verification/salscores.py

View check run for this annotation

Codecov / codecov/patch

pysteps/verification/salscores.py#L395

Added line #L395 was not covered by tests
else:
volume_scaled = intensity_sum / max_intensity
tot_vol = intensity_sum * volume_scaled
intensity_vol = tot_vol

objects_volume_scaled.append(
{"intensity_vol": tot_vol, "intensity_sum_obj": intensity_sum}
{"intensity_vol": intensity_vol, "intensity_sum_obj": intensity_sum}
)
df_vols = pd.DataFrame(objects_volume_scaled)
total_scaled_volum = (np.nansum(df_vols.intensity_vol)) / (
np.nansum(df_vols.intensity_sum_obj)
)

if df_vols.empty or (df_vols["intensity_sum_obj"] == 0).all():
total_scaled_volum = 0
else:
total_scaled_volum = np.nansum(df_vols.intensity_vol) / np.nansum(
df_vols.intensity_sum_obj
)
return total_scaled_volum


Expand Down

0 comments on commit a2b6761

Please sign in to comment.