up [pdf]
from rsf.proj import *
import math
import os

Flow('clean2',None,'math n1=50 o1=1 d1=1 output="sqrt(4+0.000025*x1*x1)"')

# sin
Flow('sin2',None,
     'math n1=100  d1=1 output="2.5+0.00125*(1+sin(-%g*x1))"'%(math.pi*0.02))
Flow('sin11','sin2','window n1=50 f1=26')
# cat
Flow('signal','clean2 sin11','cat ${SOURCES[1:2]} axis=1 | smooth rect1=5 ')
Flow('snoisy','signal','noise var=0.01 seed=2007 | put n2=1')
Plot('snoisy',
     '''
     graph wanttitle=n dash=1 plotfat=3 plotcol=7
     font=2 crowd1=0.75 crowd2=0.25  min2=1.6 max2=2.8
     ''')

Flow('t0','snoisy','math output=1')
Flow('t1','snoisy','math output="%g*x1"'% (1/2900.3002))
Flow('t2','snoisy','math output="%g*x1*x1"'% (1/11400006.01))

Flow('t','t0 t1','cat axis=2 ${SOURCES[1]}')
Flow('tt','t t2','cat axis=2 ${SOURCES[1]}')

Flow('flt2 linefit','t snoisy',
     'lpf match=${SOURCES[1]} pred=${TARGETS[1]} rect1=5000')
Plot('linefit',
     '''
     graph wanttitle=n wantaxis=n plotfat=3 plotcol=7
     dash=5 min2=1.6 max2=2.8  font=2    crowd1=0.75 crowd2=0.25
     ''')
Flow('flt3 lpf','tt  snoisy',
     'lpf match=${SOURCES[1]} pred=${TARGETS[1]} rect1=8')

Plot('lpf',
     '''
     graph title=""  plotfat=3 min2=1.6  plotcol=7 
     label1="\F2 X" label2="\F2 Y"
     max2=2.8  font=2
     crowd1=0.75 crowd2=0.25
     ''')
Result('compare','snoisy lpf linefit ','Overlay')

End()

sfmath
sfwindow
sfcat
sfsmooth
sfnoise
sfput
sfgraph
sflpf