Skip to content

Commit

Permalink
Bug when some bin_variables for elevation bands are NaN (#1602)
Browse files Browse the repository at this point in the history
* only drop NaNs if all bin_variables are NaN

* check if any bin_variables given in elevation_band_flowline before dropping NaNs
  • Loading branch information
pat-schmitt committed Jul 3, 2023
1 parent 15ff031 commit fc8ed12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion oggm/core/centerlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,11 @@ def elevation_band_flowline(gdir, bin_variables=None, preserve_totals=True):
df['width'] = df['area'] / df['dx']

# Remove possible NaNs from above
df = df.dropna()
if not bin_variables:
df = df.dropna()
else:
# only remove if all bin_variables are NaN
df = df.dropna(how='all', subset=bin_variables)

# Check for binned vars
for var, data, in_total, do_p in zip(bin_variables, out_vars, out_totals,
Expand Down

0 comments on commit fc8ed12

Please sign in to comment.