#!/bin/csh 
#-------------------------------------------------------------
# ingest_regr_datasets.csh
#
# Purpose: send collections of REGR dataset to regression Ingest pipeline
#
# Environment: 
#      The default directory be the regr directory of the regression datasets
#
# Usage: ingest_regr_datasets.csh <regr_path>
#
#       where <regr_path> is the path name of the regression Ingest pipeline
#       which is different from the standard Ingest pipeline. There is no
#       extension to this path name.
#
#     Ex: ingest_regr_datasets.csh regr
#
# Modification history:
#
#   date    opr     who     reason
# -------- -----  --------  --------------------------------------
# 09/02/04 51879  J.Baum    first version
# 07/08/05 53016  J.Baum    Insert missing "touch" commands for MTL class
# 08/30/10 59963  Sherbert  rm fuse in cases these ever used
#--------------------------------------------------------------------------
if ($#argv < 1) then
  echo "Must supply one argument: path name of the regression Ingest pipeline"
  exit 1
endif
set pathname = $argv[1]
if ( ! $?OPUS_DEFINITIONS_DIR ) then
   echo "OPUS_DEFINITIONS_DIR is not defined in the environment."
   exit 1
endif
set pathfile = `osfile_stretch_file OPUS_DEFINITIONS_DIR:$pathname.path`
if ( $status ) then
   echo "Unable to locate OPUS_DEFINITIONS_DIR:$pathname.path."
   exit 1
endif
echo "Ingest pathfile is: $pathfile" 
#
# extract path file keyword values to be used later
set awk_out = `awk '/^OVERRIDE_REQUIRED|^DLG_INGEST_PATH|^INGEST_TRIGGER_ROOT|^INGEST_SOURCE_DIR/{print $1,$3}' $pathfile`
#
while ($#awk_out)  # while more words in awk_out
  set kwname = $awk_out[1]
  shift awk_out 
  set kwvalue = $awk_out[1]
  shift awk_out
  # assign the keyword values to variables
  switch  ($kwname) 
    case OVERRIDE_REQUIRED:
      set override_req = $kwvalue
      breaksw
    case DLG_INGEST_PATH:
      set dlg_path = $kwvalue
      breaksw
    case INGEST_TRIGGER_ROOT:
      set trig_root = $kwvalue
      breaksw
    case INGEST_SOURCE_DIR:
      set ingest_src_dir = $kwvalue
      breaksw
  endsw  
end
# check that all keywords were found
if ($#override_req == 0) then
  echo "Unable to find OVERRIDE_REQUIRED in $pathfile"
  exit 1
endif
if ($#dlg_path == 0) then
  echo "Unable to find DLG_INGEST_PATH in $pathfile"
  exit 1
endif
if ($#dlg_path == 0) then
  echo "Unable to find INGEST_TRIGGER_ROOT in $pathfile"
  exit 1
endif
if ($#ingest_src_dir == 0) then
  echo "Unable to find INGEST_SOURCE_DIR in $pathfile"
  exit 1
endif
#
# check if override can be used for this path
if ($override_req !~ Y) then
  echo "OVERRIDE_REQUIRED is not set to Y in $pathfile"
  echo "The standard Ingest path cannot be used with this tool."
  exit 1
endif
#
# verify that the path is idle with no OSFs
echo "Verifying no OSF files present in $pathname path." 
set osf_list = `osf_test -p $pathname -pr dataset`
if ($status) then
   echo "Cannot access pipeline $pathname using osf_test."
   echo "Please verify pipeline servers are active and try again."
   exit 1
endif 
if ( $#osf_list > 1 ) then
   set pipeline_busy = 1
else if ( $#osf_list == 1 ) then
   set pipeline_busy = ($osf_list != "")
else
   set pipeline_busy = 0
endif   
if ( $pipeline_busy ) then
   echo "The osf_test tool for path $pathname has found pipeline OSFs."
   echo "The following OSF dataset names were found in pipeline $pathname"
   foreach dataset ($osf_list)
      echo $dataset
   end 
   echo "This tool must run only after all OSFs in this pipeline are gone."
   exit 1
endif
#
# reset data source override to REGR
rm -f ${ingest_src_dir}source_override.*
touch ${ingest_src_dir}source_override.regr
#
if (!(-d ./cal)) then
  echo "The default directory must be the regr directory."
  echo "This regr directory must contain subdirectories for each class."
  exit 1
endif
#----------------------------------------------------------------------  
echo "start processing STIS omama datasets"
cd acc
genreq -r genreq -t Oma life_fuv_20000123
touch ${trig_root}hst/life_fuv_20000123.Oma
genreq -r genreq -t Oma life_nuv_20000123
touch ${trig_root}hst/life_nuv_20000123.Oma
genreq -r genreq -t Oma life_nuv_20000123
touch ${trig_root}hst/life_nuv_20000123.Oma
genreq -r genreq -t Oma mama_fuv_20000118
touch ${trig_root}hst/mama_fuv_20000118.Oma
genreq -r genreq -t Oma mama_fuv_20000119
touch ${trig_root}hst/mama_fuv_20000119.Oma
genreq -r genreq -t Oma mama_fuv_20000120
touch ${trig_root}hst/mama_fuv_20000120.Oma
genreq -r genreq -t Oma mama_fuv_20000121
touch ${trig_root}hst/mama_fuv_20000121.Oma
genreq -r genreq -t Oma mama_fuv_20000122
touch ${trig_root}hst/mama_fuv_20000122.Oma
genreq -r genreq -t Oma mama_fuv_20000123
touch ${trig_root}hst/mama_fuv_20000123.Oma
genreq -r genreq -t Oma mama_nuv_20000117
touch ${trig_root}hst/mama_nuv_20000117.Oma
genreq -r genreq -t Oma mama_nuv_20000118
touch ${trig_root}hst/mama_nuv_20000118.Oma
genreq -r genreq -t Oma mama_nuv_20000119
touch ${trig_root}hst/mama_nuv_20000119.Oma
genreq -r genreq -t Oma mama_nuv_20000120
touch ${trig_root}hst/mama_nuv_20000120.Oma
genreq -r genreq -t Oma mama_nuv_20000121
touch ${trig_root}hst/mama_nuv_20000121.Oma
genreq -r genreq -t Oma mama_nuv_20000122
touch ${trig_root}hst/mama_nuv_20000122.Oma
genreq -r genreq -t Oma mama_nuv_20000123
touch ${trig_root}hst/mama_nuv_20000123.Oma
#
#----------------------------------------------------------------------  
echo "start processing ACS accum (data-id acc) (ACM class) dataset"
cd ../acm
genreq -r genreq -t Acc life_acs_20040723
touch ${trig_root}hst/life_acs_20040723.Acc
#
#----------------------------------------------------------------------  
echo "start processing HST ancillary (ANC class) dataset"
cd ../anc
genreq -r genreq -t Anc this_is_the_longest_file_in_dads_____39
touch ${trig_root}hst/this_is_the_longest_file_in_dads_____39.Anc
#
#----------------------------------------------------------------------  
echo "start processing astrometry (AST class)datasets"
cd ../ast
genreq -r astreq -t Ast f5gr230gm
touch ${trig_root}hst/f5gr230gm.Ast
genreq -r astreq -t Ast f92m020lm
touch ${trig_root}hst/f92m020lm.Ast
#
#----------------------------------------------------------------------  
echo "start processing HST calibrated science (CAL class) datasets"
cd ../cal
clean_request_members.pl j8rw19010 Aca
genreq -r genreq -t Aca j8rw19010
touch ${trig_root}hst/j8rw19010.Aca
genreq -r genreq -t Acs j8tlgfkmq
touch ${trig_root}hst/j8tlgfkmq.Acs
clean_request_members.pl n3zb1j010 Nas
genreq -r genreq -t Nas n3zb1j010
touch ${trig_root}hst/n3zb1j010.Nas
clean_request_members.pl n49j13090 Nas
genreq -r genreq -t Nas n49j13090
touch ${trig_root}hst/n49j13090.Nas
genreq -r genreq -t Nic n4k6miviq
touch ${trig_root}hst/n4k6miviq.Nic
genreq -r genreq -t Nic n4nf23xlq
touch ${trig_root}hst/n4nf23xlq.Nic
genreq -r genreq -t Nic n4nf29uxq
touch ${trig_root}hst/n4nf29uxq.Nic
genreq -r genreq -t Nic n4qsf5bfq
touch ${trig_root}hst/n4qsf5bfq.Nic
clean_request_members.pl n54h8s0e0 Nas
genreq -r genreq -t Nas n54h8s0e0
touch ${trig_root}hst/n54h8s0e0.Nas
genreq -r genreq -t Nic n58c2rsiq
touch ${trig_root}hst/n58c2rsiq.Nic
clean_request_members.pl n8vm21010 Nas
genreq -r genreq -t Nas n8vm21010
touch ${trig_root}hst/n8vm21010.Nas
clean_request_members.pl o54359020 Sas
genreq -r genreq -t Sas o54359020
touch ${trig_root}hst/o54359020.Sas
genreq -r genreq -t Sti o5hyb3zbq
touch ${trig_root}hst/o5hyb3zbq.Sti
genreq -r genreq -t Sti o5hyd3zlq
touch ${trig_root}hst/o5hyd3zlq.Sti
genreq -r genreq -t Sti o5i92by4q
touch ${trig_root}hst/o5i92by4q.Sti
genreq -r genreq -t Sti o8pg01q0q
touch ${trig_root}hst/o8pg01q0q.Sti
clean_request_members.pl o8ru12020 Sas
genreq -r genreq -t Sas o8ru12020
touch ${trig_root}hst/o8ru12020.Sas
genreq -r genreq -t Wf2 u21y0b02t
touch ${trig_root}hst/u21y0b02t.Wf2
genreq -r genreq -t Wf2 u5js0404r
touch ${trig_root}hst/u5js0404r.Wf2
#
#----------------------------------------------------------------------  
echo "start processing calibration reference (CDB class) datasets"
cd ../cdb
genreq -r cdbreq -t Cdb i4r1523bu
touch ${trig_root}hst/i4r1523bu.Cdb
genreq -r cdbreq -t Cdb o7f1140gj
touch ${trig_root}hst/o7f1140gj.Cdb
genreq -r cdbreq -t Cdb o7r13134o
touch ${trig_root}hst/o7r13134o.Cdb
#
#----------------------------------------------------------------------  
echo "start processing calibration table (CTB class) datasets"
cd ../ctb
genreq -r cdbreq -t Ctb nic2_f204m_003
touch ${trig_root}hst/nic2_f204m_003.Ctb
genreq -r cdbreq -t Ctb o680902su
touch ${trig_root}hst/o680902su.Ctb
genreq -r cdbreq -t Ctb o7811184j
touch ${trig_root}hst/o7811184j.Ctb
genreq -r cdbreq -t Ctb stis_005x31ndb_002
touch ${trig_root}hst/stis_005x31ndb_002.Ctb
#
#----------------------------------------------------------------------  
echo "start processing instrument dumps - diagnostic (DIA class) datasets"
cd ../dia
genreq -r genreq -t Ndm n20l7007q
touch ${trig_root}hst/n20l7007q.Ndm
genreq -r genreq -t Ndm n4ic03mhq
touch ${trig_root}hst/n4ic03mhq.Ndm
#
#----------------------------------------------------------------------  
echo "start processing DADS log (DLG class) dataset"
cd ../dlg
# there is no genreq process for DADS log files, just copy the one file
cp ingest_2004_06_18.log  $dlg_path
touch ${trig_root}hst/ingest_2004_06_18.Dlg
#
#----------------------------------------------------------------------  
echo "start processing HST dump (DMP class) datasets"
cd ../dmp
genreq -r genreq -t Dmp gtja92336
touch ${trig_root}hst/gtja92336.Dmp
genreq -r genreq -t Dmp gto7q1839
touch ${trig_root}hst/gto7q1839.Dmp
genreq -r genreq -t Dmp gtw5c0656
touch ${trig_root}hst/gtw5c0656.Dmp
#
#----------------------------------------------------------------------  
echo "start processing HST edited science (EDT class) datasets"
cd ../edt
genreq -r genreq -t Edj j8c011orq
touch ${trig_root}hst/j8c011orq.Edj
genreq -r genreq -t Edu u5hh2003r
touch ${trig_root}hst/u5hh2003r.Edu
#
#----------------------------------------------------------------------  
echo "start processing HST engineering parameter (EPC class) datasets"
cd ../epc
genreq -r fgsreq -t Epc n628w6ecj
touch ${trig_root}hst/n628w6ecj.Epc
genreq -r fgsreq -t Epc o91p08ajj
touch ${trig_root}hst/o91p08ajj.Epc
#
#----------------------------------------------------------------------  
echo "start processing HST mission schedule (MSC class) datasets"
cd ../msc
genreq -r pdrreq -t Msc ucac12130
touch ${trig_root}hst/ucac12130.Msc
genreq -r pdrreq -t Msc uo8515410
touch ${trig_root}hst/uo8515410.Msc
#
#----------------------------------------------------------------------  
echo "start processing HST mission timeline (MTL class) datasets"
cd ../mtl
genreq -r pdrreq -t Mtl vc8g07000
touch ${trig_root}hst/vc8g07000.Mtl
genreq -r pdrreq -t Mtl vo7r01460
touch ${trig_root}hst/vo7r01460.Mtl
#
#----------------------------------------------------------------------  
echo "start processing HST jitter (OMS class) datasets"
cd ../oms
genreq -r fgsreq -t Fgs j8tlgjm4j
touch ${trig_root}hst/j8tlgjm4j.Fgs
clean_request_members.pl n6296q020 Fas
genreq -r fgsreq -t Fas n6296q020
touch ${trig_root}hst/n6296q020.Fas
clean_request_members.pl o5el08020 Fas
genreq -r fgsreq -t Fas o5el08020
touch ${trig_root}hst/o5el08020.Fas
genreq -r fgsreq -t Fgs o8tt7gmcj
touch ${trig_root}hst/o8tt7gmcj.Fgs
genreq -r fgsreq -t Fgs u59g0108j
touch ${trig_root}hst/u59g0108j.Fgs
genreq -r fgsreq -t Fgs u8u84l01j
touch ${trig_root}hst/u8u84l01j.Fgs
#
#----------------------------------------------------------------------  
echo "start processing HST orbit (ORB class) datasets"
cd ../orb
genreq -r pdrreq -t Orb pkcv0000r
touch ${trig_root}hst/pkcv0000r.Orb
genreq -r pdrreq -t Orb po7r0000r
touch ${trig_root}hst/po7r0000r.Orb
#
#----------------------------------------------------------------------  
echo "start processing HST science telemetry (POD class) datasets"
cd ../pod
genreq -r genreq -t Pod lz_490c_235_0000258426
touch ${trig_root}hst/lz_490c_235_0000258426.Pod
genreq -r genreq -t Pod lz_499d_055_0000192499
touch ${trig_root}hst/lz_499d_055_0000192499.Pod
genreq -r genreq -t Pod lz_49b1_055_0000223073
touch ${trig_root}hst/lz_49b1_055_0000223073.Pod
genreq -r genreq -t Pod lz_49be_07_0000104361
touch ${trig_root}hst/lz_49be_07_0000104361.Pod
genreq -r genreq -t Pod lz_49d5_055_0000256201
touch ${trig_root}hst/lz_49d5_055_0000256201.Pod
genreq -r genreq -t Pod lz_49da1997060112152813
touch ${trig_root}hst/lz_49da1997060112152813.Pod
genreq -r genreq -t Pod lz_7e87_25_0000108398
touch ${trig_root}hst/lz_7e87_25_0000108398.Pod
genreq -r genreq -t Pod lz_7eb01997061416452236
touch ${trig_root}hst/lz_7eb01997061416452236.Pod
genreq -r genreq -t Pod lz_a236_371_0000258839
touch ${trig_root}hst/lz_a236_371_0000258839.Pod
genreq -r genreq -t Pod lz_a2481997062106055115
touch ${trig_root}hst/lz_a2481997062106055115.Pod
genreq -r genreq -t Pod lz_a253_141_0000104869
touch ${trig_root}hst/lz_a253_141_0000104869.Pod
genreq -r genreq -t Pod lz_a25e_265_0000221774
touch ${trig_root}hst/lz_a25e_265_0000221774.Pod
genreq -r genreq -t Pod lz_a260_211_0000192930
touch ${trig_root}hst/lz_a260_211_0000192930.Pod
genreq -r genreq -t Pod lz_a2cf_209_0000256059
touch ${trig_root}hst/lz_a2cf_209_0000256059.Pod
genreq -r genreq -t Pod lz_dc3f1997020721281461
touch ${trig_root}hst/lz_dc3f1997020721281461.Pod
#
#----------------------------------------------------------------------  
echo "start processing HST problem (PRB class) dataset"
cd ../prb
genreq -r genreq -t Prb v1630605t
touch ${trig_root}hst/v1630605t.Prb
#
#----------------------------------------------------------------------  
echo "start processing HST science mission schedule (SMS class) datasets"
cd ../sms
genreq -r pdrreq -t Sms yd5a11550
touch ${trig_root}hst/yd5a11550.Sms
genreq -r pdrreq -t Sms yo7q19000
touch ${trig_root}hst/yo7q19000.Sms
#
#----------------------------------------------------------------------  
echo "End of ingest requests for regression datasets"
exit
