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

File: [Development] / JSOC / proj / globalhs / scripts / domkleak (download)
Revision: 1.2, Fri May 15 18:49:43 2015 UTC (3 years, 2 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_9-1, Ver_9-0, Ver_8-12, Ver_8-11, Ver_8-10
Changes since 1.1: +29 -31 lines
now pass tag as input parameter

#!/bin/tcsh -f

setenv PATH $JSOCROOT/bin/$JSOC_MACHINE':'$JSOCROOT/proj/globalhs/scripts':'$PATH

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

if (! $?tag) then
  echo must specify parameter tag
  exit 1
endif

if (! $?deltal) set deltal = 6
if (! $?deltam) set deltam = 15
#if (! $?xoffset) set xoffset = 0.0
#if (! $?yoffset) set yoffset = 0.0
#if (! $?pangle) set pangle = 0.0
#if (! $?bangle) set bangle = 0.0
#if (! $?obsdist) set obsdist = 1.000
if (! $?segment) set segment = vradsum
set tag2=$tag'_'$segment

echo `date` on $HOST
echo $PWD
echo $0 $argv

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

set tstart = `cat ../ylm.parms.blank | grep -v "^[[:space:]]*#" | grep TSTART= | cut -d= -f2`
if ($#tstart == 0) then
@ line = `mkylms -H | grep -n "TSTART (time)" | cut -d: -f1` + 1
  set tstart = `mkylms -H | sed -n $line'p' | awk '{print $3}'`
endif
set startsecs = `time_convert o=jsoc time=$tstart`

set file = `cat ../ylm.parms.blank | grep -v "^[[:space:]]*#" | grep MODELIST= | cut -d= -f2`
if (! -es ../$file) then
  echo MODELIST file $file is missing
  exit 1
endif
set nim=`cat ../$file | wc -l`

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

grep -v "^[[:space:]]*#" v2t.parms.blank | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$' > parms.tmp

#set tagblank = `cat parms.tmp | grep TAG= | cut -d= -f2`
#if ($#tagblank == 0) then
#  set tag = none
#else
#  set tagsuff = $xoffset'_'$yoffset'_'$pangle'_'$bangle'_'$obsdist'_'$segment
#  set tag = `echo $tagblank | sed s/TTTT/$tagsuff/`
#endif

set out = `cat parms.tmp | grep -v "^[[:space:]]*#" | grep out= | cut -d= -f2`
set tstep = `show_info -j $out | grep -i '^keyword:t_step' | cut -d, -f5`
set tchunk = `cat parms.tmp | grep -v "^[[:space:]]*#" | grep TCHUNK= | cut -d= -f2`
set chunksecs = `durcon $tchunk`
set recchunk = `echo "$chunksecs/$tstep" | bc`
@ nchunks = ( ( $nim - 1 ) / $recchunk ) + 1

set epoch = `show_info -j $out | grep -i '^keyword:t_start_epoch' | cut -d, -f5`
set epochsecs = `time_convert o=jsoc time=$epoch`
set tstartstep = `show_info -j $out | grep -i '^keyword:t_start_step' | cut -d, -f5`
set firstindex = `echo "($startsecs - $epochsecs)/$tstartstep" | bc`

show_info -q $out"[#$firstindex/$nchunks][TAG = $tag2]" -AP key=lmin,lmax > files.$segment.txt

idl << EOF
.run
dl=$deltal
dm=$deltam
file='../$file'

q=readx(file,nlin=nim)
q=long(q)
lim=(q[0,*])[*]
mim=(q[1,*])[*]
recchunk=$recchunk
nchunks = ((nim-1)/recchunk) + 1

lmaxl=max(lim)+dl
ndl=2*dl+1
ndm=2*dm+1
dla=rebin(reform(lindgen(ndl)-dl,1,ndl),ndm,ndl)
dma=rebin(reform(lindgen(ndm)-dm,ndm,1),ndm,ndl)
leakr1=fltarr(ndm,ndl,nim)
leaki1=fltarr(ndm,ndl,nim)

spawn,'cat files.$segment.txt',hold

for i=0L,nchunks-1 do begin
  offset = i * recchunk
  words=strsplit(hold[i],/extract)
  llmin=long(words[0])
  llmax=long(words[1])
  print,i,llmin,llmax

  leak0=readfits(words[2])
  nleak0=llmin*(llmin+1)/2
  nleak=(llmax+1)*(llmax+2)/2-nleak0
  leak0=reform(leak0,2,recchunk,nleak,/overwrite)

  nin=recchunk
  if (offset + recchunk gt nim) then nin=nim-offset

  for it=0,nin-1 do begin
    l=lim[offset+it]
    m=mim[offset+it]
;    print,i,it,l,m
    lx=l+dla
    mx=m+dma
    ix=lx*(lx+1)/2+mx-nleak0
    w=where((lx ge 0) and (lx le lmaxl) and (mx ge 0) and (mx le lx))
    lr=dblarr(ndm,ndl)+10
    li=dblarr(ndm,ndl)+20
    lr(w)=leak0(0,it,ix(w))/(1000./sqrt(2.))
    li(w)=leak0(1,it,ix(w))/(1000./sqrt(2.))
    leakr1(*,*,it+offset)=lr
    leaki1(*,*,it+offset)=li
  end
end

writefits,'leakrlist.$segment.fits',leakr1
writefits,'leakilist.$segment.fits',leaki1

;stop

;lmax1=310l
;lmaxi=min(lim(where(lim ge lmax1))) ; Where to truncate input leaks
;w=where(lim le lmaxi,nim)
;lim=lim(w)
;mim=mim(w)
;leakrp=(leaki1(*,*,w)+leakr1(*,*,w))/2
;leakrm=(leaki1(*,*,w)-leakr1(*,*,w))/2

lmax1=max(lim)
leakrp=(leaki1+leakr1)/2
leakrm=(leaki1-leakr1)/2

leakr1=0l
leaki1=0l

leakrr1=fltarr(2*dm+1,2*dl+1,lmax1+1,lmax1+1)
leakri1=fltarr(2*dm+1,2*dl+1,lmax1+1,lmax1+1)

doodd=1l
for l1=0l,lmax1 do begin
  print,l1
  for il=0l,2*dl do begin
    dl1=il-dl
    intleak1,lim,mim,leakrp,leakrm,l1,dl1,doodd,qr,qi
    leakrr1(*,il,0:l1,l1)=qr
    leakri1(*,il,0:l1,l1)=qi
  end
end 

writefits,'leakr1.$segment.fits',leakrr1
writefits,'leaki1.$segment.fits',leakri1

END

EOF

if (-es leakrlist.$segment.fits && -es leakilist.$segment.fits && -es leakr1.$segment.fits && -es leaki1.$segment.fits) then
  rm parms.tmp
  echo successful completion
  exit 0
else
  exit 1
endif

Karen Tian
Powered by
ViewCVS 0.9.4