When source of the outlier covers more than one element, and its flux is close to the noise level, not all of its elements will be clipped: because of noise, some of its elements will remain un-clipped; and thus affecting the output.
Examples of this were created and thoroughly discussed in previous sections with \(\sigma\)-clipping and MAD-clipping (see Sigma clipping and MAD clipping). \(\sigma\)-clipping had good purity (very few non-outliers were clipped) but at the cost of bad completeness (many outliers remained). MAD-clipping was the opposite: it masked many outliers (good completeness), but at the cost of clipping many pixels that shouldn’t have been clipped (bad purity).
Fortunately there is a good way to benefit from the best of both worlds.
Recall that in the numbers image of the MAD-clipping output, the wrongly clipped pixels were randomly distributed are barely connected.
On the other hand, those that covered the circle were nicely connected, with unclipped pixels scattered within it.
Therefore, using their spatial distribution, we can improve the completeness (not have any “holes” within the masked circle) and purity (remove the false clips).
This is done through the madclip-maskfilled
operator:
Let’s have a look at the output of this process with the first command below.
Note that because madclip-maskfilled
returns its main input operands back to the stack, we need to call Arithmetic with --writeall (which will produce a multi-HDU output file).
With the second, open the output in DS9:
$ astarithmetic build/in-*.fits 9 4.5 0.01 madclip-maskfilled \ -g1 --writeall --output=inputs-masked.fits $ astscript-fits-view inputs-masked.fits
In the small “Cube” window, you will see that 9 HDUs are present in inputs-masked.fits. Click on the “Next” button to see each input. When you get to the last (9th) HDU, you will notice that the circle has been masked there (it is filled with NaN values). Now that all the contiguous outlier(s) of the inputs are masked, we can use more pure stacking operators (like \(\sigma\)-clipping) to remove any strong, single-pixel outlier:
$ astarithmetic build/in-*.fits 9 4.5 0.01 madclip-maskfilled \ 9 5 0.1 sigclip-mean \ -g1 --writeall --output=stack-good.fits $ astscript-fits-view stack-good.fits --ds9scale=minmax
You see a clean noisy stack in the first HDU (note that we used the \(\sigma\)-clipped mean here; which was strongly affected by outliers as we saw before in Sigma clipping).
When you go to the next HDU, you see that over the circle only 8 images were used and that there are no “holes” there.
But the operator that was most affected by outliers was the standard deviation.
To test it, repeat the first command above and use sigclip-std
instead of sigclip-mean
and have a look at the output: again, you don’t see any footprint of the circle.
Of course, if the potential outlier signal can become weaker, there are some solutions: use more inputs if you can (to decrease the noise), or decrease the multiple MAD in the madclip-maskfilled
call above: it will decrease your purity, but to some level, this may be fine (depends on your usage of the stack).
JavaScript license information
GNU Astronomy Utilities 0.23 manual, July 2024.