Wait, Troels, the problem here is not that the number is close to
infinity.  It is that numpy.cosh() can't handle numbers >> 100!  Try
running:

"""
from numpy import cosh
for i in range(10):
    print("cosh(%i+0.0j):  %s" % (i*100, cosh(i*100+0.j)))
"""

You will see:

"""
cosh(0+0.0j):  (1+0j)
cosh(100+0.0j):  (1.34405857091e+43+0j)
cosh(200+0.0j):  (3.61298688406e+86+0j)
cosh(300+0.0j):  (9.71213197621e+129+0j)
cosh(400+0.0j):  (2.61073484488e+173+0j)
cosh(500+0.0j):  (7.01796108926e+216+0j)
cosh(600+0.0j):  (1.88651015046e+260+0j)
cosh(700+0.0j):  (5.07116027368e+303+0j)
aaa.py:3: RuntimeWarning: overflow encountered in cosh
  print("cosh(%i+0.0j):  %s" % (i*100, cosh(i*100+0.j)))
aaa.py:3: RuntimeWarning: invalid value encountered in cosh
  print("cosh(%i+0.0j):  %s" % (i*100, cosh(i*100+0.j)))
cosh(800+0.0j):  (inf+nan*j)
cosh(900+0.0j):  (inf+nan*j)
"""

Therefore summing over the list and checking for isfinite() or isnan()
is no good, when you are looking for a small number.  I used 100 in
the lib.dispersion.cr72 module, but obviously this could be 200 or
300.

Regards,

Edward




On 11 May 2014 21:42, Troels E. Linnet <[email protected]> wrote:
> Follow-up Comment #4, bug #22032 (project relax):
>
> Acccording to these guys:
> http://stackoverflow.com/questions/6736590/fast-check-for-nan-in-numpy
>
> The fastest way to check for numpy errors is a sum of the list.
> That can then be checked for isfinite() or isnan()
>
>     # Skip the error search.
>     etapos = etapos_part / cpmg_frqs
>     etaneg = etaneg_part / cpmg_frqs
>     fact = Dpos * cosh(etapos) - Dneg * cos(etaneg)
>
>     if isfinite(sum(fact)):
>         R2eff =  r20_kex - cpmg_frqs * arccosh(fact)
>         for i in range(num_points):
>             back_calc[i] = R2eff[i]
>     else:
>         R2eff = array([10**7]*num_points)
>         for i in range(num_points):
>             back_calc[i] = R2eff[i]
>
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.isfinite.html
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.isnan.html
>
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.isinf.html
>
>     _______________________________________________________
>
> Reply to this item at:
>
>   <http://gna.org/bugs/?22032>
>
> _______________________________________________
>   Message sent via/by Gna!
>   http://gna.org/
>

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to