#!/bin/tcsh -fx
#-------------------------------------------------------------
# catalog_regr_datasets.csh
#
# Purpose: catalog collections of REGR datasets after ingest pipeline is done
#
# Environment: 
#      The default directory be the regr directory of the regression datasets
#
# Usage: catalog_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: catalog_regr_datasets.csh regr
#
# Modification history:
#
#   date    opr     who     reason
# -------- -----  --------  --------------------------------------
# 09/02/04 51879  J.Baum    first version
# 08/30/10 59963  Sherbert  rm fuse in cases these ever used
# 09/10/12 70213  MSwam     use tcsh
#--------------------------------------------------------------------------
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|^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 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 ($#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
#
# remove data source override 
rm -f ${ingest_src_dir}source_override.*
#
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
catalog -r cat_oma life_fuv_20000123.oma
update_db_tool -r hkp_sci -t oma life_fuv_20000123
catalog -r cat_oma life_nuv_20000123.oma
update_db_tool -r hkp_sci -t oma life_nuv_20000123
catalog -r cat_oma life_nuv_20000123.oma
update_db_tool -r hkp_sci -t oma life_nuv_20000123
catalog -r cat_oma mama_fuv_20000118.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000118
catalog -r cat_oma mama_fuv_20000119.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000119
catalog -r cat_oma mama_fuv_20000120.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000120
catalog -r cat_oma mama_fuv_20000121.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000121
catalog -r cat_oma mama_fuv_20000122.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000122
catalog -r cat_oma mama_fuv_20000123.oma
update_db_tool -r hkp_sci -t oma mama_fuv_20000123
catalog -r cat_oma mama_nuv_20000117.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000117
catalog -r cat_oma mama_nuv_20000118.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000118
catalog -r cat_oma mama_nuv_20000119.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000119
catalog -r cat_oma mama_nuv_20000120.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000120
catalog -r cat_oma mama_nuv_20000121.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000121
catalog -r cat_oma mama_nuv_20000122.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000122
catalog -r cat_oma mama_nuv_20000123.oma
update_db_tool -r hkp_sci -t oma mama_nuv_20000123
#----------------------------------------------------------------------  
echo "start processing ACS accum (data-id acc) (ACM class) dataset"
cd ../acm
catalog -r cat_acc life_acs_20040723.acc
update_db_tool -r hkp_sci -t acc life_acs_20040723
#
#
#----------------------------------------------------------------------  
echo "start processing astrometry (AST class)datasets"
cd ../ast
catalog -r cat_ast f5gr230gm.ast
update_db_tool -r hkp_ast -t ast f5gr230gm
catalog -r cat_ast f92m020lm.ast
update_db_tool -r hkp_ast -t ast f92m020lm
#
#----------------------------------------------------------------------  
echo "start processing HST calibrated science (CAL class) datasets"
cd ../cal
InteractiveIngResponse.csh j8rw19010 Aca ./
clean_request_members.pl j8rw19010 Aca
catalog -r cat_acs j8rw19010.aca
update_db_tool -r hkp_sci -t aca j8rw19010
InteractiveIngResponse.csh j8tlgfkmq Acs ./
catalog -r cat_acs j8tlgfkmq.acs
update_db_tool -r hkp_sci -t acs j8tlgfkmq
InteractiveIngResponse.csh n3zb1j010 Nas ./
clean_request_members.pl n3zb1j010 Nas
catalog -r cat_nic n3zb1j010.nas
update_db_tool -r hkp_sci -t nas n3zb1j010
InteractiveIngResponse.csh n49j13090 Nas ./
clean_request_members.pl n49j13090 Nas
catalog -r cat_nic n49j13090.nas
update_db_tool -r hkp_sci -t nas n49j13090
InteractiveIngResponse.csh n4k6miviq Nic ./
catalog -r cat_nic n4k6miviq.nic
update_db_tool -r hkp_sci -t nic n4k6miviq
InteractiveIngResponse.csh n4nf23xlq Nic ./
catalog -r cat_nic n4nf23xlq.nic
update_db_tool -r hkp_sci -t nic n4nf23xlq
InteractiveIngResponse.csh n4nf29uxq Nic ./
catalog -r cat_nic n4nf29uxq.nic
update_db_tool -r hkp_sci -t nic n4nf29uxq
InteractiveIngResponse.csh n4qsf5bfq Nic ./
catalog -r cat_nic n4qsf5bfq.nic
update_db_tool -r hkp_sci -t nic n4qsf5bfq
InteractiveIngResponse.csh n54h8s0e0 Nas ./
clean_request_members.pl n54h8s0e0 Nas
catalog -r cat_nic n54h8s0e0.nas
update_db_tool -r hkp_sci -t nas n54h8s0e0
InteractiveIngResponse.csh n58c2rsiq Nic ./
catalog -r cat_nic n58c2rsiq.nic
update_db_tool -r hkp_sci -t nic n58c2rsiq
InteractiveIngResponse.csh n8vm21010 Nas ./
clean_request_members.pl n8vm21010 Nas
catalog -r cat_nic n8vm21010.nas
update_db_tool -r hkp_sci -t nas n8vm21010
InteractiveIngResponse.csh o54359020 Sas ./
clean_request_members.pl o54359020 Sas
catalog -r cat_sti o54359020.sas
update_db_tool -r hkp_sci -t sas o54359020
InteractiveIngResponse.csh o5hyb3zbq Sti ./
catalog -r cat_sti o5hyb3zbq.sti
update_db_tool -r hkp_sci -t sti o5hyb3zbq
InteractiveIngResponse.csh o5hyd3zlq Sti ./
catalog -r cat_sti o5hyd3zlq.sti
update_db_tool -r hkp_sci -t sti o5hyd3zlq
InteractiveIngResponse.csh o5i92by4q Sti ./
catalog -r cat_sti o5i92by4q.sti
update_db_tool -r hkp_sci -t sti o5i92by4q
InteractiveIngResponse.csh o8pg01q0q Sti ./
catalog -r cat_sti o8pg01q0q.sti
update_db_tool -r hkp_sci -t sti o8pg01q0q
InteractiveIngResponse.csh o8ru12020 Sas ./
clean_request_members.pl o8ru12020 Sas
catalog -r cat_sti o8ru12020.sas
update_db_tool -r hkp_sci -t sas o8ru12020
InteractiveIngResponse.csh u21y0b02t Wf2 ./
catalog -r cat_wf2 u21y0b02t.wf2
update_db_tool -r hkp_sci -t wf2 u21y0b02t
InteractiveIngResponse.csh u5js0404r Wf2 ./
catalog -r cat_wf2 u5js0404r.wf2
update_db_tool -r hkp_sci -t wf2 u5js0404r
#
#----------------------------------------------------------------------  
echo "start processing instrument dumps - diagnostic (DIA class) datasets"
cd ../dia
update_db_tool -r hkp_sci -t ndm n20l7007q
update_db_tool -r hkp_sci -t ndm n4ic03mhq
#
#----------------------------------------------------------------------  
echo "start processing HST edited science (EDT class) datasets"
cd ../edt
update_db_tool -r hkp_sci -t edj j8c011orq
update_db_tool -r hkp_sci -t edu u5hh2003r
#
#----------------------------------------------------------------------  
echo "start processing HST engineering parameter (EPC class) datasets"
cd ../epc
update_db_tool -r hkp_fgs -t epc n628w6ecj
update_db_tool -r hkp_fgs -t epc o91p08ajj
#
#----------------------------------------------------------------------  
echo "start processing HST mission schedule (MSC class) datasets"
cd ../msc
update_db_tool -r hkp_pdr -t msc ucac12130
update_db_tool -r hkp_pdr -t msc uo8515410
#
#----------------------------------------------------------------------  
echo "start processing HST mission timeline (MTL class) datasets"
cd ../mtl
update_db_tool -r hkp_pdr -t mtl vc8g07000
update_db_tool -r hkp_pdr -t mtl vo7r01460
#
#----------------------------------------------------------------------  
echo "start processing HST jitter (OMS class) datasets"
cd ../oms
catalog -r cat_fgs j8tlgjm4j.fgs
update_db_tool -r hkp_fgs -t fgs j8tlgjm4j
clean_request_members.pl n6296q020 Fas
catalog -r cat_fgs n6296q020.fas
update_db_tool -r hkp_fgs -t fas n6296q020
clean_request_members.pl o5el08020 Fas
catalog -r cat_fgs o5el08020.fas
update_db_tool -r hkp_fgs -t fas o5el08020
catalog -r cat_fgs o8tt7gmcj.fgs
update_db_tool -r hkp_fgs -t fgs o8tt7gmcj
catalog -r cat_fgs u59g0108j.fgs
update_db_tool -r hkp_fgs -t fgs u59g0108j
catalog -r cat_fgs u8u84l01j.fgs
update_db_tool -r hkp_fgs -t fgs u8u84l01j
#
#----------------------------------------------------------------------  
echo "start processing HST orbit (ORB class) datasets"
cd ../orb
update_db_tool -r hkp_pdr -t orb pkcv0000r
update_db_tool -r hkp_pdr -t orb po7r0000r
#
#----------------------------------------------------------------------  
echo "start processing HST science telemetry (POD class) datasets"
cd ../pod
update_db_tool -r hkp_sci -t pod lz_490c_235_0000258426
update_db_tool -r hkp_sci -t pod lz_499d_055_0000192499
update_db_tool -r hkp_sci -t pod lz_49b1_055_0000223073
update_db_tool -r hkp_sci -t pod lz_49be_07_0000104361
update_db_tool -r hkp_sci -t pod lz_49d5_055_0000256201
update_db_tool -r hkp_sci -t pod lz_49da1997060112152813
update_db_tool -r hkp_sci -t pod lz_7e87_25_0000108398
update_db_tool -r hkp_sci -t pod lz_7eb01997061416452236
update_db_tool -r hkp_sci -t pod lz_a236_371_0000258839
update_db_tool -r hkp_sci -t pod lz_a2481997062106055115
update_db_tool -r hkp_sci -t pod lz_a253_141_0000104869
update_db_tool -r hkp_sci -t pod lz_a25e_265_0000221774
update_db_tool -r hkp_sci -t pod lz_a260_211_0000192930
update_db_tool -r hkp_sci -t pod lz_a2cf_209_0000256059
update_db_tool -r hkp_sci -t pod lz_dc3f1997020721281461
#
#----------------------------------------------------------------------  
echo "start processing HST science mission schedule (SMS class) datasets"
cd ../sms
catalog_ascii_main.py -r cat_sms -d yd5a11550 -a sms
update_db_tool -r hkp_pdr -t sms yd5a11550
catalog_ascii_main.py -r cat_sms -d yo7q19000 -a sms
update_db_tool -r hkp_pdr -t sms yo7q19000
#
#----------------------------------------------------------------------  
echo "End of catalog processing for regression datasets"
exit
