(file) Return to docatgaps CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / scripts

File: [Development] / JSOC / proj / globalhs / scripts / docatgaps (download)
Revision: 1.6, Thu May 29 20:11:17 2014 UTC (9 years ago) by tplarson
Branch: MAIN
CVS Tags: Ver_8-6, Ver_8-5
Changes since 1.5: +28 -13 lines
change construction of input recordset, propagate VERSION

#! /bin/tcsh -f

setenv PATH $JSOCROOT/bin/$JSOC_MACHINE':'$JSOCROOT/proj/globalhs/scripts':'$PATH
set idldir=$JSOCROOT/proj/globalhs/scripts/idl

@ i = 1
while ($i <= $#argv )
  set $argv[$i]
@ i++
end

if (! $?starttime) then
  echo must specify parameter starttime
  exit 1
endif

if (! $?totaltime) then
  echo must specify parameter totaltime
  exit 1
endif

set totalsecs = `durcon $totaltime`
if ($status) then
  echo incorrect format for parameter totaltime
  exit 1
endif

if (! $?ndtin) set ndtin = ''

date
echo $PWD
echo $0 $argv


if (! -es ret.parms.blank) then
  echo parameter file blank missing: ret.parms.blank is required
  exit 1
endif

grep "^[[:space:]]*##" ret.parms.blank | awk -F '##' '{print $2}' > script.parms

set vars = `cat script.parms`
@ i = 1
while ($i <= $#vars )
  set $vars[$i]
@ i++
end

if ($?TAG) then
  set tagclause = "TAG=$TAG"
else
  set tagclause = ""
endif

set in = $gapsin
set epoch = `show_info -j $in | grep -i '^keyword:t_start_epoch' | cut -d, -f5`
set epochsecs = `time_convert o=jsoc time=$epoch`
set tstartstep = `show_info -j $in | grep -i '^keyword:t_start_step' | cut -d, -f5`

durcon $starttime >& /dev/null
if ($status) then
  set startsecs = `time_convert o=jsoc time=$starttime`
  set firstday  = `echo "($startsecs - $epochsecs)/86400" | bc` 
else
  set startsecs = `durcon $starttime` 
  set firstday = `echo "$startsecs / 86400" | bc`
  set startsecs = `echo "$startsecs + $epochsecs" | bc`
endif

set start = `time_convert o=cal zone=tai s=$startsecs`
set firstindexin = `show_info -q $in\[]\[$ndtin]\[$tagclause]'[? t_start <= $('$start') and t_stop > $('$start') ?]' key=t_start_index`

set firstindexout = `echo "($startsecs - $epochsecs)/$tstartstep" | bc`
set indexchunkout = `echo "$totalsecs/$tstartstep" | bc`
@ indexchunkin = ($firstindexout - $firstindexin) + $indexchunkout

show_info $in'[#'$firstindexin/$indexchunkin]\[$ndtin]\[$tagclause] key=version -q > version.tmp
set versionin = `uniq version.tmp`
if ($#versionin > 1) then
  echo VERSION varies across the input
  exit 1
endif

if ($versionin != InvalidKeyname) then
  set verclause = "VERSION=$versionin"
else
  set verclause = ""
endif

show_info $gapsin'[#'$firstindexin/$indexchunkin]\[$ndtin]\[$tagclause] key=t_start_index,ndt -APq > gaplist.tmp

set cadence = `show_info -j $gapsout | grep -i '^keyword:t_step' | cut -d, -f5`
set ndays = `echo $totalsecs / 86400 | bc`
set ndt   = `echo $totalsecs / $cadence | bc`

idl<<EOF
catgaps,$firstday,$ndt,$cadence,'gaplist.tmp'
mksec,$firstday,$ndt,$cadence,ref='$secsref'
EOF

if (`filetest -es gaps.$ndays.$firstday.fits`) then
  ingestgaps in=gaps.$ndays.$firstday.fits out=$gapsout day=$firstday ndays=$ndays $tagclause $verclause
  if ($?) then
    echo failure to ingest gaps for starttime = $starttime, totaltime = $totaltime
    exit 1
  endif
else
  echo failure to make gaps for starttime = $starttime, totaltime = $totaltime
  exit 1
endif

if (`filetest -es secs.$ndays.$firstday`) then
  ingestsecs in=secs.$ndays.$firstday out=$secsmade day=$firstday ndays=$ndays
  if ($?) then
    echo failure to ingest secs for starttime = $starttime, totaltime = $totaltime
    exit 1
  endif
else
  echo failure to make secs for starttime = $starttime, totaltime = $totaltime
  exit 1
endif

echo successful completion

rm script.parms gaplist.tmp version.tmp

exit 0

Karen Tian
Powered by
ViewCVS 0.9.4