i want to use astropy for fitting spectra my code is:
from astropy.io import fits
from astropy.modeling import models, fitting
import math
import numpy as np
import pylab as plb
import matplotlib.pyplot as plt
#after opening the fits file and reading its data pixel by pixel
# fitting for the spectra at a pixel
x = velocity
y = ant_tem
g_init = models.Gaussian1D(amplitude=1., mean=0, stddev=1.)
f1 = fitting.NonLinearLSQFitter()
g = f1(g_init, x,y)
# Plot the data with the best-fit model
plt.figure(figsize=(8,5))
plt.plot(x, y, 'ko')
plt.plot(x, g(x), 'r-', lw=2, label='Gaussian')
plt.xlabel('Velocity')
plt.ylabel('Antenne Temperature')
plt.legend(loc=2)
` But my code is giving me the following error:
in <module>
f1 = fitting.NonLinearLSQFitter().
AttributeError: 'module' object has no attribute 'NonLinearLSQFitter'
Please suggest what should i do?