program csx
#***********************************************************************************
#***********************************************************************************
#***********************************************************************************
# 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.
#
#***********************************************************************************
#***********************************************************************************
# Instructions on how to start up shuffling at site
#***********************************************************************************
#***********************************************************************************
# Now, how does this all link up with the operation of charge shuffling under RVTAURUS?
#
# Start up with
#
# observer
# observer
# version cs (optional)
# rvtaurus ccd1
#
# startup- (? on any line gives help)
# ccd_shuffle (looks up instrument sequencer)
#
# run-
# run_ccd-
# shuf_multi-
# csr_default disk$user:[observer.cs_files]*.csx
# filename eighty
# preexpose_info 3_1000_100 (2 = 0.1ms; 3 = 1ms clock rate)
# (1000 = min phase time for bias frames clock cycles)
# (100 = delay time for external device. Leave these!)
# cycle_count <<5>> (no. of cycles where exposure time in .csx file)
# bias <>
# setup_array <> (option 1: read in indexed gap numbers; see below)
# <> (option 2: generate gap numbers; see below)
# etalon_start <<0300>> (start gap in option 2)
# etalon_incremt <<0010>> (increment in gap in option 2; no. of steps in .csx file)
#
# **note: option 1 says, how many entries in the .csx files. Let's use these as index points
# into the array filled by sel_fil_z_array. Type in each entry alone. This is the only
# way to deal with irregularly sampled frequencies.
#
# You can always return to normal mode to do a glance, say, with "method default". Probably
# best to do this after every shuffle since bombing in shuffle mode is not good. "Method
# shuffle" gets you back after "method default". The long-slit shuffle mode is excellent for
# calibrating where lines occur in a filter, as is the FORS cube mode.
#
# So there are in fact five different ways to drive/step the etalon.
#
# (i) change_cs100 gap and "run"
# (ii) run_step
# (iii) run_file
# (iv) shuf_multi option 1
# (iv) shuf_multi option 2
#
# Finally, to generate
#
# Issues remaining. Simply run the csx.f file below and trap the output.
#
# JBH (AAT 15/3/96)
#--------------------------------------------------------------
character numch*30, nrowch*30, jumpch*30, iexpch*30, iexpch1*30
#write(*,'(x,a,$)') 'Exposure time? '
read *,iexp
iexp = iexp*1000
#write(*,'(x,a,$)') 'Steps? '
read *,istp
nrow = 1024/(2*istp-1)
jump = nrow*(istp-1)
write(jumpch,'(i5)') jump
k = 1
while ( jumpch(k:k) == ' ' ) k=k+1 # lnblnk(string) does not count leading blanks
write(iexpch,'(i5)') iexp
l = 1
while ( iexpch(l:l) == ' ' ) l=l+1
write(iexpch1,'(i5)') iexp+1000
m = 1
while ( iexpch1(m:m) == ' ' ) m=m+1
#
# ** first lines
#
print *,'PI'
write(*,'(7a)')'PR 0,65535,',iexpch(l:5),',',iexpch1(m:5),',65535,',jumpch(k:5),',0,0,1'
#
# ** main phase table
#
do j = 2, istp {
write(numch,'(i5)') j
i = 1
while ( numch(i:i) == ' ' ) i=i+1
write(nrowch,'(i5)') nrow
k = 1
while ( nrowch(k:k) == ' ' ) k=k+1
write(iexpch,'(i5)') iexp
l = 1
while ( iexpch(l:l) == ' ' ) l=l+1
write(iexpch1,'(i5)') iexp+1000
m = m
while ( iexpch1(m:m) == ' ' ) m=m+1
write(*,'(8a)') 'PR 0,65535,',iexpch(l:5),',',iexpch1(m:5),',1,',nrowch(k:5),',0,0,',numch(i:5)
}
#
# ** last lines
#
print *,'PE 0,65535,1,100,0,65535,0,0,0'
print *,'PT'
end