up [pdf]
from rsf.proj import *

Flow('prim',None,'spike n1=100 n2=50 o1=0.0 d1=0.004 o2=0.0 d2=0.02 k1=12')
Flow('hyper','prim','window n1=1 | math output="0.052+sqrt(0.048^2+x1*x1/16)" ')
Flow('mult','prim hyper','datstretch inv=y datum=${SOURCES[1]}')
Flow('cmp','prim mult','add ${SOURCES[1]}')
Plot('cmp','grey labelsz=12 titlesz=12 title="CMP (after NMO)" ')

# randomization
Flow('off','cmp','window n1=1 | noise rep=y seed=2015')
Flow('rand','cmp off','headersort head=${SOURCES[1]}')
Plot('rand','grey labelsz=12 titlesz=12 title="CMP (after randomization)" ')

Result('syn-in','cmp rand','SideBySideAniso')

Flow('cmp3','cmp','spray axis=3 n=50 o=0 d=1 label=Sample')
Flow('off3','cmp3','window n1=1 | noise rep=y seed=2015')
Flow('rand3','cmp3 off3','headersort head=${SOURCES[1]}')
Result('syn-cube','rand3',
       '''
       byte |
       grey3 frame1=50 frame2=30 frame3=30 flat=n title="3-D cube"
       ''')

# Add random noise
Flow('ncmp','cmp','noise seed=2015 var=0.001')
Flow('nrand','ncmp off','headersort head=${SOURCES[1]}')

#Flow('pef lag','nrand','lopef a=3,7 w=10,50 lag=${TARGETS[1]}') 
#Flow('tx','nrand pef','decon filt=${SOURCES[1]} predictive=y')

Flow('tx','nrand','transp | mf nfw=5 | transp')

# Sort back
Flow('inv','off','math output=x1 | spray axis=1 n=1 | headersort head=$SOURCE')
Flow('back','tx inv','headersort head=${SOURCES[1]}')

Flow('dif','ncmp back','add scale=1,-1 ${SOURCES[1]}')

title = dict(ncmp='Input CMP',back='CMP (2-D)',dif='Difference (2-D)')
for case in title.keys():
    Plot(case,'grey clip=1 labelsz=12 titlesz=12 title="%s" ' % title[case])
Result('syn-tx','ncmp back dif','SideBySideAniso')

End()

sfspike
sfwindow
sfmath
sfdatstretch
sfadd
sfgrey
sfnoise
sfheadersort
sfspray
sfbyte
sfgrey3
sftransp
sfmf