### Post by Sarah on Aug 9, 2017 16:37:12 GMT 8

I've been looking at different sky subtraction options etc. and here's a couple of things that give me a headache.

A bit of background info: I use KiDS r-band tiles, which are stacked images that have been regridded onto a common scale of 0.2 arcsec/pix. They have associated weight (inverse variance) maps taking account of the rather non-uniform depth.

I run ProFound on 2000x2000 pixel (400x400 arcsec) cutouts around my galaxies of interest, then select stars from the objects it returns and fit those with a Moffat function (each one on its own within a smaller cutout around the star) to determine the PSF. For test purposes, I fitted a (constant) background along with the Moffat function as well. The cutout size within which this is fitted is 30 FWHM of the star, which is typically of the order of 100 pixels (20 arcsec) or a little less; we have previously found that to be a reasonable size to include enough background beyond the wings of the star.

The plot below shows the distribution of all background values fitted by ProFit for stars around some 200 test galaxies. Blue is what I get using mostly defaults in ProFound (skycut=2, doclip=TRUE, skytype=median) and the "normal" objects mask ($objects). As you can see, the distribution is skewed towards positive values (mean is 0.62, median 0.46, std 1.47; total of 2264 values). This makes sense: ProFound does its best to estimate the "true" sky, i.e. exclude non-detected objects and faint wings of objects not included in the objects mask before estimating the sky. The background fit in ProFit on the other hand just uses ALL the unmasked non-object pixels, hence it should be systematically higher than the ProFound sky estimate (because there will always be such undetected objects).

In order to get rid of this, I went much harsher on everything: Red shows the same distribution but for skycut=1, doclip=FALSE, skytype=mean and more aggressive objects masking ($objects_redo); i.e. going deeper into the noise in the first place, masking out a larger area around each object AND including the remaining non-detected objects in the sky estimate. This, as expected, gets the distribution closer to zero and narrower, but still significantly positive (mean 0.25, median 0.20, std 0.73, total length 2858 - note there's more stars here because of the lower skycut). By far the largest change in this comes from the more aggressive masking, skycut has near to no effect (apart from finding a few more stars), doclip and skytype both have small effects.

For comparison, here's the corresponding correlation plot with a zoom (averaged over all cutouts around the test galaxies) and FFT (stacked), for both of the above versions ('number27' refers to the blue histogram, 'number23' to the red one). Clearly, the correlation decreases for the harsher masking etc. but is still non-zero up to scales of ~ 200 pixels. Note the funky bit in the central ~ 4 pixels is expected due to the stacking/regridding; as is the dark outer part in the FFT. There's also some interesting dots along the vertical in the FFT in regular intervals, not sure what those are... but in any case, I'm more worried about the part between 5 and 200 pixels.

So the main question is: Can I do any better than this?

I can't decrease skycut further, otherwise the correlation plots go negative (plus it didn't have much of an effect on the histogram anyway); I can get the histogram a little closer to zero by ignoring the weight map given by KiDS and using the skyRMS of ProFound instead but again the correlation plot and FFT go crazy... any other ideas? Comments?

A bit of background info: I use KiDS r-band tiles, which are stacked images that have been regridded onto a common scale of 0.2 arcsec/pix. They have associated weight (inverse variance) maps taking account of the rather non-uniform depth.

I run ProFound on 2000x2000 pixel (400x400 arcsec) cutouts around my galaxies of interest, then select stars from the objects it returns and fit those with a Moffat function (each one on its own within a smaller cutout around the star) to determine the PSF. For test purposes, I fitted a (constant) background along with the Moffat function as well. The cutout size within which this is fitted is 30 FWHM of the star, which is typically of the order of 100 pixels (20 arcsec) or a little less; we have previously found that to be a reasonable size to include enough background beyond the wings of the star.

The plot below shows the distribution of all background values fitted by ProFit for stars around some 200 test galaxies. Blue is what I get using mostly defaults in ProFound (skycut=2, doclip=TRUE, skytype=median) and the "normal" objects mask ($objects). As you can see, the distribution is skewed towards positive values (mean is 0.62, median 0.46, std 1.47; total of 2264 values). This makes sense: ProFound does its best to estimate the "true" sky, i.e. exclude non-detected objects and faint wings of objects not included in the objects mask before estimating the sky. The background fit in ProFit on the other hand just uses ALL the unmasked non-object pixels, hence it should be systematically higher than the ProFound sky estimate (because there will always be such undetected objects).

In order to get rid of this, I went much harsher on everything: Red shows the same distribution but for skycut=1, doclip=FALSE, skytype=mean and more aggressive objects masking ($objects_redo); i.e. going deeper into the noise in the first place, masking out a larger area around each object AND including the remaining non-detected objects in the sky estimate. This, as expected, gets the distribution closer to zero and narrower, but still significantly positive (mean 0.25, median 0.20, std 0.73, total length 2858 - note there's more stars here because of the lower skycut). By far the largest change in this comes from the more aggressive masking, skycut has near to no effect (apart from finding a few more stars), doclip and skytype both have small effects.

For comparison, here's the corresponding correlation plot with a zoom (averaged over all cutouts around the test galaxies) and FFT (stacked), for both of the above versions ('number27' refers to the blue histogram, 'number23' to the red one). Clearly, the correlation decreases for the harsher masking etc. but is still non-zero up to scales of ~ 200 pixels. Note the funky bit in the central ~ 4 pixels is expected due to the stacking/regridding; as is the dark outer part in the FFT. There's also some interesting dots along the vertical in the FFT in regular intervals, not sure what those are... but in any case, I'm more worried about the part between 5 and 200 pixels.

So the main question is: Can I do any better than this?

I can't decrease skycut further, otherwise the correlation plots go negative (plus it didn't have much of an effect on the histogram anyway); I can get the histogram a little closer to zero by ignoring the weight map given by KiDS and using the skyRMS of ProFound instead but again the correlation plot and FFT go crazy... any other ideas? Comments?