#!/bin/csh -f
#+
# ref2slit -- offset star at REF onto slit at (x,y)
#
# Purpose:
#	Put the star at the REF pointing origin onto the slit at
#	the specified pixel location on the DEIMOS CCD mosaic.
#
# Usage:
#	ref2slit x y
# 
# Arguments:
#	x = column number of slit center [px, DEIMOS pane coordinate system]
#	y = row number of slit center [px, DEIMOS pane coordinate system]
# 
# Output:
#	To stdout
# 
# Restrictions:
#	- Should only be used for slits visible on the guider, 
#	since it will not place targets precisely and does not 
#	account for the gaps in the DEIMOS mosaic.
# 
# Exit values:
#	 0 = normal completion
#	 1 = wrong number of arguments
#
# Example:
#	1) To move a star onto a slit at DEIMOS mosaic pane coordinates
#	x=4975, y=2117, first put the star at REF and then type
#		ref2slit 4975 2117
#-
# Calibration:
#	- Configure DEIMOS for direct imaging.
#	- Place a MIRA star at REF
#	- Execute command "mov 0 0 0 -1000"
#	- Measure (x,y) position of star on image using ds9
#	- Set x0=x and y0=y+1000
#
# Modification history:
#	2004-Sep-14	GDW	Original version
#-----------------------------------------------------------------------

set x0 = 4903
set y0 = 3523
set buf = $0
set cmd = $buf:t
set usage = "Usage: $cmd x y"

# verify args...
if ( $#argv < 1 || $argv > 2 ) then
  printf "$usage\n"
  exit 1
endif

# parse args...
if ( $#argv >= 1 ) then
    set x = $1
    shift
endif
if ( $#argv >= 1 ) then
    set y = $1
    shift
endif

# verify that we are at REF...
set poname = `poname`
if ( "$poname" != "REF" ) then
    printf "ERROR: current pointing origin is $poname not REF -- aborting! \n"
    exit 2
endif

# offset to slit...
mov $x0 $y0 $x $y
exit
