![]() ![]() |
![]() |
File: [Development] / JSOC / proj / globalhs / scripts / dogfgaps
(download)
Revision: 1.9, Thu Feb 13 23:39:01 2014 UTC (9 years, 3 months ago) by tplarson Branch: MAIN CVS Tags: Ver_8-6, Ver_8-5, Ver_8-4 Changes since 1.8: +2 -2 lines add rm version.tmp |
#! /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 (! $?lmin) set lmin = 0 if (! $?lmax) set lmax = 300 date echo $PWD echo $0 $argv if (! -es tsf.parms.blank) then echo parameter file blank missing: tsf.parms.blank is required exit 1 endif grep -v "^[[:space:]]*#" tsf.parms.blank | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$' > parms.tmp grep "^[[:space:]]*##" tsf.parms.blank | awk -F '##' '{print $2}' > script.parms set vars = `cat script.parms` @ i = 1 while ($i <= $#vars ) set $vars[$i] @ i++ end set out = `cat parms.tmp | grep ^tsout= | cut -d= -f2` 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` if ($lmin > 3) then set lgap=$lmin else if ($lmax < 3) then set lgap=$lmax else set lgap=3 endif set tagclause = `cat parms.tmp | grep ^TAG=` if ($#tagclause == 0) set tagclause = `cat parms.tmp | grep ^in= | cut -d= -f2- | sed s/"'"/""/g | sed s@"\["@"\n"@g | sed s@]@"\n"@g | grep TAG` show_info -q $out\[$starttime]\[$lmin-$lmax]\[]\[$ndt]\[$tagclause] key=version > version.tmp set version = `uniq version.tmp` if ($#version > 1) then echo VERSION varies across the input exit 1 endif set file = `show_info $out\[$starttime]\[$lgap]\[$lgap]\[$ndt]\[$tagclause] -Apq` if ($#file == 0) then echo could not find record in output dataseries for $starttime exit 1 endif idl << EOF q=fitsio_read_image('$file') sz=size(q) nx=sz[1]/2 if (nx ne $ndt) then exit ix=2*lindgen(nx) qave=rebin(abs(q[ix,*]),nx,1)+rebin(abs(q[ix+1,*]),nx,1) w=where(finite(qave) and (qave ne 0)) gnew=fltarr(nx) gnew[w]=1 writefits,'gapsrml.$ndays.$firstday.fits',gnew EOF if ($version != InvalidKeyname) then set verclause = "VERSION=$version" else set verclause = "" endif if (`filetest -es gapsrml.$ndays.$firstday.fits`) then ingestgaps in=gapsrml.$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 echo successful completion rm script.parms version.tmp exit 0
Karen Tian |
Powered by ViewCVS 0.9.4 |