PetroFit / petrofit

Python package for calculating Petrosian properties and fitting galaxy light profiles
https://petrofit.readthedocs.io
26 stars 6 forks source link

Why Does the COG Drop When Apertures are Larger than Cutout #171

Open robelgeda opened 1 year ago

robelgeda commented 1 year ago

When apertures are larger than the cutout image, there seems to be a drop in the COG. This could be because of how area is calculated in Photutils. Its currently not clear if this is a bug or a real feature but should be looked at.

lucatelli commented 1 year ago

Hi there, what is the state of this issue?

I am using petrofit to analyse Radio Interferometric images, and I found two occasions where this happens: 1. the same as you described; and 2. in the case where the slice (or averaged brightness profile) oscillates between + and - values.

The second case, seems to be natural, but the first case I managed to do a 'workaround' just by inspecting if the values of R_last are np.nans, which means that there is no enough radial points to fill the 2xRp region. So at the end, I just have to run the photometry again with a larger area (i.e. min of 2xRp) and therefore the COG should be fine. However, more experiments are yet to be made.

robelgeda commented 1 year ago

Thank you so much! This is very helpful to know.

I just want to confirm and document that case two is natural. Here is an example profile (without any background subtraction):

image

Note that the issue with the corners does not occur here because the apertures are spaced out by a few pixels. When you look at the sum of negative pixel values to positive pixel values within an aperture, you see the negative values start to dominate. i.e This kind of dip can be attributed to less than ideal background subtraction:

image In this plot the x-axis is aperture index instead of pixel radii but it maps the same since the radii are evenly spaced.

This applies to case two even if the masked sources were set to 0 instead of np.nan.

I am working on case one now.

lucatelli commented 1 year ago

Hi there. I have missed this. Thank you so much for your reply.

OKay, I will keep an eye on this to see what I can do.