#!/bin/bash -f
#------------------------------------------------------------------------------
# The following script finds an SDSS spectrum based upon RA,DEC position.
# It prints the plate, MJD and fiber of all matches, then plots the first
# match.
#
# This script is hard-wired to work at Princeton w/out adding anything
# to your path.
#
# Example: zplot 37.9069 -7.4818
#------------------------------------------------------------------------------
if [ $# = 0 ] ; then
  echo Must specify RA and DEC on command line, e.g. "zplot 37.9069 -7.4818"
  exit
fi
TMPFILE=zplot.idl
#------------------------------------------------------------------------------
PATH=/usr/bin:/bin:/usr/peyton/bin:/usr/X11R6/bin:.:/usr/openwin/bin:/usr/peyton/pgi/linux86/bin
export IDLSPEC2D_DIR=/u/schlegel/idlspec2d
export IDLUTILS_DIR=/u/schlegel/idlutils
export IDL_DIR=/usr/peyton/common/licensed/idl_5.4
export IDL_PATH=+/u/schlegel/idlspec2d/pro:+/u/schlegel/idlutils/pro:+/u/schlegel/idlutils/goddard/pro:.:+/usr/peyton/common/licensed/idl_5.4/lib
export BOSS_SPECTRO_REDUX=/u/dss/spectro
export RA=$1
export DEC=$2
echo Looking for $RA $DEC
echo !quiet=1 > $TMPFILE
echo "findspec,getenv('RA'),getenv('DEC'),slist=slist" >> $TMPFILE
echo "if (slist.plate EQ 0) then print,'No matches found. Exiting.'" >> $TMPFILE
echo "if (slist.plate EQ 0) then exit" >> $TMPFILE
echo "help,slist,/st" >> $TMPFILE
echo "plotspec,slist.plate,slist.fiberid,mjd=slist.mjd" >> $TMPFILE
echo "print,'Type exit to quit'" >> $TMPFILE
idl $TMPFILE
\rm -f $TMPFILE
#------------------------------------------------------------------------------
