#!/bin/csh -f
#+
# OSIRIS library of scripts
#
# NAME
#      osirisCoadds - set the number of coadds
#
# SYNOPSIS
#     osirisCoadds spec|imag [x] 
#
# DESCRIPTION
#      sets or returns the number of coadds
#
# ARGUMENTS
#     x - number of coadds
#
# OPTIONS
#
# EXAMPLES
#
# ENVIRONMENT VARIABLES
#
# FILES
#
# SERVERS & KEYWORDS
#    
#
#
# SCRIPTS CALLED
#
# EXIT STATUS
#     0 - normal exit, no error
#     1 - script aborted by an interrupt
#     2 - syncheck error
#     3 - error parsing command line input
#     other errors...
#
#
#
# Modification History:
# 20180703 - jlyke: Original
#------------------------------------------------------


# 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 {text int:1,2000}` 
unset noglob

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

# End of help/syncheck boiler plate.

set mode = $1
switch ($mode)
    case S*:
    case s*:
        set M = "s"
        set det = "spec"
        breaksw
    case I*:
    case i*:
        set M = "i"
        set det = "imag"
        breaksw
    default:
        osirisScriptMsg -T "${cmd} ${det}: Specified detector must be SPEC or IMAG 
- aborting."
        exit 1
        breaksw
endsw
shift

# Check integration time requested versus minimum calculated.
set coadds = $1

if ($coadds == "") then
    show -s o${M}ds -terse coadds
else
    modify -s o${M}ds coadds=$coadds
endif
