#!/bin/sh #+ # barcode2radec -- given slitmask barcode, return RA/Dec # # Purpose: # Given the barcode number of a slitmask, query the database to # retrieve the mask center coordinates, equinox, and PA # # Usage: # barcode2radec # # Arguments: # barcode = integer barcode number # # Output: # If a match is found, returns the following values on STDOUT: # - guiname # - ra [deg] # - dec [deg] # - equinox # - pa [deg] # # Restrictions: # - Must execute on polo as a deimos account # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Example: # > barcode2radec 7148 # bck11x 189.303280 62.218216 2000.000000 52.700000 #- # Modification history: # 2011-Feb-05 GDW Original version # 2013-Mar-29 GDW Add check for barcode # 2013-Apr-11 GDW Ensure that all invocations of # "inventory" use full path, so that it # will work for LRIS. #----------------------------------------------------------------------- cmd=`basename $0` # verify number of args... if [ $# = 1 ]; then barcode=$1 else printf "Usage: $cmd \n\a" exit 1 fi # verify that we are on the correct host machine... myhost=`/bin/hostname` goodhost=`/bin/rsh deimosserver hostname` if [ "$myhost" != "$goodhost" ]; then printf "[$cmd] ERROR: current host is $myhost, but this script must run on $goodhost -- abort!\n\a" exit 1 fi # confirm that barcode is legal... /home/deimos/bin/inventory s | awk "/barcode=$barcode/{exit 1}" if [ $? != 1 ]; then printf "[$cmd] ERROR: no mask with barcode=$barcode found in database -- abort!\n\a" exit 1 fi # define where Sybase is installed... SYBASE=/local/sybase export SYBASE # this chokes many Sybase utilities if not blank... LANG= export LANG # at Lick the server is YAKUZA (well sort of) # at Keck the server is KSUMMIT # this is translated by $SYBASE/interfaces file sybserv=KSUMMIT # who do we want to be on the Sybase server? sybuser=ktlw # shhh! (this is supposed to be secret) sybpass=ofFish # define names of output files... outfile=/tmp/$cmd.outfile.$$ errfile=/tmp/$cmd.errfile.$$ # convert barcode to desid... bluid=`/home/deimos/bin/inventory s b $barcode i` guiname=`/home/deimos/bin/inventory s b $barcode g` # translate desid to bluid... sqlquery="select BluId,DesId from metabase.dbo.MaskBlu where BluId=$bluid" $SYBASE/bin/isql -S$sybserv -U$sybuser > $outfile 2> $errfile < $outfile 2> $errfile <