Created
September 5, 2023 10:48
-
-
Save JohannesBuchner/cda64a762dcbb663853b0799eae7f8d1 to your computer and use it in GitHub Desktop.
Smoothly bending power law function of Ryde+98. The width of the bend can be controlled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sbpl(x, norm, lam1, lam2, x0, xbrk, Lambda): | |
"""Smoothly bending powerlaw | |
Parameterization from Ryde99 | |
https://ui.adsabs.harvard.edu/abs/1999ApL%26C..39..281R/abstract | |
Parameters | |
---------- | |
x: array of independent variable | |
xmax: only consider x values up to this value | |
norm: normalisation at x0 | |
lam1: powerlaw slope below xbrk | |
lam2: powerlaw slope above xbrk | |
xbrk: x value where powerlaw break occurs | |
Lambda: width of bend at xbrk | |
""" | |
with np.errstate(over='ignore'): | |
q = log(x/xbrk) / Lambda | |
qpiv = log(x0/xbrk) / Lambda | |
return norm * (x/x0)**((lam1 + lam2 + 2)/2.) * \ | |
((exp(q) + exp(-q))/(exp(qpiv) + exp(-qpiv))) ** ((lam2 - lam1)/2. * Lambda) * (x0 / x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment