threeML / astromodels

Spatial and spectral models for astrophysics
BSD 3-Clause "New" or "Revised" License
43 stars 44 forks source link

Fix super exponential cutoff PL #188

Closed henrikef closed 2 years ago

henrikef commented 2 years ago

Fix the super-exponential cutoff PL in the numba functions.

The log of the value needs to be

        log_v = index * np.log(x[i] / piv) - (x[i] / xc)**gamma

instead of

        log_v = index * np.log(x[i] / piv) - gamma*(x[i] / xc)

In the latter, xc and gamma were degenerate (so this was equivalent to an exponential cutoff PL with cutoff energy xc/gamma, not a true superexponential cutoff PL).

In the distant past, the function looked like this:

return K * np.power(np.divide(x, piv), index) * np.exp(-1 * np.divide(x, xc)**gamma)

@grburgess please let me know if there's anyhing you'd like to do to speed up the (x[i] / xc)**gamma term.

codecov-commenter commented 2 years ago

Codecov Report

Merging #188 (057acf9) into dev (751f206) will not change coverage. The diff coverage is 0.00%.

@@           Coverage Diff           @@
##              dev     #188   +/-   ##
=======================================
  Coverage   81.86%   81.86%           
=======================================
  Files          66       66           
  Lines        8119     8119           
=======================================
  Hits         6647     6647           
  Misses       1472     1472           
grburgess commented 2 years ago

@henrikef maybe with a np.power call? or some numba? otherwise looks good.