up [pdf]
from rsf.proj import *

# Generate synthetic data
Flow('step',None,
     '''
     spike nsp=3 n1=101 k1=26,51,76 mag=-1,2,-1 d1=1 label1= unit1= |
     causint |
     noise seed=62009 var=0.001
     ''')
Result('step','dots')

# Conventional smoothing
Flow('smooth','step','smooth rect1=10')
Result('smooth','dots')

# Spray by repeating the input
Flow('spray','step','spray axis=2 d=1 o=-10 n=21')
Result('spray','dots')

# Shift each trace
Flow('shift','spray','window n1=1 | math output=x1')
Flow('local','spray shift',
     'datstretch datum=${SOURCES[1]}')
Result('local','dots')

# Triangle weight
# --- CHANGE BELOW ---
Flow('triangle','local','math output="1-abs(x2)/10" ')
Flow('tnorm','triangle','stack')
Result('triangle','dots gaineach=n title="Triangle Weight" ')

# Triangle smoothing by weighting and stacking
Flow('smooth2','local triangle tnorm',
     '''
     add mode=p ${SOURCES[1]} |
     stack |
     add mode=d ${SOURCES[2]}
     ''')
Result('smooth2','dots title="Triangle Smoothing 2" ')

# Nonlocal weight
Flow('similarity','spray local triangle',
     'math loc=${SOURCES[1]} tri=${SOURCES[2]} output="tri*exp(-10*(input-loc)^2)"')
Result('similarity','dots gaineach=n title="Similarity Weight" ')

# Multiply two weights together
Flow('nlnorm','similarity','stack')
Flow('nlsmooth','local similarity nlnorm',
     '''
     add mode=p ${SOURCES[1]} |
     stack |
     add mode=d ${SOURCES[2]}
     ''')
Result('nlsmooth','dots')

End()

sfspike
sfcausint
sfnoise
sfdots
sfsmooth
sfspray
sfwindow
sfmath
sfdatstretch
sfstack
sfadd