Skip to content

Commit

Permalink
reduce number of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
lee1043 committed Jun 4, 2024
1 parent b5a64fe commit 6c12692
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pcmdi_metrics/monsoon_sperber/lib/calc_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def sperber_metrics(d, region, debug=False):
frac_accum = d / d_sum

# Stat 1: Onset
onset_index = (i for i, v in enumerate(frac_accum) if v >= 0.2)
onset_index = next(onset_index)
onset_index = next(i for i, v in enumerate(frac_accum) if v >= 0.2)
i = onset_index
v = frac_accum[i]

Expand All @@ -38,8 +37,7 @@ def sperber_metrics(d, region, debug=False):
else:
decay_threshold = 0.8

decay_index = (i for i, v in enumerate(frac_accum) if v >= decay_threshold)
decay_index = next(decay_index)
decay_index = next(i for i, v in enumerate(frac_accum) if v >= decay_threshold)

# Stat 3: Slope
slope = (frac_accum[decay_index] - frac_accum[onset_index]) / float(
Expand Down

0 comments on commit 6c12692

Please sign in to comment.