up [pdf]
import os
from rsfproj import *

### Set FTP server parameter
FTPserver = {
    'server': os.environ.get('SLIM_SERVER'),
    'login': os.environ.get('SLIM_LOGIN'),
    'password':os.environ.get('SLIM_PASSWORD')}

filesloc = os.path.join('users','dwang','Geophysics','Bayes','saga','results')

#--------Fetch files from FTP server---------
flist = '''
        saga_data.rsf       saga_srme.rsf
        saga_mult.rsf       saga_Bayes3D.rsf saga_Bayes3D_mult.rsf
   '''
#fetch data from FTP server
for fil in str.split(flist):
    Fetch(fil,filesloc,FTPserver)

# Define plot functions
def greym(title):
     return '''
     sfdd form=native |sfcut n1=60 |sfwindow n1=875|sfput d1=0.004 d2=25 o2=0| sfagc| 
     sfgrey xinch=6 yinch=8  clip=2.5 grid2=y g2num=1.0 parallel2=n
     label1="Time" unit1="s"  label2="Shot location" unit2="m"
     labelsz=6.0  titlesz=6.0 title="%s"
      ''' % (title)

def greym1(title):
     return '''
     sfdd form=native |sfcut n1=125 |sfwindow n1=875|sfput d1=0.004 d2=25 o2=0| sfagc| 
     sfgrey xinch=6 yinch=8  clip=2.5 grid2=y g2num=1.0 parallel2=n
     label1="Time" unit1="s"  label2="Shot location" unit2="m"
     labelsz=6.0  titlesz=6.0 title="%s"
      ''' % (title)


#-------Basic plot-------------------
Plot('F2a','saga_data.rsf',greym(''))
Plot('F2b','saga_mult.rsf',greym1(''))
Plot('F2c','saga_srme.rsf',greym(''))
Plot('F2d','saga_Bayes3D.rsf',greym(''))


#--------difference plot------------
Flow('diff-data-srme',['saga_data.rsf','saga_srme.rsf'], \
      ' sfmath  a=${SOURCES[1]} output="input-a"')

Flow('diff-data-bayes',['saga_data.rsf','saga_Bayes3D.rsf'], \
      ' sfmath  a=${SOURCES[1]} output="input-a"')

Flow('diff-srme-bayes',['saga_srme.rsf','saga_Bayes3D.rsf'], \
      ' sfmath  a=${SOURCES[1]} output="input-a"')

Flow('noise',['saga_data.rsf','saga_Bayes3D.rsf','saga_Bayes3D_mult.rsf'], \
      ' sfmath  a=${SOURCES[1]} b=${SOURCES[2]} output="input-(a+b)"')


Plot('diff-data-srme',greym1('diff-data-srme'))
Plot('diff-data-bayes',greym1('diff-data-bayes'))
Plot('diff-srme-bayes',greym1('diff-srme-bayes'))
Plot('bayes-mult','saga_Bayes3D_mult.rsf',greym1('bayes mult'))
Plot('noise',greym1('noise'))

#-------annotations-----------------    
labels = (
    (6.6,7.25,''),
    (7.0,3.0,'')
    )
nlabels = len(labels)
annot = []
for i in range(nlabels):
    annot.append('annot%d' % i)
    Plot(annot[i],None,
         '''
         box x0=%g y0=%g label="%s"
         xt=0.5 yt=0.4 lab_fat=0 
         boxit=1 size=0.2 pointer=1 x_oval=0.0 y_oval=0.0
         ''' % labels[i])

Plot('antNone',None,'box x0=6.85 y0=5.7 label="" xt=0.0 yt=0.0 lab_fat=0 boxit=1 \
       size=0.0 pointer=1 x_oval=0.0 y_oval=0.0')

#------Final result----------------
Result('Figure2-a',['F2a']+annot,'Overlay')
Result('Figure2-b',['F2b']+annot,'Overlay')
Result('Figure2-c',['F2c']+annot,'Overlay')
Result('Figure2-d',['F2d']+annot,'Overlay')


Result('Figure2-e',['diff-data-srme']+['antNone'],'Overlay')
Result('Figure2-f',['diff-data-bayes']+['antNone'],'Overlay')
Result('Figure2-g',['diff-srme-bayes']+['antNone'],'Overlay')
Result('Figure2-h',['bayes-mult']+['antNone'],'Overlay')
Result('Figure2-i',['noise']+['antNone'],'Overlay')


End()

sfdd
sfcut
sfwindow
sfput
sfagc
sfgrey
sfmath
sfbox