Skip to content

Commit

Permalink
added better exception if QDM/presrat returns NaN values
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbuster committed Nov 5, 2024
1 parent e5df5d0 commit 6e46d6c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sup3r/bias/bias_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,13 @@ def local_qdm_bc(
output = np.maximum(output, np.min(out_range))
output = np.minimum(output, np.max(out_range))

if np.isnan(output).any():
msg = ('Presrat bias correction resulted in NaN values! If this is a '
'relative QDM, you may try setting ``delta_denom_min`` or '
'``delta_denom_zero``')
logger.error(msg)
raise RuntimeError(msg)

return output


Expand Down Expand Up @@ -944,6 +951,13 @@ def _apply_presrat_bc(data, time_index, base_params, bias_params,
data_unbiased = np.maximum(data_unbiased, np.min(out_range))
data_unbiased = np.minimum(data_unbiased, np.max(out_range))

if np.isnan(data_unbiased).any():
msg = ('Presrat bias correction resulted in NaN values! If this is a '
'relative QDM, you may try setting ``delta_denom_min`` or '
'``delta_denom_zero``')
logger.error(msg)
raise RuntimeError(msg)

return data_unbiased


Expand Down

0 comments on commit 6e46d6c

Please sign in to comment.