up [pdf]
from rsf.proj import *

# fetch model
Fetch('marmsmooth.HH',"marm")

Flow('marmsmooth','marmsmooth.HH',
     '''
     dd form=native | 
     scale rscale=.001 | put
     label1=Depth label2=Position unit1=km unit2=km
     d1=0.024 d2=0.024
     ''')

Plot('marmsmooth',
     '''
     window $SOURCE  | 
     grey color=j gainpanel=a allpos=y scalebar=y 
     title=''Smoothed\ Marmousi\ Model'' barlabel="Velocity" barunit=km\/s
     barreverse=y screenht=6.5 screenratio=0.45 labelsz=6 titlesz=8 labelfat=3 titlefat=3
     ''')

# ray tracing
Flow('rays','marmsmooth',
     '''
     rays2 zshot=0. yshot=0. xshot=0. nr=20 a0=120 amax=165 dt=0.001 nt=5000
     ''')

Plot('rays',
     '''
     graph transp=y yreverse=y wanttitle=n wantaxis=n
     min1=0. max1=2.904 min2=0. max2=9.192 scalebar=y
     plotfat=5 plotcol=7 screenht=6.5 screenratio=0.45
     ''')

Result('marmsmooth','marmsmooth rays','Overlay')

# causal
Flow('dsr0 fdsr0 adsr0','marmsmooth',
     'dsreiko flag=${TARGETS[1]} alpha=${TARGETS[2]}')

# non-causal
Flow('dsr1 fdsr1 adsr1','marmsmooth',
     'dsreiko flag=${TARGETS[1]} alpha=${TARGETS[2]} causal=n')

# check accuracy
curve = []

for n in (0,31,62):
    curve.append('check_'+str(n))

    Flow('eiko_'+str(n),'marmsmooth',
         'eikonal zshot=%g yshot=0. xshot=0. | window n1=1 f1=%d' % (n*0.024,n))
    Flow('dsr0_'+str(n),'dsr0','window n3=1 | window n1=1 f1=%d' % n)
    Flow('dsr1_'+str(n),'dsr1','window n3=1 | window n1=1 f1=%d' % n)

    Plot('check_'+str(n),['eiko_'+str(n),'dsr0_'+str(n),'dsr1_'+str(n)],
         '''
         cat axis=2 ${SOURCES[1]} ${SOURCES[2]} |
         graph dash=0,1,1 label1=Position unit1=km 
         label2=Traveltime unit2=s labelsz=6 titlesz=8 labelfat=3 titlefat=3
         wanttitle=n plotcol=7,4,2 plotfat=4 min2=-0.1 max2=4
         screenht=6.5 screenratio=0.45 
         ''')

Result('causal',curve,'Overlay')

End()

sfdd
sfscale
sfput
sfwindow
sfgrey
sfrays2
sfgraph
sfdsreiko
sfeikonal
sfcat

data/marm/marmsmooth.HH