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

File: [Development] / JSOC / proj / globalhs / scripts / ingestgaps (download)
Revision: 1.7, Thu May 29 19:29:18 2014 UTC (3 years, 7 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-12, Ver_8-11, Ver_8-10, HEAD
Changes since 1.6: +3 -3 lines
now handle TAG the same as VERSION

#! /bin/tcsh

# this script requires the following arguments:
# in    = fits file containing timeseries to be ingested
# out   = name of dataseries to ingest file into
# day   = day number of first day of timeseries
# ndays = number of days in the timeseries

setenv PATH $JSOCROOT/bin/$JSOC_MACHINE':'$PATH

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

set epoch = `show_info -j $out | grep -i '^keyword:t_start_epoch' | cut -d, -f5`
set epochsecs = `time_convert o=jsoc time=$epoch`
set tstep = `show_info -j $out | grep -i '^keyword:t_step' | cut -d, -f5`

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

set curdir = $PWD

cat > ingestgaps.idl.tmp << EOF
g=readfits('$in')
n=n_elements(g)
dc=total(g)/n
g=byte(g)
if (n ne $ndays*86400L/$tstep) then exit

sxaddpar,header,'SIMPLE','T'
sxaddpar,header,'BITPIX',8
sxaddpar,header,'NAXIS',1
sxaddpar,header,'NAXIS1',n

sxaddpar,header,'T_START','$tstart'
sxaddpar,header,'T_STOP','$tstop'
sxaddpar,header,'T_OBS','$tobs'
sxaddpar,header,'DATE','$now'
sxaddpar,header,'DUTYCYCL',dc
sxaddpar,header,'NDT',n
sxaddpar,header,'PATH','$curdir'
sxaddpar,header,'FILE','$in'

EOF
if ($?TAG) then
 echo sxaddpar,header,\'TAG\',\'$TAG\' >> ingestgaps.idl.tmp
endif
if ($?VERSION) then
 echo sxaddpar,header,\'VERSION\',\'$VERSION\' >> ingestgaps.idl.tmp
endif
echo writefits,\'gapstmp.$ndays.$day.fits\',g,header >> ingestgaps.idl.tmp

idl<ingestgaps.idl.tmp

ingest_from_fits in=gapstmp.$ndays.$day.fits ds=$out
set stat = $status
if ($stat == 0) then
  rm gapstmp.$ndays.$day.fits ingestgaps.idl.tmp
endif
exit $stat

Karen Tian
Powered by
ViewCVS 0.9.4