I'm often doing centroiding/fitting & calibration of distortion models. This page shows what I did when asked to analyse a bunch of images of a 2dF back-illuminated field plate acquired by a Pulnix CCD camera mounted on the AAT spider. (Imaging the prime focus via the primary mirror.)
It's mostly intended as a reference for myself, hence the lack of elaboration in many places.
Red dots denote fibre buttons on 2dF field plate. Rectangles denote approximate FOV of the 3 fields: a (green), b (yellow) & c (blue).
centroid -a -f p1_a1.pgm -b50 -r3 -s6 | grep ^Bary | perl -ne '/(\d+\.\d+),(\d+\.\d+)/ && print "$1\t$2\n"' > ~/tmp/ajm/a.bary $e/echScripts/perl/plate.pl -m ~/tmp/ajm/a.bary -a ~/m.fp -r 92 -o ~/coords.txt -x -8200 -y 22300 -xscale 215 -yscale 269 && \ echo "set key outside\nset size square\nset xrange [-100000:100000]\nset yrange [-100000:100000]\nplot './m.fp' t 'fibres', './coords.txt' t 'centroids'" | gnuplot -geometry +0+0 -persist && \ $e/echScripts/perl/plotResiduals.pl --geometry +0+469 -mag 50 -scale 500 ~/coords.txt &
Tried to fit measured centroids to actual fibre positions (as measured by 2dF robot) but distortion of lens (actually a small off-the-shelf telescope) on Pulnix CCD camera proved excessive!
Fitting incorporated variables for:
The images below show how the (measured) centroids align with the (actual) fibre button positions. This if for field A.
A plot of the residuals shows much greater sensitivity. Here it is obvious that distortion in the lens swamps any minor innacuracies I may have in translation, rotation & image scale. The first residual plot is for field A, the second for field B.
Aborted the above method & decided to look at centroiding stability instead. 9 images were acquired for each of the 3 fields. According to AJM, if the computed centroids don't vary by more than 1/20th pixel for all 9 images, this would prove that the STRIP concept could work. (Lens distortion can be calibrated out.)
# Rename some files to obtain consistent filenames. foreach f (p1_?a.*) n=$(echo $f | perl -ne '/_(\d+)/ && print "$1"') echo mv $f p1_a$n.$f:e end # Convert FITS images to PGM format for centroiding. foreach f (*.fits) echo convert $f $f:r.pgm end # Centroid all images. foreach f (*.pgm) echo "Centroiding $f ..." centroid -a -f $f -b50 -r3 -s6 > $f:r.data || echo FAILED end
To get this:
# Extract raw x/y centroid values & sort.
foreach f (*.data)
grep ^Bary $f | perl -ne '/(\d+\.\d+),(\d+\.\d+)/ && print "$1\t$2\n"' | sort -n > $f:r.bary
end
foreach c (a b c)
echo "Analysing data for field $c ..."
# Combine all centroids for each fibre into columns.
paste -s p1_$c?.bary >! /tmp/tmp0
# How many fibres are there?
wc -l p1_${c}1.bary | read n rest
# Calculate the standard deviation of the centroids for each fibre.
rm -f /tmp/tmp{1,2,3}
echo "calculating stddev for column:"
foreach i ($(seq $(($n*2))))
echo -n " $i"
< /tmp/tmp0 | cut -f$i | $e/echScripts/zsh/stdDev.zsh | egrep '^(mean|stdDev)' | perl -ne '/(\d+\.\d+)/ && print "$1\n"' >! /tmp/tmp1
if [ -e /tmp/tmp2 ] ; then
paste /tmp/tmp2 /tmp/tmp1 > /tmp/tmp3
mv -f /tmp/tmp3 /tmp/tmp2
else
mv /tmp/tmp1 /tmp/tmp2
fi
end
echo
echo >> /tmp/tmp0
cat /tmp/tmp0 /tmp/tmp2 >! /tmp/results.$c.data
echo "Results in: /tmp/results.$c.data"
end
Results for: field A, field B, field C.
The results show that centroiding stability is on the order of ~1/5th pixel.