#!/bin/csh -f
#
# mark
#
# saves the current telescope offsets (see also gomark).
#
#-

# Boiler plate for "-h" support for command autohelp.

if ("$1" == "-h") then
    help $0
    exit $status
endif

# Boilerplate for syncheck.
# Note that the boiler plate should be transparent for all usages,
# but to make correct use of syncheck you will need to specify the
# correct pattern.

 set noglob
 set CheckStatus = `syncheck -command $0 $* -pattern ` 
 unset noglob

if ("$CheckStatus" != "OK") then
    help $0
    exit 1
endif

# End of help/syncheck boiler plate.

# The only DCS keywords with enough precision are the raw (binary) versions.
# These are, alas, in radians.

set raoffset = `show -s dcs -terse -binary raoff`
set decoffset = `show -s dcs -terse -binary decoff`

set raoffset  = `math $raoffset x 180 x 3600 / 3.1415926536`
set decoffset = `math $decoffset x 180 x 3600 / 3.1415926536`

# There is a bug in DCS where the value of RAOFF read back has been
# divided by cos(Dec).  We correct for that error here.

set dec = `show -s dcs -terse -binary dec`
set raoffset = `math "$raoffset x c($dec)"`

modify -s osiris RAOFFSET  = $raoffset
modify -s osiris DECOFFSET = $decoffset