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

File: [Development] / JSOC / proj / globalhs / scripts / domkgaps (download)
Revision: 1.16, Sat Nov 12 03:24:41 2016 UTC (20 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_9-1, Ver_9-0, Ver_8-12
Changes since 1.15: +3 -0 lines
add calversecs

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

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 -v "^[[:space:]]*#"  ret.parms.blank | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$' > parms.tmp
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 (! $?calversecs) set calversecs = 0

if (`echo $sourcetype | grep -c hmi`) set secsref=''
if ($?copyto) then
  set out=$copyto
else
  set out = `cat parms.tmp | grep ^out= | cut -d= -f2`
endif

set tagclause = `cat parms.tmp | grep ^in= | cut -d= -f2- | sed s/"'"/""/g | sed s@"\["@"\n"@g | sed s@]@"\n"@g | grep TAG`

set epoch = `show_info -j $out | grep -i '^keyword:t_start_epoch' | cut -d, -f5`
set epochsecs = `time_convert o=jsoc time=$epoch`
set cadence = `show_info -j $out | grep -i '^keyword:t_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 ndays = `echo $totalsecs / 86400 | bc`
set ndt   = `echo $totalsecs / $cadence | bc`

show_info -q $out\[$starttime]\[0-50]\[]\[$ndt]\[$tagclause] key=version > version.tmp
set versionin = `uniq version.tmp`
if ($#versionin > 1) then
  echo VERSION varies across the input
  exit 1
endif

show_info $out\[$starttime]\[0,1,2,5,10,20,50]\[]\[$ndt]\[$tagclause] -Apq >& $firstday.pathlist
if (`cat $firstday.pathlist | wc -l` != 7) then
  echo something is missing
  exit 1
endif

set list=`cat $firstday.pathlist`

cat > mkgaps.$firstday.idl << EOF
day=$firstday
ndays=$ndays
tstep=$cadence
secsref='$secsref'
calversecs=$calversecs
x0=fitsio_read_image('$list[1]')
x1=fitsio_read_image('$list[2]')
x2=fitsio_read_image('$list[3]')
x5=fitsio_read_image('$list[4]')
x10=fitsio_read_image('$list[5]')
x20=fitsio_read_image('$list[6]')
x50=fitsio_read_image('$list[7]')

nx=n_elements(x0)/2
if (nx ne $ndt) then exit
ix=2*lindgen(nx)
sum1=fltarr(nx)
for i=0,1 do sum1=sum1+abs(x1(ix,i))+abs(x1(ix+1,i))
sum2=fltarr(nx)
for i=0,2 do sum2=sum2+abs(x2(ix,i))+abs(x2(ix+1,i))
sum5=fltarr(nx)
for i=0,5 do sum5=sum5+abs(x5(ix,i))+abs(x5(ix+1,i))
sum10=fltarr(nx)
for i=0,10 do sum10=sum10+abs(x10(ix,i))+abs(x10(ix+1,i))
sum20=fltarr(nx)
for i=0,20 do sum20=sum20+abs(x20(ix,i))+abs(x20(ix+1,i))
sum50=fltarr(nx)
for i=0,50 do sum50=sum50+abs(x50(ix,i))+abs(x50(ix+1,i))

w0=where(finite(x0(ix)) and (x0(ix) ne 0),c0)
g0=fltarr(nx)
g0(w0)=1

EOF

cat $idldir/getissandsecs.$sourcetype.idl >> mkgaps.$firstday.idl

cat >> mkgaps.$firstday.idl << EOF
g=g0*g2

x=x0[ix]
wmf=medfilt(day,x,g2,tstep,xmed0,rms=rms0,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=x1[ix,0]
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=x1[ix,1]
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=x1[ix+1,1]
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0

x=sum1
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=sum2
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=sum5
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=sum10
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=sum20
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0
x=sum50
wmf=medfilt(day,x,g2,tstep,nwmf=nwmf)
if (nwmf ne 0) then g[wmf]=0

EOF

cat $idldir/finishgaps.$sourcetype.idl >> mkgaps.$firstday.idl
echo writefits,\'gaps.$ndays.$firstday.fits\',g >> mkgaps.$firstday.idl

idl<mkgaps.$firstday.idl

# TAG may have been defined in script.parms above
if ($?TAG) then
  set tagclause = "TAG=$TAG"
endif

# VERSION may have been defined in script.parms above
if ($?VERSION) then
  set verclause = "VERSION=$VERSION"
else if ($versionin != InvalidKeyname) then
  set verclause = "VERSION=$versionin"
else
  set verclause = ""
endif

if (`filetest -es gaps.$ndays.$firstday.fits`) then
  ingestgaps in=gaps.$ndays.$firstday.fits out=$gapsmade 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 parms.tmp script.parms $firstday.pathlist version.tmp

exit 0

Karen Tian
Powered by
ViewCVS 0.9.4