Python astropy:属性错误无法导入管件
我想使用astropy拟合光谱我的代码是:Python astropy:属性错误无法导入管件,python,curve-fitting,astropy,Python,Curve Fitting,Astropy,我想使用astropy拟合光谱我的代码是: 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 # fitt
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)
`
但我的代码给了我以下错误:
in <module>
f1 = fitting.NonLinearLSQFitter().
AttributeError: 'module' object has no attribute 'NonLinearLSQFitter'
Please suggest what should i do?
in
f1=拟合。非线性lsqfitter()。
AttributeError:“模块”对象没有属性“非线性SQfitter”
请建议我该怎么做?
您正在使用astropy 0.3或更早版本的文档。非线性SQfitter
已在astropy 0.4及更高版本中重命名为LevMarLSQFitter
。改用它。您使用的是astropy 0.3或更早版本的文档。非线性SQfitter在astropy 0.4中更名为LevMarLSQFitter。用它来代替。