Subject: Source code for "dsrand.tcl"
From: James Rhoads
Submitted: Thu, 4 Apr 1996 17:03:52 -0500
Message number: 12
(previous: 11,
next: 13
up: Index)
Here is the Tcl source code for the macro described in the preceding message.
Enjoy! -James.
# Tcl script. Etymology: dosource_random -> dsrand
# dsrand assumes we're already slewed to the source.
# Basic idea: do 'on-off' pairs of exposures, choosing offsets randomly
# within a centerd square box (on) or offset sqare boxes (off);
# finish with an extra off frame.
# By allowing arbitrarily many pairs to be requested, one can start a
# virtual 'long integration', which should reduce the babysitting needed.
#
# There are 7 arguments:
# $1, x offset (arcsec) of "field center"
# $2, y offset
# $3 maximum x and y offsets for on-source (differential, rel to $1,$2)
# Note, we will now use a random number generator to get rand.
# integers up to this limit for offsets.
# $4 minimum x and y offsets for off-source frames.
# $5 maximum x and y offsets for off-source (differential)
# $6 number of off-on pairs to do
# $7 exposure time.
# For point sources, setting arguments 3 & 5 equal and $4 to 0 will make 'on'
# and 'off' frames indistinguishable.
proc dsrand { off0x off0y off1max off2min off2max nexp tim } {
# initialize global variables: message id, offsets, exposure time array
global MID RID REPLY goff0x goff0y goff1x goff2n goff2x gnexp gtt iii
set goff0x $off0x
set goff0y $off0y
set goff1x $off1max
set goff2n $off2min
set goff2x $off2max
set gnexp $nexp
set gtt $tim
# start the expose-offset
# daisy chain of subroutines.
set iii 0
sendhub $MID 0 do_oo "time"
}
proc do_oo {args} {
global MID RID REPLY goff0x goff0y goff1x goff2n goff2x gnexp gtt iii
if { [cindex $args 1] == ":" } {
echo $args
incr MID
if {$gnexp > 0} {
incr iii
if { $iii == 1 } {
sendhub $MID 0 do_off "time"
} elseif {$iii == 2} {
sendhub $MID 0 do_on "time"
} else {
set iii 0
incr gnexp -1
sendhub $MID 0 do_oo "time"
}
} else {
sendhub $MID 0 do_off "time"
# echo Done with random position dosource macro...
# set MID 10
}
} else {
echo $args
}
}
proc do_off {args} {
global MID RID REPLY goff0x goff0y goff1x goff2n goff2x gnexp gtt iii
if { [cindex $args 1] == ":" } {
echo $args
incr MID
set offsignx [expr 2 * [random 2] - 1]
set offsigny [expr 2 * [random 2] - 1]
set xoff [ expr $goff0x + $offsignx * ( [ random [expr $goff2x - $goff2n ] ] + $goff2n ) ]
set yoff [ expr $goff0y + $offsigny * ( [ random [expr $goff2x - $goff2n ] ] + $goff2n ) ]
sendhub $MID 0 snap_one "offset $xoff $yoff abs inst nocompute"
} else {
echo $args
}
}
proc do_on {args} {
global MID RID REPLY goff0x goff0y goff1x goff2n goff2x gnexp gtt iii
if { [cindex $args 1] == ":" } {
echo $args
incr MID
set xoff [ expr $goff0x + [ random [expr 2 * $goff1x ] ] - $goff1x ]
set yoff [ expr $goff0y + [ random [expr 2 * $goff1x ] ] - $goff1x ]
sendhub $MID 0 snap_one "offset $xoff $yoff abs inst nocompute"
} else {
echo $args
}
}
proc snap_one {args} {
global MID RID REPLY goff0x goff0y goff1x goff2x gnexp gtt iii
if { [cindex $args 1] == ":" } {
echo $args
incr MID
if {$gnexp > 0} {
sendhub $MID 0 do_oo "nexpose it=$gtt inst=grim n=1"
} else {
sendhub $MID 0 dsrand_end "nexpose it=$gtt inst=grim n=1"
}
} else {
echo $args
}
}
proc dsrand_end {args} {
global MID RID REPLY goff0x goff0y goff1x goff2x gnexp gtt iii
if { [cindex $args 1] == ":" } {
echo $args
echo Done with random position dosource macro...
} else {
echo $args
}
}
echo Loaded dsrand script.
APO APO APO APO APO Apache Point Observatory 3.5m APO APO APO
APO
APO This is message 12 in the apo35-grim archive. You can find
APO the archive on http://astro.princeton.edu:82/apo35-grim/INDEX.html
APO To join/leave the list, send mail to apo35-request@astro.princeton.edu
APO To post a message, mail it to apo35-grim@astro.princeton.edu
APO
APO APO APO APO APO APO APO APO APO APO APO APO APO APO APO APO