up [pdf]
from rsf.proj import*
from rsf.prog import RSFROOT

def Grey1(data,other):
        Result(data,
          '''
       grey clip=0.2 wanttitle=n label2=Trace unit2= label1=Time unit1=s
       labelfat=4 font=2 labelsz=10 titlefat=4 color=g screenratio=1.3 %s 
       '''%other)

def Grey2(data,other):
        Result(data,
          '''
       put d1=0.002 o1=0 d2=1 o2=0 | grey clip=0.2 wanttitle=y title= label2=Trace unit2= label1=Time unit1=s wheretitle=t wherexlabel=b 
       labelfat=4 font=2 labelsz=10 titlefat=4 color=g screenratio=1.3 %s 
       '''%other)

def Greydip(data,other):
        Result(data,
          '''
       put d1=0.002 o1=0 d2=1 o2=0 | grey clip=0.5 wanttitle=n label2=Trace unit2=
       labelfat=4 font=2 labelsz=10 titlefat=4 color=j %s 
       '''%other)

# multi-step
########################################################################
# INITIALIZATION
#######################################################################
matlab         = WhereIs('matlab')
matROOT = '../matfun'
matfun = 'hyper'

matlabpath = os.environ.get('MATLABPATH',os.path.join(RSFROOT,'lib'))

if not matlab:
    sys.stderr.write('\nCannot find Matlab.\n')
    sys.exit(1)

nt=501
nx=76
dt=0.002
lf=1
hf=250
twin=100
xwin=20
r=1
M=4
N2=10
N3=10
N22=2
N33=2
############################################################
## generate and process synthetic data
############################################################
Flow('hyper-c hyper-t hypers',[os.path.join(matROOT,matfun+'.m')],
     '''MATLABPATH=%(matlabpath)s %(matlab)s 
     -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${TARGETS[0]}','${TARGETS[1]}','${TARGETS[2]}');quit"
     '''%vars(),stdin=0,stdout=-1)
Flow('hyper','hyper-t','put n2=76 n3=1 o3=0 d1=0.004 d2=1')
Flow('hypers3','hypers','put n2=76 n3=3 o3=0 d1=0.004 d2=1')




matcykROOT='../matfun'
############################################################
## Curvelet thresholding
############################################################
matfun='Curvelet'
perc=10
n1=501
n2=76
# Flow('hyper-e-0',[os.path.join(matcykROOT,matfun+'.m'),'hyper'],
#      '''MATLABPATH=%(matlabpath)s %(matlab)s 
#      -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}','${TARGETS[0]}',%(n1)d,%(n2)d,%(perc)g);quit"
#      '''%vars(),stdin=0,stdout=-1)


Flow('sep1','hypers3','window n3=1 f3=1 | stack norm=n axis=3 ')
Flow('sep2','hypers3','window n3=1 f3=2 | stack norm=n axis=3')


Grey2('sep1','')
Grey2('sep2','')

Flow('hyper-dip','hyper','threshold1 thr=5|dip rect1=5 rect2=5 | pad n2=128')
Flow('sep1-dip','sep1','threshold1 thr=3 | dip rect1=5 rect2=5 | pad n2=128')
Flow('sep2-dip','sep2','threshold1 thr=3 | dip rect1=5 rect2=5 | pad n2=128')
Greydip('hyper-dip','')
Greydip('sep1-dip','')
Greydip('sep2-dip','')


Flow('hyper-seis','hyper hyper-dip','pad n2=128 | seislet adj=y inv=y dip=${SOURCES[1]} eps=0.1 type=b')
Flow('sep1-seis','sep1 sep1-dip','pad n2=128 | seislet adj=y inv=y dip=${SOURCES[1]} eps=0.1 type=b')
Flow('sep2-seis','sep2 sep2-dip','pad n2=128 | seislet adj=y inv=y dip=${SOURCES[1]} eps=0.1 type=b')
Result('hyper-seis','put d1=0.004 o1=0 d2=1 o2=0 |grey label1=Time unit1=s label2=Trace unit2= wanttitle=n ')
Result('sep1-seis','put d1=0.004 o1=0 d2=1 o2=0 |grey label1=Time unit1=s label2=Trace unit2= wanttitle=n ')
Result('sep2-seis','put d1=0.004 o1=0 d2=1 o2=0 |grey label1=Time unit1=s label2=Trace unit2= wanttitle=n ')

Flow('hyper-thr','hyper-seis','threshold1 thr=10')
Flow('sep1-thr','sep1-seis','threshold1 thr=10')
Flow('sep2-thr','sep2-seis','threshold1 thr=10')

Flow('hyper-recon','hyper-thr hyper-dip','seislet adj=n inv=y dip=${SOURCES[1]} eps=0.1 type=b | window n2=76')
Flow('sep1-recon','sep1-thr sep1-dip','seislet adj=n inv=y dip=${SOURCES[1]} eps=0.1 type=b| window n2=76')
Flow('sep2-recon','sep2-thr sep2-dip','seislet adj=n inv=y dip=${SOURCES[1]} eps=0.1 type=b| window n2=76')

Grey2('hyper-recon','')
Grey2('sep1-recon','')
Grey2('sep2-recon','')


Flow('hyper-e-0','sep1-recon sep2-recon','add scale=1,1 ${SOURCES[1]}')
Flow('hyper-e-n-0','hyper hyper-e-0','add scale=1,-1 ${SOURCES[1]}')
Flow('hyper-e-n hyper-e','hyper-e-n-0 hyper-e-0','ortho rect1=20 rect2=20 sig=${SOURCES[1]} sig2=${TARGETS[1]}')

Grey2('hyper-c','')
Grey2('hyper-c','')
Grey2('hyper','')

Grey2('hyper-e-0','')
Grey2('hyper-e-n-0','')
Grey2('hyper-e','')
Grey2('hyper-e-n','')

# perc=18
# n1=501
# n2=76
# Flow('hyper-s',[os.path.join(matcykROOT,matfun+'.m'),'hyper'],
#      '''MATLABPATH=%(matlabpath)s %(matlab)s 
#      -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}','${TARGETS[0]}',%(n1)d,%(n2)d,%(perc)g);quit"
#      '''%vars(),stdin=0,stdout=-1)

Flow('hyper-s-n','hyper hyper-s','add scale=1,-1 ${SOURCES[1]}')
Flow('hyper-s-n-0 hyper-s-0','hyper-s-n hyper-s','ortho rect1=30 rect2=20 sig=${SOURCES[1]} sig2=${TARGETS[1]}')

Flow('hyper-s','hyper-recon','cp')
Grey2('hyper-s','')
Grey2('hyper-s-n','')
Grey2('hyper-s-0','')
Grey2('hyper-s-n-0','')

perc=8
n1=501
n2=76
Flow('hyper-ct',[os.path.join(matcykROOT,matfun+'.m'),'hyper'],
     '''MATLABPATH=%(matlabpath)s %(matlab)s 
     -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}','${TARGETS[0]}',%(n1)d,%(n2)d,%(perc)g);quit"
     '''%vars(),stdin=0,stdout=-1)
Flow('hyper-ct-n','hyper hyper-ct','add scale=1,-1 ${SOURCES[1]}')
Flow('hyper-ct-n-0 hyper-ct-0','hyper-ct-n hyper-ct','ortho rect1=30 rect2=30 sig=${SOURCES[1]} sig2=${TARGETS[1]}')
Grey2('hyper-ct','')
Grey2('hyper-ct-n','')
Grey2('hyper-ct-0','')
Grey2('hyper-ct-n-0','')

Flow('hyper-fx','hyper','put d1=0.002 o1=0 d2=1 o2=0 | fxdecon n2w=30 lenf=4')
Flow('hyper-fx-n','hyper hyper-fx','add scale=1,-1 ${SOURCES[1]}')
Flow('hyper-fx-n-0 hyper-fx-0','hyper-fx-n hyper-fx','ortho rect1=30 rect2=30 sig=${SOURCES[1]} sig2=${TARGETS[1]}')
Grey2('hyper-fx','')
Grey2('hyper-fx-n','')
Grey2('hyper-fx-0','')
Grey2('hyper-fx-n-0','')

End()

sfput
sfwindow
sfstack
sfgrey
sfthreshold1
sfdip
sfpad
sfseislet
sfadd
sfortho
sfcp
sffxdecon