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

File: [Development] / JSOC / proj / globalhs / scripts / ingestlzero (download)
Revision: 1.3, Tue Jul 2 19:07:07 2013 UTC (9 years, 11 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, HEAD
Changes since 1.2: +5 -0 lines
added setting of PATH and checking of data VERSION to scripts

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

idl << EOF
q=fitsio_read_image('$in')
nx=n_elements(q)/2
ix=2*lindgen(nx)
x=q[ix]
w=where(finite(x) and x ne 0)
x=x[w]
m=moment(x)
minx=min(x)
maxx=max(x)
rms=sqrt(mean(x*x))
med=median(x)

sxaddpar,header,'SIMPLE','T'
sxaddpar,header,'BITPIX',-32
sxaddpar,header,'NAXIS',2
sxaddpar,header,'NAXIS1',2*nx
sxaddpar,header,'NAXIS2',1                                               

sxaddpar,header,'NDT',nx
sxaddpar,header,'T_START','$tstart'
sxaddpar,header,'T_STOP','$tstop'
sxaddpar,header,'T_OBS','$tobs'
sxaddpar,header,'DATE','$now'
sxaddpar,header,'DATAMIN',minx
sxaddpar,header,'DATAMAX',maxx
sxaddpar,header,'DATARMS',rms
sxaddpar,header,'DATAMEAN',m[0]
sxaddpar,header,'DATAMEDN',med
sxaddpar,header,'DATASKEW',m[2]
sxaddpar,header,'DATAKURT',m[3]
sxaddpar,header,'PATH','$curdir'
sxaddpar,header,'FILE','$in'

writefits,'lzerotmp.$ndays.$day.fits',q,header
EOF

ingest_from_fits in=lzerotmp.$ndays.$day.fits ds=$out
set stat = $status
if (! $stat) rm lzerotmp.$ndays.$day.fits
exit $stat

Karen Tian
Powered by
ViewCVS 0.9.4