up [pdf]
from rsf.proj import *
import math
from math import *
import os

wf = 2*pi
nt = 501
dt = 0.004
ot = 0
nx = 501
dx = 0.01
ox = 0
ny = 501
dy = 0.01
oy = 0
nw = 200
dw = 0.0005
ow = 0



Flow('spike',None,
     '''
     spike n1=%d d1=%g o1=%g n2=%d d2=%g o2=%g n3=%d d3=%g o3=%g nsp=1 k1=250 mag=1  p2=0| 
     ricker1 frequency=20 | put unit2=km label2=Distance
     ''' % (nt,dt,ot,nx,dx,ox,ny,dy,oy))

Flow('tsin','spike','window n1=1 | math output="0.08*cos(3*sqrt((x1-2.5)^2+(x2-2.5)^2))"')
Result('tsin','tsin','math output="1+input" | grey scalebar=y wanttitle=n bias=1  label2=X unit2=km label1=Y unit1=km')

Flow('sin','spike tsin',
     'datstretch datum=${SOURCES[1]} | window min1=0.8 max1=1.2 j2=4 j3=4 j1=1 ')

Result('sin','sin',' byte clip=0.3| grey3 frame1=50 frame2=60 frame3=60 flat=n wanttitle=n label2=X unit2=km label3=Y unit3=km ')

Flow('cmp','sin',' noise var=1e-2 seed=2008 ')

Result('cmp','cmp',' byte clip=0.3| grey3 frame1=50 frame2=60 frame3=60 flat=n wanttitle=n label2=X unit2=km label3=Y unit3=km ')

Flow('fcmp','cmp','fft1 |  transp plane=13 memsize=1000  | transp plane=12 memsize=1000')

Flow('shifts','fcmp',
     '''
     cshifts2 ns1=2 ns2=2 | transp plane=34 memsize=300
     ''')

Flow('flt pre','shifts fcmp',
     'clpf match=${SOURCES[1]} pred=${TARGETS[1]} rect1=10 rect2=10 niter=30')


Flow('tpre','pre','transp plane=13 memsize=10000| transp plane=23 memsize=10000 | fft1 inv=y')


Result('tpre','tpre','put o1=0.8 |byte clip=0.3| grey3  frame1=50 frame2=60 frame3=60 flat=n wanttitle=n label2=X unit2=km label3=Y unit3=km')



Result('flt','flt',
       '''
       window n4=1 f4=15  |  imag | transp plane=13 memsize=1000| transp plane=23 memsize=1000 |  smooth rect1=5 |
       byte pclip=99 scalebar=y bar=bar.rsf| grey3 scalebar=y bar=bar.rsf color=j frame1=9 frame2=60 frame3=60 flat=n wanttitle=n label2=X unit2=km label3=Y unit3=km
       ''')

#################
## 2D RNA
################

Flow('shifts2d','fcmp','shiftd1 ns=3 |transp plane=25 | window squeeze=y')

Flow('flt2d pre2d','shifts2d fcmp',
     'clpf match=${SOURCES[1]} pred=${TARGETS[1]} rect1=5  niter=400')

Flow('tpre2d','pre2d','transp plane=13 memsize=1000| transp plane=23 memsize=1000 | fft1 inv=y')
Result('tpre2d','tpre2d','put o1=0.8 |byte clip=0.3| grey3  frame1=50 frame2=60 frame3=60 flat=n wanttitle=n label2=X unit2=km label3=Y unit3=km')






End()

sfspike
sfricker1
sfput
sfwindow
sfmath
sfgrey
sfdatstretch
sfbyte
sfgrey3
sfnoise
sffft1
sftransp
sfcshifts2
sfclpf
sfimag
sfsmooth
sfshiftd1