up [pdf]
from rsf.proj import *

yshot=4
yshot2=4.2
yshot3=4.4
zshot=0.0
dl=0.2
dll=-0.2

contour = '''
contour c0=0. nc=100 wanttitle=n
label1=Depth label2=Lateral screenratio=.327 screenht=4.7 wantaxis=n  labelsz=12
'''
grey = '''
grey wanttitle=n polarity=n
label1=Depth label2=Lateral screenratio=.327 screenht=4.7 wantaxis=y  labelsz=12
'''

grey2 = '''
grey wanttitle=n
label1=Depth label2=Lateral screenratio=.327 screenht=4.3 wantaxis=y  labelsz=12
clip=0.01 maxval=0.01 minval=0 barreverse=n scalebar=y barlabel="Time (s)"
'''

# Fetch Files from repository
raw=['marmvel.hh','marmsmooth.HH']
for file in raw:
    Fetch(file,"marm")
    if file is 'marmvel.hh':
        d=.004
        fileOut='marm'
        t='Velocity\ Model'
    if file is 'marmsmooth.HH':
        d=.024
        fileOut='marms'
        t='Smoothed\ Velocity\ Model'
# Convert Files to RSF and update headers
    Flow(fileOut,file,'''dd form=native | 
        scale rscale=.001 | put
        label1=Depth label2=Position unit1=km unit2=km
        d1=%f d2=%f''' % (d,d))

Flow('marm1','marm','window min2=1 max2=7 max1=2.904 j1=6 j2=6')
Flow('marm2','marm','window min2=1.2 max2=7.2 max1=2.904 j1=6 j2=6')
Flow('marm3','marm','window min2=1.4 max2=7.4 max1=2.904 j1=6 j2=6')
Plot('marm1','grey allpos=y screenratio=.327 screenht=4.7 wanttitle=n')
Plot('marm2','grey allpos=y screenratio=.327 screenht=4.7 wanttitle=n')
Plot('marm3','grey allpos=y screenratio=.327 screenht=4.7 wanttitle=n')
Flow('marms1','marms','window min2=1 max2=7')
Plot('marms1','grey allpos=y screenratio=.327 screenht=4.7 wanttitle=n')
Result('medium','marm1 marms1','SideBySideIso')


Flow('eiko1','marm1',
         '''
         eikonal order=%d zshot=%g yshot=%g br1=0.024 br2=0.024
         ''' % (2,zshot,yshot))

Flow('eiko2','marm2',
         '''
         eikonal order=%d zshot=%g yshot=%g br1=0.024 br2=0.024
         ''' % (2,zshot,yshot2))

Flow('eiko3','marm3',
         '''
         eikonal order=%d zshot=%g yshot=%g br1=0.024 br2=0.024
         ''' % (2,zshot,yshot3))

Plot('eiko1','eiko1',
         '''
         %s dash=3 wantaxis=n
         ''' % (contour))

Plot('eiko2','eiko2',
         '''
         %s dash=3 wantaxis=n
         ''' % (contour))

Flow('eikavgg','eiko1 eiko3','math x=${SOURCES[1]} output="(input+x)/2" ')

Plot('constl',['marm2','eikavgg'],'Overlay')
Plot('diff','eikavgg','difference subtracter=%s | math output="abs(input)" | %s ' % ('eiko2.rsf',grey2))

for sorder in (1,2,3):
  eikods = 'eikods%d' % sorder
  eikodss = 'eikodss%d' % sorder
  eikodsv = 'eikodsv%d' % sorder
  eikavg = 'eikavg%d' % sorder
  const1 = 'const1%d' % sorder
  const2 = 'const2%d' % sorder
  const3 = 'const3%d' % sorder
  const4 = 'const4%d' % sorder
  const5 = 'const5%d' % sorder
  Flow(eikods,'marm1',
         '''
         eikds order=%d zshot=%g yshot=%g sorder=%d br1=0.024 br2=0.024 btime=n dl=%g
         ''' % (2,zshot,yshot,sorder,dl))

  Flow(eikodss,'marm3',
         '''
         eikds order=%d zshot=%g yshot=%g sorder=%d br1=0.024 br2=0.024 btime=n dl=%g
         ''' % (2,zshot,yshot3,sorder,dll))

  Flow(eikavg,[eikodss,eikods],'math x=${SOURCES[1]} output="(input+x)/2" ')

  Plot(eikodsv,eikods,
         '''
         %s dash=1 wantaxis=n
         ''' % (contour))

  Plot(const1,['marm1','eiko1',eikodsv],'Overlay')
  Plot(const2,['marm2','eiko2',eikodsv],'Overlay')
  Plot(const3,['eiko2',eikods],'difference subtracter=${SOURCES[1]} | math output="abs(input)" | %s ' % grey2)
  Plot(const4,eikodss,'difference subtracter=%s | math output="abs(input)" | %s ' % ('eiko2.rsf',grey2))
  Plot(const5,eikavg,'difference subtracter=%s | math output="abs(input)" | %s ' % ('eiko2.rsf',grey2))

Result('cir1','const21','SideBySideIso')
Result('cir2','const31','SideBySideIso')
Result('cir3','const23 const33','SideBySideIso')
Result('cir4','const31 const41','SideBySideIso')
Result('cir5','const31 diff','SideBySideIso')
End()

sfdd
sfscale
sfput
sfwindow
sfgrey
sfeikonal
sfcontour
sfmath
sfdifference
sfeikds

data/marm/marmvel.hh
data/marm/marmsmooth.HH