#***********************************************************************************
#***********************************************************************************
#***********************************************************************************
# CCD/TAURUS sequencing files required by charge shuffling
#***********************************************************************************
#***********************************************************************************
#***********************************************************************************
#
# This program is available via WWW or FTP (aaoepp.aao.gov.au/pub/jbh/ttf),
# a simple operation running under unix. There is a fortran file there if
# needs to be compiled on a different machine. It is essential to generate
# the CSX file for a given exposure time and no. of shuffles.
#
# Run: csx < csx.inp > csx.out
#
# where csx.inp is exposure time (sec.) and steps on consec lines. The csx.out
# file should be ftp's to disk$user:[observer.cs_files]. Note that this is the
# exposure time PER SHUFFLE STEP and not total exposure time. The remaining
# shuffle info is inserted into
#
# run-
# run_ccd-
# shuf_multi-
#
# Assume Tek 1024x1024, and slit falling at 518 as I measured for the 4-pix
# 0.356mm slit. To understand the output CSX file, take the following 1 sec
# x 80 shuffle:-
#
# PI
# PR 0,65535,1000,2000,65535,474,6,0,0,1
# PR 0,65535,1000,2000,65535,474,6,0,0,2
# PR 0,65535,1000,2000,65535,474,6,0,0,3
# PR 0,65535,1000,2000,65535,474,6,0,0,4
# :
# PE
#
# 0,65535 - ignore
# 1000 - exp time in ms
# 2000 - end exp time with arbitrary offset
# 65535 or 1 - 65535 shift down away from read-out register
# 1 is shift up (so could reverse shift direction)
# 474 - shift charge down by 79*6 rows; then bring up slowly
# 6 - no. of rows in each shift
# 0,0 - ignore
# 1 - index needed by instr seq
#
# Therefore we have 80 x 6 rows = 480 rows.
#
# So a jump of -474 puts first frequency centred at 518-474 = 44
# centre of freq bands 44, 50......512, 518. But the first real row is 41.
#
# How do we convert from row number to gap number. If this unsettles you,
# simply scan through a 5x5 window sausage cube using Heath's special window.
# Let's say we stepped from 100 to 495 in steps of 5. In the example above,
# we can write (where frequency is just an index from 1->80)
#
# pixel = 6*(frequency-1) + 44
# gap = 5*(frequency-1) + 100
# Thus
# (gap-100)/5 = (pixel-44)/6
#
# So what is the best way to calibrate wavelength vs. gap from the long-slit
# mode? Take a column through your CuAr spectrum, say, and fit to the 3-4
# known lines against gap. The column is indexed in pixels, but you can
# easily convert to gap with the above, i.e.
#
# gap = (pixel-44)*5/6 + 100
#
# So then the approach in Zodiac would be
#
# spec=col(image,512)
# pixel=seq(1024)
# xfit,spec,gap
# linfit,spec,gap,grad_lam,off_lam
# wave = grad_lam*gap + off_lam
#
# Exact calibration of order/gap requires that you fit to a few emission lines
# to get all required constants:-
#
# m * lam_1 = 2 * z_1 + off
# m * lam_2 = 2 * z_2 + off
# m * lam_3 = 2 * z_3 + off
#
# and then you can solve for m, therefore true gap. More than 2 ensures single order.