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

def Grey(data,other):
        Result(data,'window f2=560 n2=180 | put o2=0| real | grey clip=0.7 label2=Trace color=d unit2="" label1=Time unit1="s" title="" wherexlabel=t scalebar=n   %s'%other)

def Grey1(data,other):
        Result(data,'window f2=560 n2=180 | put o2=0 | math output="abs(input)" | real | grey label2=Trace unit2="" label1=Time unit1="s" wherexlabel=t allpos=y color=j title= scalebar=y unit2= %s'%other)


def Grey2(data,other):
        Result(data,'window f2=560 n2=180 |put o2=0 | grey clip=0.7 label2=Trace color=d unit2="" label1=Time unit1="s" title="" wherexlabel=t scalebar=n   %s'%other)

def Grey3(data,other):
        Result(data,'put o2=0 | grey clip=0.7 label2=Trace color=d unit2="" label1=Time unit1="s" title="" wherexlabel=t scalebar=n   %s'%other)

def Greyzoom(data,other):
        Result(data,'put d1=0.002 d2=1 o1=1.5 o2=0 | grey minval=-0.3 maxval=0.3 clip=0.3 label2=Trace color=g unit2="" label1=Time unit1="s" title="" wherexlabel=t scalebar=n  %s'%other)

Flow('data','../freeusp/stack.bin',' echo in=$SOURCE n1=751 n2=1285 data_format=native_float | put n1=751 n2=1285 d1=0.004 d2=1 o1=0 o2=0 | scale axis=2' )

#Plot('data','grey clip=0.9 title="Input Data"')
Grey2('data','title="Input data"')

########################################################################
# INITIALIZATION
########################################################################
Flow('data1','data','window f2=560 n2=180')

n1=751
n2=180

matlab         = WhereIs('matlab')
matROOT = '../matfun'
matfun = 'Freeusp'
matlabpath = os.environ.get('MATLABPATH',os.path.join(RSFROOT,'lib'))

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

############################################################
## generate and process synthetic data
############################################################
Flow('imf1 imf2 imf3 imf4',[os.path.join(matROOT,matfun+'.m'),'data1'],
     '''MATLABPATH=%(matlabpath)s %(matlab)s 
     -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${SOURCES[1]}',%(n1)d,%(n2)d,'${TARGETS[0]}','${TARGETS[1]}','${TARGETS[2]}','${TARGETS[3]}');quit"
     '''%vars(),stdin=0,stdout=-1)

Grey3('imf1','title="Component 1"')
Grey3('imf2','title="Component 2"')
Grey3('imf3','title="Component 3"')
Grey3('imf4','title="Component 4"')








End()

sfput
sfscale
sfwindow
sfgrey