These are chat archives for astropy/astropy

21st
Mar 2017
Thomas Spriggs
@tspriggs
Mar 21 2017 15:31
so should I be using fit_deriv(x, self) and then write self. infront of all the parameters? or just add self on somewhere in fit_deriv? i.e. fit_deriv(x, amplitude_0, mean_0, stddev_0, self)
Thomas Spriggs
@tspriggs
Mar 21 2017 16:17
Ok, so I think I fixed the above issue by adding in the @staticmethod above fit_deriv, now my only problem is this RuntimeWarning: overflow encountered in exp
Thomas Spriggs
@tspriggs
Mar 21 2017 17:35
anyone know what might be causing this from this custom gaussian model?
class Gaussian_OIII(Fittable1DModel):
amplitude_0 = Parameter()
mean_0 = Parameter()
stddev_0 = Parameter()
amplitude_1 = Parameter()
mean_1 = Parameter()
@staticmethod
def evaluate(x, amplitude_0, mean_0, stddev_0, amplitude_1, mean_1):
    return amplitude_0 * np.exp(- 0.5 * (x - mean_0) ** 2 / stddev_0 ** 2) + amplitude_1 * np.exp(- 0.5 * (x - (mean_1) ** 2 / stddev_0 ** 2))


@staticmethod
def fit_deriv(x, amplitude_0, mean_0, stddev_0, amplitude_1, mean_1):
    d_amplitude_0 = np.exp(-0.5 * ((x - mean_0) ** 2)/ (stddev_0 ** 2))
    d_amplitude_1 = (1/3 * np.exp(- 0.5 * (x - (mean_1) ** 2 / stddev_0 ** 2)))
    d_mean_0 = (amplitude_0 * np.exp(-0.5 * ((x - mean_0) ** 2)/ (stddev_0 ** 2)) * (x - mean_0) / stddev_0 ** 2)
    d_mean_1 = (-1* amplitude_1 * (x-mean_1) *np.exp(- 0.5 * (x - mean_1) ** 2 / stddev_0 ** 2))/stddev_0**2
    d_stddev_0 = amplitude_0 * np.exp(-0.5 * ((x - mean_0) ** 2)/ (stddev_0 ** 2)) * (x - mean_0) ** 2 / stddev_0 ** 3 + (amplitude_1 * (x-mean_1)**2 * np.exp(- 0.5 * (x - mean_1) ** 2 / stddev_0 ** 2)/stddev_0**3)
    return [d_amplitude_0, d_mean_0, d_stddev_0, d_amplitude_1, d_mean_1]