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

File: [Development] / JSOC / proj / globalhs / scripts / doreweed (download)
Revision: 1.2, Wed Jun 18 05:04:24 2014 UTC (8 years, 11 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_8-6, Ver_8-5
Changes since 1.1: +1 -0 lines
setenv JSOCROOT /home/jsoc/cvs/Development/JSOC and prepend to path

#! /bin/tcsh -f

# this script reruns the final weeding of the peakbagging

setenv JSOCROOT /home/jsoc/cvs/Development/JSOC
setenv PATH $JSOCROOT/bin/$JSOC_MACHINE':'$JSOCROOT/proj/globalhs/scripts':'$JSOCROOT/proj/globalhs/scripts/pkbgn':'$PATH

set idldir=$JSOCROOT/proj/globalhs/scripts/idl
set pbdir=$JSOCROOT/proj/globalhs/scripts/pkbgn

@ 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

set timecheck = `echo "$totalsecs % 86400" | bc`
if ($timecheck) then
  echo totaltime must be an integer number of days
  exit 1
endif

set ndays = `echo "$totalsecs / 86400" | bc`


if (! $?lmin) set lmin = 0
if (! $?lmax) set lmax = 300

date
echo $PWD
echo $0 $argv

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

grep -v "^[[:space:]]*#" pkb.parms.blank | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$'  > parms.tmp
grep -v '^[[:space:]]*$' pkb.parms.blank | grep "^[[:space:]]*##" | awk -F '##' '{print $2}' | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$' > script.parms

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

# TAG may have been defined in script.parms 
if ($?TAG) then
  set tagclause = "TAG=$TAG"
else
  set tagclause = `cat parms.tmp | grep ^in= | cut -d= -f2- | sed s/"'"/""/g | sed s@"\["@"\n"@g | sed s@]@"\n"@g | grep TAG`
endif

if (! $?writeflag) set writeflag=1
if (! $?executable) set executable=jpkbgn

if (! $?ica) set ica=2
set npflags = `echo $npflags | cut -d, -f1- --output-delimiter=' '`
set amflags = `echo $amflags | cut -d, -f1- --output-delimiter=' '`
if ($#npflags != $niter || $#amflags != $niter) then
  echo problem with parameter file blank: number of flags does not match niter
  exit 1
endif

if (! $?iweed) set iweed=0
# the following is not used if iweed=0
if (! $?weedthresh) set weedthresh=10

set in = `cat parms.tmp | grep ^in= | sed s/\'//g | sed s/\"//g | awk -F '[=[]' '{print $2}'`
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`
set cadence = `show_info -j $in | grep -i '^keyword:t_step' | cut -d, -f5`
set ndt   = `echo "$totalsecs / $cadence" | bc`

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 index = `echo "($startsecs - $epochsecs)/$tstartstep" | bc`

set in = `cat parms.tmp | grep ^in= | sed s/\'//g | sed s/\"//g | awk -F 'in=' '{print $2}' | sed s/XXXX/$starttime/g | sed s/MMMM/$lmin-$lmax/g | sed s/TTTT/$ndt/g`
show_info -q "$in" key=calver64 > calver.tmp
set calver = `uniq calver.tmp`
if ($#calver > 1) then
  echo CALVER64 varies across the input
  exit 1
endif
if ($calver == InvalidKeyname) set calver=0

show_info -q "$in" key=version > version.tmp
set version = `uniq version.tmp`
if ($#version > 1) then
  echo VERSION varies across the input
  exit 1
endif

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


if (! -e save) then
  mkdir -p save
  mv *qr* save
endif
set tarfile = `show_info $archseries\[$starttime]\[$lmin]\[$lmax]\[$ndt]\[$tagclause] -qAP` 
tar -xzf $tarfile m10q m10q.18 m10q.36 par10


set last=$niter

set thi=`cat m$last{q.36} | wc -l`
set eig=`cat m$last{q.18} | wc -l`
set six=`cat m$last{q} | wc -l`

echo $six $eig $thi $last $firstday > list
idl << EOF
weed,$ndt,$cadence,$ica
EOF

if (! -es split$last{qr}.$firstday.18.2d) then
  echo error in weeding, splittings file either does not exist or is empty
  exit 1
endif
echo weeding done, splittings files made

rm -f m10q m10q.18 m10q.36 par10

set nonomatch
set histlink = `show_info $archseries\[$starttime]\[$lmin]\[$lmax]\[$ndt]\[$tagclause] -qK`

set tstart = `time_convert s=$startsecs zone=TAI`
set stopsecs = `echo "$startsecs + $totalsecs" | bc`
set tstop = `time_convert s=$stopsecs zone=TAI`
set midsecs = `echo "$startsecs + ($totalsecs / 2)" | bc`
set tobs = `time_convert s=$midsecs zone=TAI`
set now = `date -u  +%Y.%m.%d_%T`

set_info -c ds=$modeseries HISTORY=$histlink $tagclause $verclause NDT=$ndt LMIN=$lmin LMAX=$lmax T_START=$tstart T_STOP=$tstop T_OBS=$tobs CALVER64=$calver DATE=$now m6=m$last{qr}.$firstday m18=m$last{qr}.$firstday.18 m36=m$last{qr}.$firstday.36
if ($?) then
    echo failure to ingest mode parameters for starttime = $starttime, totaltime = $totaltime
    exit 1
endif

rm calver.tmp version.tmp parms.tmp script.parms list
echo successful completion
exit 0


Karen Tian
Powered by
ViewCVS 0.9.4