2
$\begingroup$

I have recovered the following LOSVD from an elliptical galaxy, that I now want to fit a gauss-hermite-parametrization to and derive the kinematical parameters rotational velocity, velocity dispersion and hermite moments h3 and h4. enter image description here The gauss hermite parametrization consists of a classical gaussian and hermite polynoms. I am only looking at the hermite moments h3 (skewness of the curve, asymmetric) and h4 (kurtosis, symmetric). The parametrization I want to use has the following formula (everything is a function of velocities v).

enter image description here

I have written this function in python:

    def losvd_param(v, v_rot, v_disp, h3, h4):
    """parametrized LOSVD, to create a synthetic galaxy spectrum"""
    y = np.asarray((np.asarray(v)-v_rot)/(v_disp))        # define new variably y for compact notation
    return (np.exp(-0.5 * y**2) * (1 + h3*((2*np.sqrt(2)*y**3-3*np.sqrt(2)*y)/np.sqrt(6)) + h4*((4*y**4-12*y**2+3)/np.sqrt(24))))

This parametrization should work fine plugging in approximate values reading off the data:

plt.plot(vel_corr_peak, losvd_param(vel_corr_peak, 1318, 300, 0, 0), label='read of fit')

Resulting in the plot:

enter image description here

If I know try to fit using curve_fit from the scipy.optimize library, I dont get the values that I expect at all (saying I get 1s for all parameters).

gh_moments = curve_fit(losvd_param, vel_corr_peak, broadening_func)[0]
print(gh_moments)

Output: [1. 1. 1. 1.] and not as expected roughly [1318, 300, 0, 0] h3 and h4 can have small positive or negative values. Can anybody tell me what could be the problem here ?

$\endgroup$

1 Answer 1

3
$\begingroup$

If you read the documentation for the curve_fit function, you’ll see that it has an optional parameter (p0) for the initial guess for the parameter values. Since you didn’t provide anything for this, it defaults to 1 for all parameter values. Since these were then returned as the output, it means the fit failed to converge (probably because [1,1,1,1] is much too far away from the true values). Try running it with sensible initial-guess values for the parameters.

$\endgroup$
2
  • $\begingroup$ I have tried arround with different guesses for the initial values, and my results differ by a lot. The problem I keep getting is that even with the initial parameter guesses relatively close the fit data still differs significantly from my real data. Also small changes in my initial guesses give me huge differences in my final fit. f.e. initial guess [1250, 200, 0, 0] gives me the fit [ 929.68956083 1277.90277059 -10.92366431 9.70117469] which is wrong. contrary the initial guess [1000, 100, 1, 1] results in the fit [-387.78 720.37 7.72 5.54] which is also totally off $\endgroup$
    – trynerror
    Commented May 10, 2022 at 9:40
  • 1
    $\begingroup$ I don't know if I can help at this point. There may be something pathological about your "data" (aside from it being smooth and noiseless) and the fact that you haven't defined any sigma values, though if I define "data" as xx = np.arange(500, 2250, 1) and yy = losvd_param(xx, 1300, 300, 0, 0) and then call p = curve_fit(losvd_param, xx, yy, p0=[1250, 250, 0, 0]) (smooth "data", no sigmas), I get [1300, 300, 1e-10, 2e-10]. (And similarly for p0=[1000,100,0,0].) $\endgroup$ Commented May 10, 2022 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .