1
0
Fork 0
mirror of https://github.com/Findus23/halo_comparison.git synced 2024-09-19 16:03:50 +02:00
halo_comparison/nfw.py

17 lines
352 B
Python
Raw Normal View History

2022-06-23 10:07:10 +02:00
from numpy import inf
from scipy.optimize import curve_fit
def nfw(r, rho_0, r_s):
r_norm = r / r_s
return rho_0 / (r_norm * (1 + r_norm) ** 2)
def fit_nfw(radius, densities):
popt, pcov = curve_fit(
nfw, radius, densities,
verbose=1, method="trf", max_nfev=1000,
bounds=([0, 0], [inf, 1])
)
return popt