from rsf.proj import *
Fetch('bay.h','bay')
Flow('bay','bay.h',
'''
dd form=native |
window f2=500 n2=1500
''')
def plot(title):
return '''
grey allpos=y title="%s" yreverse=n
label1=South-North label2=West-East
screenratio=0.8
''' % title
Result('bay',plot('Digital Elevation Map'))
run = Program('run.c')
w = 30
Flow('ave','bay %s' % run[0],
'./${SOURCES[1]} w1=%d w2=%d how=fast' % (w,w))
Result('ave',plot('Signal'))
Flow('res','bay ave','add scale=1,-1 ${SOURCES[1]}')
Result('res',plot('Noise') + ' allpos=n')
import sys
if sys.platform=='darwin':
gtime = WhereIs('gtime')
if not gtime:
print("For computing CPU time, install gtime.")
else:
gtime = WhereIs('gtime') or WhereIs('time')
for case in ('fast','slow'):
ts = []
ws = []
time = 'time-' + case
wind = 'wind-' + case
for w in range(3,16,2):
itime = '%s-%d' % (time,w)
ts.append(itime)
iwind = '%s-%d' % (wind,w)
ws.append(iwind)
Flow(iwind,None,'spike n1=1 mag=%d' % (w*w))
Flow(itime,'bay %s' % run[0],
'''
( (%s -f "%%S %%U"
./${SOURCES[1]} < ${SOURCES[0]}
w1=%d w2=%d how=%s > /dev/null ) 2>&1 )
> time.out &&
(tail -1 time.out;
echo in=time0.asc n1=2 data_format=ascii_float)
> time0.asc &&
dd form=native < time0.asc | stack axis=1 norm=n
> $TARGET &&
/bin/rm time0.asc time.out
''' % (gtime,w,w,case),stdin=0,stdout=-1)
Flow(time,ts,'cat axis=1 ${SOURCES[1:%d]}' % len(ts))
Flow(wind,ws,'cat axis=1 ${SOURCES[1:%d]}' % len(ws))
Flow('c'+time,[wind,time],
'''
cat axis=2 ${SOURCES[1]} |
transp |
dd type=complex
''')
Plot('time','ctime-fast ctime-slow',
'''
cat axis=1 ${SOURCES[1]} | transp |
graph dash=0,1 wanttitle=n
label2="CPU Time" unit2=s
label1="Window Size" unit1=
''',view=1)
End() |