(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.7, Fri Oct 17 11:15:53 2014 UTC (3 years, 3 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-12, Ver_8-11, Ver_8-10, HEAD
Changes since 1.6: +1 -1 lines
add HOST information to output

#! /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 = ''

echo `date` on $HOST
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