from rsf.proj import *
from rsf.prog import RSFROOT
from rsf.recipes.beg import server
from math import *
def Grey(data,other):
Result(data,'grey label2=Trace unit2="" unit1= label1="Time sampling number" title="" labelsz=10 labelfat=4 font=2 titlesz=10 titlefat=4 screenht=10.24 screenratio=0.75 screenwd=13.65 wherexlabel=b wheretitle=t color=b bartype=v clip=0.1 %s'%other)
Fetch('real.rsf','dsd',server)
Grey('real','title="Noisy"')
n1=512
n2=512
padn2=512
lambda1=0.5
niter=30
lvl=2
htype='spline'
thr=0.01
thr1=20
thr2=5
thr3=10
lenf=6
thrtype='g'
Flow('dip','real','dip rect1=30 rect2=20 | pad n2=%d'%padn2)
Flow('real-slet','real dip','pad n2=%d | seislet dip=${SOURCES[1]} adj=y inv=y eps=0.1 type=b'%padn2)
Flow('real-sletthr','real-slet','threshold1 thr=%g'%thr1)
Flow('real-re','real-sletthr dip','seislet dip=${SOURCES[1]} adj=n inv=y eps=0.1 type=b | window n2=%d'%n2 )
Flow('real-dif','real real-re','add scale=1,-1 ${SOURCES[1]}')
matlab = WhereIs('matlab')
matROOT = '../Matfun'
matfun = 'Syn_ddtf'
matlabpath = os.environ.get('MATLABPATH',os.path.join(RSFROOT,'lib'))
if not matlab:
sys.stderr.write('\nCannot find Matlab.\n')
sys.exit(1)
Flow('real-sletddtfthr',[os.path.join(matROOT,matfun+'.m'),'real-slet'],
'''MATLABPATH=%(matlabpath)s %(matlab)s
-nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}','${TARGETS[0]}',%(n1)d,%(padn2)d,%(lambda1)g,%(niter)d,%(lvl)d,'%(htype)s',%(thr2)g,'%(thrtype)s');quit"
'''%vars(),stdin=0,stdout=-1)
Flow('real-sletddtfthr0','real-sletddtfthr','put d2=1 d1=1 o1=0 o2=0 ')
Flow('real-sletddtf-re','real-sletddtfthr dip','put d2=1 d1=1 o1=0 o2=0 | seislet dip=${SOURCES[1]} adj=n inv=y eps=0.1 type=b | window n2=%d'%n2 )
Flow('real-sletddtf-dif','real real-sletddtf-re','add scale=1,-1 ${SOURCES[1]}')
Flow('real-ddtf-t',[os.path.join(matROOT,matfun+'.m'),'real'],
'''MATLABPATH=%(matlabpath)s %(matlab)s
-nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}','${TARGETS[0]}',%(n1)d,%(n2)d,%(lambda1)g,%(niter)d,%(lvl)d,'%(htype)s',%(thr3)g,'%(thrtype)s');quit"
'''%vars(),stdin=0,stdout=-1)
Flow('real-ddtf-t0','real-ddtf-t','put d2=1 d1=1 o1=0 o2=0 ')
Flow('real-ddtf-dif','real real-ddtf-t0','add scale=1,-1 ${SOURCES[1]}')
n2w=50
Flow('real-fx0','real','put d1=0.004 | fxdecon n2w=%d lenf=%d taper=0.5| put d1=1'%(50,lenf))
Flow('real-fx-dif0','real real-fx0','add scale=1,-1 ${SOURCES[1]}')
Grey('dip','color=j')
Grey('real-slet','clip=0.1')
Grey('real-sletthr','clip=0.1')
Grey('real-sletddtfthr0','clip=0.1')
Flow('real-zero','real','math output=0')
Grey('real-zero','clip=0.1 title="Zero"')
Grey('real-re','clip=0.1 title="Seislet"')
Grey('real-dif','clip=0.1 title=Seislet')
Grey('real-sletddtf-re','clip=0.1 title=DSD')
Grey('real-sletddtf-dif','clip=0.1 title=DSD')
Grey('real-ddtf-t0','clip=0.1 title=DDTF')
Grey('real-ddtf-dif','clip=0.1 title=DDTF')
Grey('real-fx0','clip=0.1 title=FX')
Grey('real-fx-dif0','clip=0.1 title=FX')
End() |