Skip to content

Commit

Permalink
Bug in filter_inversion_output (#1635)
Browse files Browse the repository at this point in the history
* check number of gridpoints in filter_inversion_output

* small adaptation
  • Loading branch information
pat-schmitt authored Oct 26, 2023
1 parent db634e5 commit 2954359
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions oggm/core/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ def filter_inversion_output(gdir, n_smoothing=5, min_ice_thick=1.,
cls = gdir.read_pickle('inversion_output')
cl = cls[-1]

# check that their are enough grid points for smoothing
nr_grid_points = len(cl['thick'])
if nr_grid_points <= n_smoothing:
if nr_grid_points >= 3:
n_smoothing = nr_grid_points - 1
else:
log.warning(f'({gdir.rgi_id}) filter_inversion_output: flowline '
f'has not enough grid points for applying the filter '
f'(only {nr_grid_points} grid points)!')
# Return volume for convenience
return np.sum([np.sum(cl['volume']) for cl in cls])

# convert to negative number for indexing
n_smoothing = -abs(n_smoothing)

Expand Down

0 comments on commit 2954359

Please sign in to comment.