#! /bin/csh -f
#Example for HILO system -
#jhz 2018-2-26: intiate a script for developing/testing the prototype
#               program swarm2uvfits
#jhz 2018-4-23: updated for new disk names on RTDC/RG
#jhz 2018-4-26: update for testing swarmRead for the LSB data               
#jhz 2018-5-02: update for USB test               
#jhz 2018-5-09: develop swarm2ms.py to execute CASA tasks
#jhz 2018-5-10: export swarm2ms.py a bin area where swarmRead
#               is located.
#jhz 2018-5-11: add instruction lines
#jhz 2018-5-24: updated for test on RTDC/RG system
#jhz 2018-5-25: updated for test on Hilo system (hilodr2)
#jhz 2018-5-29: add optinx to input variables
#               add alias casa /usr/local/casa-release-4.7.0-1-el6/bin/casa (from Holly)
#               test CASA 4.7.0
date            
# --------------------------------------------------------------------
#
# requirement -
#
# RH 6.7 to 6.9; or CentOS 6.7 to 6.9
# CASA 5.1.1 and higher
# --------------------------------------------------------------------
#
# set up c-shell and environment variables -
#
# INPUT_FILE_DIR     - the path of the SMA archived data produced by online 
#                      system with the SWARM correlator
# INPUT_FILE_NAME    - the file name of the SMA archived data that users want
#                      to interpret to measurementSet of CASA
# OUTPUT_FILE_PREFIX - the prefix of output file name,  for example, SMA180506
#                      will result in SMA180506.ms for the data in measurementSet
#                      for CASA       
# PATH               - the location of the executable binary code and the Python 
#                      script                                               
set    INPUT_FILE_DIR = /sma/data/science/mir_data/
set    INPUT_FILE_NAME = 180506_03:52:53 
setenv OUTPUT_FILE_PREFIX SMA180506
set    PATH = /sma/reduction/jzhao/SMA2CASA_TESTING/swarm2measurementSet/bin/ 
#----------------------------------------------------------------------
echo 'Start swarm2uvfits.csh script -'
echo ''
#
# process start -
#
#for LSB -
$PATH/swarmRead $INPUT_FILE_DIR $INPUT_FILE_NAME $OUTPUT_FILE_PREFIX 0 0
#for USB -
$PATH/swarmRead $INPUT_FILE_DIR $INPUT_FILE_NAME $OUTPUT_FILE_PREFIX 1 0
#
alias casa "/usr/local/casa-release-4.7.0-1-el6/bin/casa"
#
# run CASA batch process -
#
#
casa -c $PATH/swarm2ms.py
echo ''
echo 'CASA measurementSet data file '$OUTPUT_FILE_PREFIX'.ms is produced.'
echo 'Done, congratulation! exit from the script!'
date
exit 
