#!/bin/tcsh -ef

#
# ABOUT    : NOTCam script to take data for Detector Quality Control.
#            NB! Mirror covers must be opened. The lamp must be ON. The
#            intensity of the lamp must be such that it gives ~600 adu
#            in 0.5 sec exposure (WF-camera and J-band).
#            Both readout modes are run.
#
# USAGE     : notcam.lintest [-e]
#           -e      : Echo script on stdout, do not execute
#
# DEPENDS : notcam.autosave_on, notcam.autosave_off, notcam.object,
#           notcam.imtype, notcam.lens, notcam.clear, notcam.mdark,
#           notcam.mexpose, notcam.dframes, notcam.frames, notcam.dark,
#           notcam.expose, notcam.notcamfocus, 
#           notcam.filter1, notcam.filter2, notcam.stop, 
#           notcam.grism, notcam.wait_notcam_ready
#
# PROVIDES: notcam.lintest
#
# TFUNCT  : about 1.5 hour
#
# AUTHOR  : Anlaug Amanda Djupvik
#
# HISTORY : 2008/05/21 (Initial release sequencer version, AAD)
#           2009/04/23 Changed notcaminst. -> notcam.
#                      Changed notcam.focus -> notcam.notcamfocus (AAD)

# If -e option is given
if ("$1" == "-e") then
  set e = "echo"
  shift
else
  set e = ""
endif

# Write to Talker
logger -p local0.debug -t "notcam.lintest" "[NOTE]: notcam.lintest started"


# Execute or Echo script

# NOTCam setup should be the following
# Lens = WF camera
# Aperture = open large 
# Filter wheel 1 = open
# Filter wheel 2 = J
# Stop = 15 mm ring
# Grism = open
# Camera focus = 5650

$e date

$e notcam.lens 1 &
$e notcam.notcamfocus 5650 &
$e notcam.aperture 4 &
$e notcam.filter1 15 &
$e notcam.filter2 13 &
$e notcam.stop 12 &
$e notcam.grism 2 &
$e notcam.wait_notcam_ready

$e notcam.autosave_on

$e notcam.clear
$e notcam.clear
$e notcam.object "Lintest drk 0s"
$e notcam.mdark 0 5
$e notcam.object "lin 0.5s"
$e notcam.mexpose 0.5 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 0.5s"
$e notcam.mdark 0.5 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 42s"
$e notcam.mexpose 42 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 42s"
$e notcam.mdark 42 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 2s"
$e notcam.mexpose 2 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 2s"
$e notcam.mdark 2 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 30s"
$e notcam.mexpose 30 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 30s"
$e notcam.mdark 30 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 12s"
$e notcam.mexpose 12 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 12s"
$e notcam.mdark 12 5
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 0s"
$e notcam.mdark 0 5
$e notcam.object "lin 18s"
$e notcam.mexpose 18 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 18s"
$e notcam.mdark 18 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 24s"
$e notcam.mexpose 24 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 24s"
$e notcam.mdark 24 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 6s"
$e notcam.mexpose 6 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 6s"
$e notcam.mdark 6 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 36s"
$e notcam.mexpose 36 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 36s"
$e notcam.mdark 36 5
$e notcam.clear
$e notcam.clear
$e notcam.object "lin 1s"
$e notcam.mexpose 1 5 FLAT
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 1s"
$e notcam.mdark 1 5
$e notcam.clear
$e notcam.clear
$e notcam.object "drk 0s"
$e notcam.mdark 0 5

$e notcam.clear
$e notcam.clear
$e notcam.object "mdark 0 5"
$e notcam.mdark 0 5
$e notcam.object "lin-rs 42s 1"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 1"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 2"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 2"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 3"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 3"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 4"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 4"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 5"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 5"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 6"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 6"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 7"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 7"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 8"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 8"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "lin-rs 42s 9"
$e notcam.imtype FLAT
$e notcam.frames 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.clear
$e notcam.object "drk-rs 42s 9"
$e notcam.imtype DARK
$e notcam.dframes 4.2 10
$e notcam.clear
$e notcam.clear
$e notcam.object "mdark 0 5"
$e notcam.mdark 0 5
$e notcam.imtype OBJECT

$e astrowakeup

$e date

# All done. Exit with error status 0 and write to Talker
logger -p local0.debug -t "notcam.lintest" "[NOTE]: notcam.lintest ended successfully"
exit 0
