Description
Shifts an image by both integer and floating-point pixel amounts. During integer shifts, the edges are set to zero (non-cyclic shift). During floating-point shifts, the image is shifted to the nearest integer and then convolved with a 21 x 21 filter consisting of exponentially damped sinc() functions of the form exp(-(s / 3.25)**2) * sinc(s) in both x and y directions, resulting in a cyclical shift of at most 0.5 pixel. The result is clipped to zero. Can be used on a single file or a set of files.
Usage
shift.py -c 'cx cy rad' fits-file dx dy [min] [max], or
shift.py coords-file
'cx, cy, rad' = circle to overlay (3 values in quotes)
dx, dy = shift amounts (integer or floating-point)
coords-file = text file with lines containing {fname, dx, dy} fields (as output by brightalign.py)
When run on a single file, the image is shifted by the specified amount and plotted wrt a fixed circle (if any). In addition, the image can be further shifted by using the keyboard:
right-arrow = shift right by current increment (default = 1.0) left-arrow = shift left by current increment up-arrow = shift up by current increment down-arrow = shift down by current increment plus = multiply increment by 2 minus = divide increment by 2
When run on a set of files (using a coordinate file), each image is shifted to the center of the circle (or (255, 255) if none entered) and the resulting file is written to a 'shifted' directory (parallel to the input directory) which must already exist.
Examples
Single-file mode:
> shift.py -c '305.371417 252.452716 203.417370' 072407/filled/im0215.a.fits 8 -1 0 2000

Draws a circle at (305.371417, 252.452716, 203.417370) and then shifts the image (8 , -1) relative to that.
> shift.py -c '255 255 200' 072407/filled/im0215.a.fits 0 0 0 1250

Draws a circle at (255, 255, 200). To align the image to the circle, first increase the shift increment by pressing the plus key twice until the text 'by 4.000' appears in the window title. Then, use the arrow keys to move the image:

Press the minus key to decrease the shift increment, and realign the image using the arrow keys. Continue decreasing the shift increment and using the arrow keys until you are happy with the resulting alignment:

Multi-file mode:
> shift.py -c '255 255' 072407/intermediates/coords.171-276.filled.txt 072407/shifted/im0188.a.fits -130.039149 7.165139 072407/shifted/im0189.a.fits -123.210851 5.716901 072407/shifted/im0190.a.fits -123.029519 5.664600 072407/shifted/im0191.a.fits -118.023227 19.616139 072407/shifted/im0192.a.fits -116.657348 18.306512 072407/shifted/im0193.a.fits -116.649459 6.025653 072407/shifted/im0194.a.fits -109.172674 3.184187 072407/shifted/im0195.a.fits -108.161024 3.053222 072407/shifted/im0196.a.fits -106.195379 3.740616 072407/shifted/im0197.a.fits -106.204537 3.211076 ... 072407/shifted/im0267.a.fits 110.124676 -12.452096 072407/shifted/im0268.a.fits 110.949730 -10.786457 072407/shifted/im0269.a.fits 113.980138 -12.564000 072407/shifted/im0270.a.fits 117.739223 -12.639439 072407/shifted/im0271.a.fits 122.264887 -12.582711 072407/shifted/im0272.a.fits 121.847436 -13.958160 072407/shifted/im0273.a.fits 127.221384 -14.866703 072407/shifted/im0274.a.fits 128.642910 -14.768413 072407/shifted/im0275.a.fits 132.080803 -14.997316 072407/shifted/im0276.a.fits 133.383078 -14.746712
The output shows the (dx, dy) shift applied to each image.
©Sky Coyote 2007