up [pdf]
from rsf.proj import *

# compile program
prog = Program('traveltime.c')
exe = str(prog[0])

# v-of-z model
Flow('vofz',None,
     '''
     math n1=501 d1=0.004 o1=0 output="1.5+x1"
     label1=Time unit1=s | clip clip=2.5
     ''')

Result('vofz',
       '''
       graph yreverse=y transp=y pad=n plotfat=5
       title="Interval Velocity" wheretitle=b wherexlabel=t
       label2=Velocity unit2=km/s min2=1.25 max2=2.75
       screenratio=2 labelsz=5 titlesz=7
       ''')

# reflector file 
Flow('refl',None,'math n1=3 d1=125 o1=125 output=x1 | dd type=int')

# compute traveltime
for case in 'ae':
    Flow('time_'+case,['vofz',exe],
         '''
         ./${SOURCES[1]} nr=3 r=125,250,375
         nh=501 dh=0.01 h0=0 type=%c
         ''' % case)

# compute error
Flow('error','time_a time_e','add scale=1,-1 ${SOURCES[1]}')

# plot
for n in range(3):
    if n==0:
        Plot('curve_'+str(n),'error',
             '''
             window n2=1 f2=%d |
             graph yreverse=y plotfat=3 plotcol=%d
             min2=-0.11 max2=0.001
             title=Comparison label2=Error unit2=s
             labelsz=5 titlesz=7
             ''' % (n,7-n))

    else:
        Plot('curve_'+str(n),'error',
             '''
             window n2=1 f2=%d |
             graph yreverse=y plotfat=3 plotcol=%d
             min2=-0.11 max2=0.001 wantaxis=n wanttitle=n
             ''' % (n,7-n))

Result('curve','curve_0 curve_1 curve_2','Overlay')

End()

sfmath
sfclip
sfgraph
sfdd
sfadd
sfwindow