up [pdf]
from rsf.proj import *

def Grey(data,name):
    Result(data,
           '''
           grey title=" %s " 
           title=" "
           '''%name)

def Color(data,name):
    Result(data,
           '''
           grey color=j   title=""
           scalebar=y title=" %s "
           '''%name)

##############
# Noise data
##############
rect1=5

Flow('noise',None,
     '''
     sigmoid d1=.004 n1=200 d2=.008 n2=200  taper=no |
     smooth rect1=3 diff1=1 | smooth rect1=3 |
     noise seed=2011 var=4.e-7 
     ''')
#########################################
# Dip estimation based on Riesz transform
#########################################

Flow('nriesz','noise','bandpass fhi=60 |riesz order=10')
Flow('nrt','nriesz','window n3=1')
Flow('nrx','nriesz','window f3=1 | scale dscale=-1')

re=5
Flow('rizdip','nrx nrt','divn den=${SOURCES[1]} rect1=%d rect2=%d'%(re,re))
Color('rizdip','Riesz transform Dip')

#############################
# Dip estimation based on PWD
#############################
ns0=5 # smoothing radius

Flow('sdip','noise','bandpass fhi=60 | dip rect1=%d rect2=%d' % (ns0,ns0))
Color('sdip','PWD Dip')

###########################
# Dip-oriented filters
###########################
#### riesz-based dip-oriented lpf filter

Flow('elpf','noise rizdip',
     'lpfdenoise2 dip=${SOURCES[1]} nw=9 nfw=5 rect=50 verb=y niter=100')
Grey('elpf','riesz lpf')

Flow('delpf','noise elpf','add scale=1,-1 ${SOURCES[1]}')
Grey('delpf','diff riesz lpf')


#### PWD-based dip-oriented lpf filter

Flow('pwdelpf','noise sdip',
     'lpfdenoise2 dip=${SOURCES[1]} nw=9 nfw=5 rect=50 verb=y niter=100')
Grey('pwdelpf','pwd lpf')

Flow('depwdelpf','noise pwdelpf','add scale=1,-1 ${SOURCES[1]}')
Grey('depwdelpf','diff pwd lpf')

#### PWD-based dip-oriented median filter

Flow('median','noise sdip','domf dip=${SOURCES[1]} nw=5 stack=n verb=y')
Grey('median','pwd median')

Flow('dmedian','noise median','add scale=1,-1 ${SOURCES[1]}')
Grey('dmedian','pwd dmedian')

End()

sfsigmoid
sfsmooth
sfnoise
sfbandpass
sfriesz
sfwindow
sfscale
sfdivn
sfgrey
sfdip
sflpfdenoise2
sfadd
sfdomf