Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid RuntimeError due to nans in overschrijding #139

Closed
veenstrajelmer opened this issue Sep 9, 2024 · 0 comments · Fixed by #149
Closed

avoid RuntimeError due to nans in overschrijding #139

veenstrajelmer opened this issue Sep 9, 2024 · 0 comments · Fixed by #149
Assignees

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Sep 9, 2024

The function calc.calc_overschrijding() sometimes warns "RuntimeWarning: invalid value encountered in scalar power return -p_val_gt_threshold * (alpha * x**(alpha - 1)) * (sigma**(-alpha)) * np.exp(-((x/sigma)**alpha) + ((threshold/sigma)**alpha))". This for instance happens in test_calc_overschrijding. This happens due to nan values from powers like here. The source is optimize.minimize() and further down the line (sigma ** (-alpha)) (and others) in der_pfunc(). This happens in one of the iterations of the Nelder-Mead optimization function, might be resolvable by supplying additional settings.

Can be reproduced by checking np.isnan(sigma ** (-alpha)) in der_pfunc() when executing:

import os
import hatyan
import kenmerkendewaarden as kw

dir_base = r'p:\11210325-005-kenmerkende-waarden\work'
dir_meas = os.path.join(dir_base,'measurements_wl_18700101_20240101')

current_station = "VLISSGN"
df_ext_all = kw.read_measurements(dir_output=dir_meas, station=current_station, extremes=True)
df_ext_all_12 = hatyan.calc_HWLW12345to12(df_ext_all)

dist_exc = kw.calc_overschrijding(df_ext=df_ext_all_12, rule_type=None, rule_value=None, 
                                  clip_physical_break=True, 
                                  interp_freqs=[1])
@epsig epsig self-assigned this Oct 7, 2024
@epsig epsig linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants