astropy / photutils

Astropy package for source detection and photometry. Maintainer: @larrybradley
https://photutils.readthedocs.io
BSD 3-Clause "New" or "Revised" License
240 stars 134 forks source link

WARNING: No meaningful fit was possible. [photutils.isophote.ellipse] error when slightly changing galaxy centre #1696

Closed shruti-ramaiya closed 2 months ago

shruti-ramaiya commented 7 months ago

I am currently using photutils Ellipse() method to fit isophotes around galaxies.

I am set to run the code on many galaxy images but for now I am just experimenting getting code to run on a single image.

I have two images of the same galaxy. One of the images is centered on the galaxy and one is very slightly offset from the centre of the galaxy.

When starting with the basic Ellipse() method and not including the geometry argument (i.e. so the fit starts from the image centre):

a) on the image where the galaxy is slightly off centre (but ellipse is still fitting from the image centre), a resulting fit is successfully produced

however,

b) when running ellipse on the image where the galaxy is centered, it says: WARNING: No meaningful fit was possible. [photutils.isophote.ellipse]

The reason for opening this issue is that I am unsure if this is caused the images or is an issue with how the code is fitting in the background.

For both images, the one slightly 'off centre' has pixel positions (149, 149) and checking the galaxy centre for the same image gives pixel values (152,157), so reasonably close to each other.

I was just wondering if anyone was able to provide insight into the reason for getting an error for the slight shift in position in this case where, since I am omitting the geometry argument, the only changed variable is the galaxy position. Understanding this will help me know how to proceed when running code on thousands of galaxies and how I can combat this to avoid loss of data from unsuccessful fits. I was unable to find insight into the cause of this issue online but any guidance on how to work around would be most appreciated.

Thank you

larrybradley commented 7 months ago

@shruti-ramaiya I would recommend using a centroiding algorithm to define your initial guesses for the centers. In your example, you are 8.5 pixels away from the true center. I think you need a better starting guess. Also, if your galaxies do not have elliptical isophotes, then the ellipse-fit is not going to give good results and it's not surprising that it could fail (not converge).

shruti-ramaiya commented 6 months ago

Thanks Larry, I'll look at using a centroiding algorithm for my initial guesses