astropy / photutils

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

Can I fix (not fit) certain parameters of ellipse? #893

Closed iskren-y-g closed 5 years ago

iskren-y-g commented 5 years ago

Hi,

is it possible fix (not fit) the center or ellipticity or PA with Ellipse or ellipse.fit_image? Maybe I missed it, but it is unclear to me from the documentation whether this is possible. In certain cases this is very important.

Thanks, Iskren

larrybradley commented 5 years ago

@ibusko?

ibusko commented 5 years ago

I am afraid that we don't provide the capability to fix a single parameter, such as the center of the ellipse, or its position angle, or ellipticity. What the code can do is to fix the entire ellipse and just extract the intensity sample and output it.

I believe the reason for not allowing fixing a single parameter was originally that the fit depends on all four parameters at once. When iterating to find the best ellipse that minimizes residuals, the algorithm increments, at each iteration, one single parameter at a time. In this process, if one or more parameters aren't allowed to change, the iterations can either get stuck at a fixed ellipse, or diverge.

I have a recollection of running experiments on this a long ago, when initially developing the algorithm under the IRAF system (circa 1990). Can't recall details, but I am pretty sure that I adopted the all-or-nothing solution after verifying that behavior. This is also probably the reason the minimum number of iterations is > 1.

iskren-y-g commented 5 years ago

It will be great if this can be implemented. The IRAF's ellipse task (stsdas.analysis.isophote) can run ellipse fitting in which you can specify whether you would like to fix certain parameters. This is very useful where for one reason or the other, there might not be a very clear center or you just want to enforce a fixed PA.

ibusko commented 5 years ago

@iskren-y-g I will run some experiments to see how it performs. In case it works fine, we can put in the ability to fix parameters.

iskren-y-g commented 5 years ago

Great, that sounds excellent! And it is important in certain cases ... Thanks for looking into this!

larrybradley commented 5 years ago

Added in #922.