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

def Graph(data,other):
        Result(data,'graph label1="Rank" label2="SNR (dB)" unit2= unit1="s" labelsz=10 labelfat=4 font=2 titlesz=10 titlefat=4 title="" wherexlabel=b wheretitle=t plotfat=10 %s' %other)

def Graphplot(data,other):
        Plot(data,'graph label1="Rank" label2="SNR" unit2=dB labelsz=10 labelfat=4 font=2 titlesz=10 titlefat=4 title="" wherexlabel=b wheretitle=t plotfat=10 %s' %other)


########################################################################
# INITIALIZATION
########################################################################
matlab         = WhereIs('matlab')
matROOT = '../matfun'
matfun = 'SNRS_RANK'
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('synth_drr_ranks-0',[os.path.join(matROOT,matfun+'.m')],
    '''MATLABPATH=%(matlabpath)s %(matlab)s 
    -nosplash -nojvm -r "addpath %(matROOT)s;%(matfun)s('${TARGETS[0]}');quit"
    '''%vars(),stdin=0,stdout=-1)

Flow('rank','synth_drr_ranks-0','put n1=12 n2=3 d1=1 d2=1 o1=1 o2=1 | window n2=1')
Flow('snr1','synth_drr_ranks-0','put n1=12 n2=3 d1=1 d2=1 o1=1 o2=1 | window n2=1 f2=1')
Flow('snr2','synth_drr_ranks-0','put n1=12 n2=3 d1=1 d2=1 o1=1 o2=1 | window n2=1 f2=2')
Flow('snr3','synth_drr_ranks-0','put n1=12 n2=3 d1=1 d2=1 o1=1 o2=1 | window n2=1 f2=3')

Flow('snr1s','rank snr1','cmplx ${SOURCE} ${SOURCES[1]}')
Flow('snr2s','rank snr2','cmplx ${SOURCE} ${SOURCES[1]}')
Flow('snr3s','rank snr3','cmplx ${SOURCE} ${SOURCES[1]}')
Flow('snr1st','snr1s','cp')
Flow('snr2st','snr2s','cp')
Flow('snr3st','snr3s','cp')

Graphplot('snr1s','min2=3 max2=13 symbol="o" symbolsz=10 plotcol=3 ')
Graphplot('snr2s','min2=3 max2=13 symbol="v" symbolsz=10 plotcol=5 wantaxis=n')
Graphplot('snr3s','min2=3 max2=13 symbol="*" symbolsz=10 plotcol=6 wantaxis=n')

Graphplot('snr1st','min2=3 max2=13 plotcol=3 wantaxis=n')
Graphplot('snr2st','min2=3 max2=13 plotcol=5 wantaxis=n')
Graphplot('snr3st','min2=3 max2=13 plotcol=6 wantaxis=n')

Plot('label1',None,
        '''
        box x0=6.7 y0=3.5 label="RR" xt=-0.5 yt=-0.5 length=1 
        ''')
Plot('label2',None,
        '''
        box x0=8 y0=6.4 label="DRR" xt=0.5 yt=0.5 length=1 
        ''')
Plot('label3',None,
        '''
        box x0=5.5 y0=8.1 label="ORR" xt=0.5 yt=0.5 length=1 
        ''')

Result('snr-rank','snr1s snr2s snr3s snr1st snr2st snr3st label1 label2 label3','Overlay')


End()

sfput
sfwindow
sfcmplx
sfcp
sfgraph
sfbox