Skip to content

Commit

Permalink
More robust ELA computation (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Oct 6, 2017
1 parent 38ecf1c commit 393f249
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions oggm/core/models/massbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,15 @@ def get_ela(self, year=None):
return np.asarray([self.get_ela(year=yr) for yr in year])

if self.valid_bounds is None:
raise ValueError('valid_bounds attribute needs to be set for '
'ELA search.')
raise ValueError('attribute `valid_bounds` needs to be '
'set for the ELA computation.')

# Check for invalid ELAs
b0, b1 = self.valid_bounds
if (np.any(~np.isfinite(self.get_annual_mb([b0, b1], year=year))) or
(self.get_annual_mb([b0], year=year)[0] > 0) or
(self.get_annual_mb([b1], year=year)[0] < 0)):
return np.NaN

def to_minimize(x):
o = self.get_annual_mb([x], year=year)[0] * SEC_IN_YEAR * cfg.RHO
Expand Down

0 comments on commit 393f249

Please sign in to comment.