up [pdf]
from rsf.proj import*
from rsf.prog import RSFROOT
from rsf.recipes.beg import server as private

def Grey(data,other):
        Result(data,'put d1=0.004 d2=1 o1=0 o2=0        | grey grid=n poly=y transp=y yreverse=y  label2=Trace  unit2="" label1=Time unit1="s" title="" wherexlabel=t scalebar=n wheretitle=b screenht=9 screenratio=1 screenwd=9  %s'%other)

def Greyplot(data,other):
        Plot(data,'put d1=0.004 d2=1 o1=0 o2=0          | grey grid=n poly=y transp=y yreverse=y  label2=Trace  unit2="" label1=Time unit1="s" title="" wherexlabel=t wantaxis2=n label2= scalebar=n wheretitle=b screenht=11.5 screenratio=1 screenwd=9  %s'%other)

def Graph(data,other):
        Result(data,'transp | put d1=1 o1=0     | graph grid=n yreverse=n label2=Value  unit2="" min2=-3 max2=3 label1=Trace title="" wherexlabel=t scalebar=n wheretitle=b screenht=3 screenratio=0.25 screenwd=9  %s'%other)

def Graphplot(data,other):
        Plot(data,'transp | put d1=1 o1=0       | graph grid=n yreverse=n label2=Value  unit2="" min2=-3 max2=3 label1=Trace title="" wherexlabel=t scalebar=n wheretitle=b screenht=3 screenratio=0.25 screenwd=9  %s'%other)


########################################################################
# INITIALIZATION
########################################################################
matlab         = WhereIs('matlab')
matROOT = '../Matfun'
matfun = 'fxemddemoflat'
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('flat-clean flat-noise flat-noisy flat-denoised flat-noise1 flat-fclean flat-fnoise flat-fnoisy flat-fdenoised flat-fnoise1',[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]}','${TARGETS[3]}','${TARGETS[4]}','${TARGETS[5]}','${TARGETS[6]}','${TARGETS[7]}','${TARGETS[8]}','${TARGETS[9]}');quit"
     '''%vars(),stdin=0,stdout=-1)

Greyplot('flat-clean','color=g clip=0.62')
Greyplot('flat-noise','color=g clip=0.62')
Greyplot('flat-noisy','color=g clip=0.62')
Greyplot('flat-denoised','color=g clip=0.62')
Greyplot('flat-noise1','color=g clip=0.62')

Graphplot('flat-fclean','')
Graphplot('flat-fnoise','')
Graphplot('flat-fnoisy','')
Graphplot('flat-fdenoised','')
Graphplot('flat-fnoise1','')

Result('flat-clean','flat-fclean flat-clean','OverUnderIso')
Result('flat-noise','flat-fnoise flat-noise ','OverUnderIso')
Result('flat-noisy','flat-fnoisy flat-noisy ','OverUnderIso')
Result('flat-denoised','flat-fdenoised flat-denoised ','OverUnderIso')
Result('flat-noise1','flat-fnoise1 flat-noise1 ','OverUnderIso')


############################################################
## generate and process synthetic data
############################################################
matfun = 'fxemddemodip'
Flow('dip-clean dip-noise dip-noisy dip-denoised1 dip-noise1 dip-denoised2 dip-noise2 dip-denoised3 dip-noise3 dip-fclean dip-fnoise dip-fnoisy dip-fdenoised1 dip-fnoise1 dip-fdenoised2 dip-fnoise2 dip-fdenoised3 dip-fnoise3',[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]}','${TARGETS[3]}','${TARGETS[4]}','${TARGETS[5]}','${TARGETS[6]}','${TARGETS[7]}','${TARGETS[8]}','${TARGETS[9]}','${TARGETS[10]}','${TARGETS[11]}','${TARGETS[12]}','${TARGETS[13]}','${TARGETS[14]}','${TARGETS[15]}','${TARGETS[16]}','${TARGETS[17]}');quit"
     '''%vars(),stdin=0,stdout=-1)

Greyplot('dip-clean','color=g clip=0.45')
Greyplot('dip-noise','color=g clip=0.45')
Greyplot('dip-noisy','color=g clip=0.45')
Greyplot('dip-denoised1','color=g clip=0.45')
Greyplot('dip-noise1','color=g clip=0.45')
Greyplot('dip-denoised2','color=g clip=0.45')
Greyplot('dip-noise2','color=g clip=0.45')
Greyplot('dip-denoised3','color=g clip=0.45')
Greyplot('dip-noise3','color=g clip=0.45')

Graphplot('dip-fclean','')
Graphplot('dip-fnoise','')
Graphplot('dip-fnoisy','')
Graphplot('dip-fdenoised1','')
Graphplot('dip-fnoise1','')
Graphplot('dip-fdenoised2','')
Graphplot('dip-fnoise2','')
Graphplot('dip-fdenoised3','')
Graphplot('dip-fnoise3','')

Result('dip-clean','dip-fclean dip-clean','OverUnderIso')
Result('dip-noise','dip-fnoise dip-noise ','OverUnderIso')
Result('dip-noisy','dip-fnoisy dip-noisy ','OverUnderIso')
Result('dip-denoised1','dip-fdenoised1 dip-denoised1 ','OverUnderIso')
Result('dip-noise1','dip-fnoise1 dip-noise1 ','OverUnderIso')
Result('dip-denoised2','dip-fdenoised2 dip-denoised2 ','OverUnderIso')
Result('dip-noise2','dip-fnoise2 dip-noise2 ','OverUnderIso')
Result('dip-denoised3','dip-fdenoised3 dip-denoised3 ','OverUnderIso')
Result('dip-noise3','dip-fnoise3 dip-noise3 ','OverUnderIso')

End()

sfput
sfgrey
sftransp
sfgraph