I am trying to fit an ellipse using Ellipse2D model in astropy library. The fit does not work. The modeled parameters are the same as initial parameters (maybe except the amplitude parameter). See the code below:
import numpy as np from astropy.modeling import models, fitting import matplotlib.pyplot as pl # fake data num = 100 x, y = np.meshgrid(np.linspace(-5., 5., num), np.linspace(-5, 5, num)) e0 = models.Ellipse2D(amplitude=1., x_0=0., y_0=0., a=2, b=1, theta=0.) z0 = e0(x, y) print 'DATA:\n', e0, '\n\n' # initial model ei = models.Ellipse2D(amplitude=1., x_0=0.0, y_0=0.0, a=2, b=2, theta=0.2) fi = fitting.LevMarLSQFitter() #fitted model? e1 = fi(ei, x, y, z0) z1 = e1(x, y) print 'MODEL:\n', e1, '\n\n' pl.imshow(z0, extent=[-5, 5, -5, 5], alpha=0.5) pl.imshow(z1, extent=[-5, 5, -5, 5], alpha=0.2) pl.show()