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

Flow('mod',None,
     '''
     sigmoid n1=200 d2=.008 n2=200 |
     smooth rect1=3 diff1=1 adj=1 |
     smooth rect1=3 |
     scale dscale=150
     ''')
Plot('mod','grey title="Ideal image" ')

Flow('dat','mod',
     '''
     pad n2=1025 | cosft sign2=1 |
     stolt pad=513 vel=-1.5 |
     cosft sign2=-1 | window n2=200
     ''')
Plot('dat','grey title="Input data" ')

Flow('t2','dat','t2stretch dens=2 | put label1="Time\^2\_" unit1="sec\^2\_" ')
Plot('t2','grey title="After t\^2\_ transform" ')

Result('t2','dat t2','SideBySideIso')

Flow('cheb','dat','t2chebstretch dens=2 | put label1= unit1= ')
Plot('cheb','grey title="Transformation to Chebyshev grid" ')

Result('cheb1','dat cheb','SideBySideIso')

Flow('t2-fft','t2','fft1 | fft3')
Plot('t2-fft','real | grey title="Data FFT Real Part" label1=Frequency')

Flow('oper','t2-fft','math output="exp(-I*x2*x2*%g/x1)" | cut n1=1' % (0.5*math.pi))
Plot('oper','real | grey title="Operator FFT Real Part" label1=Frequency')

Result('t2-fft','t2-fft oper','SideBySideIso')

Flow('cheb1','cheb','cosft sign1=1')
Plot('cheb1','put o1=0 d1=1 | grey title="Chebyshev transform" label1="Polynom number" unit1=')

Flow('cheb-fft','cheb1','cosft sign2=1')
Plot('cheb-fft',
     '''
     put o1=0 d1=1 |
     grey title="Chebyshev-Cosine FT" label1="Polynom number" label2=Wavenumber unit1=
     ''')

Result('cheb1-fft','cheb1 cheb-fft','SideBySideIso')

for case in ('','cheb'):
    for dens in (1,3):
        cod = '%scod%d' % (case,dens)
        Flow(cod,'dat','t2%sstretch dens=%d | t2%sstretch inv=y' % (case,dens,case))
        Plot(cod,'grey title="Reconstructed, grid=%d" clip=0.6' % (dens*200))
        dif = '%sdif%d' % (case,dens)
        Flow(dif,[cod,'dat'],'add scale=1,-1 ${SOURCES[1]}')
        Plot(dif,'grey title="Difference, grid=%d" clip=0.6' % (dens*200))

Result('fft-inv','cod1 dif1 cod3 dif3','TwoRows')
Result('cheb1-inv','chebcod1 chebdif1 chebcod3 chebdif3','TwoRows')

Flow('fft-mig','dat',
     '''
     pad n2=513 | cosft sign2=1 |
     spray  axis=2 n=1 o=0 d=1 | fourvc pad=400 pad2=512 nv=1 dv=1.5 v0=0.0001 | 
     cosft sign3=-1 | window n3=200
     ''')
Plot('fft-mig','grey title="Fourier result" ')

Flow('cheb-mig','dat',
     '''
     t2chebstretch nout=513 | pad n2=513 | cosft sign1=1 sign2=1 |
     chebvc vel=0.75 nv=500 |
     cosft sign2=-1 sign1=-1 | window n2=200 | t2chebstretch inv=1
     ''')
Plot('cheb-mig','grey title="Chebyshev result" ')

Result('mig-impl','mod dat fft-mig cheb-mig','TwoRows')

End()

sfsigmoid
sfsmooth
sfscale
sfgrey
sfpad
sfcosft
sfstolt
sfwindow
sft2stretch
sfput
sft2chebstretch
sffft1
sffft3
sfreal
sfmath
sfcut
sfadd
sfspray
sffourvc
sfchebvc