from rsf.proj import *
from math import pi
pgrid = {'nx':150,
'ox':1.,
'dx':1.,
'nz':150,
'oz':1.,
'dz':10.
}
Flow('dfgrd',None,
'''
spike nsp=1 mag=1 n1=%(nx)d d1=%(dx)g o1=%(ox)g n2=%(nz)d d2=%(dz)g o2=%(oz)g |
put label1=f unit1=Hz label2=z unit2=m
''' % pgrid)
pgrids = {'M025':{'hu':-0.25, 'cu':1.311, 'shu':'\F15 8\F2 0.25'},
'025':{'hu':0.25, 'cu':0.5991, 'shu':'0.25'},
'05':{'hu':0.5, 'cu':1.0, 'shu':'0.5'},
'075':{'hu':0.75, 'cu':1.3317, 'shu':'0.75'},
'1':{'hu':1.0, 'cu':1.57, 'shu':'1.0'}
}
bvalues = {'b25':2.5, 'b05':5.0, 'b10':10.0}
bvalstr = {'b25':'2.5', 'b05':'5', 'b10':'10'}
parq = {
'f0':60.,
'sd':0.3,
'cp':2700.,
'cs':1230.
}
parq['s2'] = parq['sd']*parq['sd']
Flow('srick','dfgrd','math output="(x1/(%g))^2" | math output="input*exp(-input)"' % (parq['f0']))
Flow('psrick','srick','window n2=1 f2=1 | window | put label2=S unit2=')
for lb in bvalues.keys():
parq['b'] = bvalues[lb]
bstring = bvalstr[lb]
ksb = 'ksb' + lb
ksb2 = 'ksb2' + lb
kpb = 'kpb' + lb
kpb2 = 'kpb2' + lb
Flow(ksb,'dfgrd','math output="(%g)*x1/(%g)"' % (2.*pi*parq['b'],parq['cs']))
Flow(ksb2,ksb,'math output="input*input"')
Flow(kpb,'dfgrd','math output="(%g)*x1/(%g)"' % (2.*pi*parq['b'],parq['cp']))
Flow(kpb2,kpb,'math output="input*input"')
depthse = 'depthse' + lb
depthpe = 'depthpe' + lb
Flow(depthse,ksb2,'math k2=${SOURCES[0]} output="(%g)/(%g)*(1.+4.*k2)/(k2*k2)"' % (parq['b'],4.*parq['s2']))
Flow(depthpe,kpb2,'math k2=${SOURCES[0]} output="(%g)/(%g)*(1.+4.*k2)/(k2*k2)"' % (parq['b'],4.*parq['s2']))
specse = 'specse' + lb
sumse = 'sumse' + lb
fumse = 'fumse' + lb
fdomse = 'fdomse' + lb
specpe = 'specpe' + lb
sumpe = 'sumpe' + lb
fumpe = 'fumpe' + lb
fdompe = 'fdompe' + lb
fdome = 'fdome' + lb
Flow(specse,[depthse, 'srick'],'math lc=${SOURCES[0]} s=${SOURCES[1]} output="s*exp(-x2/lc)"')
Flow(sumse,specse,'stack axis=1 norm=n | window')
Flow(fumse,specse,'math output="x1*input" | stack axis=1 norm=n | window')
Flow(fdomse,[fumse, sumse],'math f=${SOURCES[0]} s=${SOURCES[1]} output="f/s" | put unit1=m unit2=Hz label2=f')
Flow(specpe,[depthpe, 'srick'],'math lc=${SOURCES[0]} s=${SOURCES[1]} output="s*exp(-x2/lc)"')
Flow(sumpe,specpe,'stack axis=1 norm=n | window')
Flow(fumpe,specpe,'math output="x1*input" | stack axis=1 norm=n | window')
Flow(fdompe,[fumpe ,sumpe],'math f=${SOURCES[0]} s=${SOURCES[1]} output="f/s" | put unit1=m unit2=Hz label2=f')
Result(fdome,[fdompe, fdomse],
'''
cat ${SOURCES[0:2]} axis=2 |
put label2='f' unit2='Hz' |
graph dash=0,3 title="Dominant frequency H=0.5" min1=0. max1=1500. min2=0. max2=68.
parallel2=n plotfat=4,4
''',stdin=0)
for fexp in ('M025','025','05','075'):
parq.update(pgrids[fexp])
hksb4 = 'hksb4' + lb + fexp
depthsf = 'depthsf' + lb + fexp
Flow(hksb4,[ksb2, ksb],'math k2=${SOURCES[0]} k=${SOURCES[1]} output="k-k/(1.+4.*k2)^(%g)"' % (0.5+parq['hu']))
Flow(depthsf,[hksb4, ksb],'math hk4=${SOURCES[0]} k=${SOURCES[1]} output="(%g)/(%g)/(k*hk4)"' % (parq['b'],parq['s2']*parq['cu']))
hkpb4 = 'hkpb4' + lb + fexp
depthpf = 'depthpf' + lb + fexp
Flow(hkpb4,[kpb2, kpb],'math k2=${SOURCES[0]} k=${SOURCES[1]} output="k-k/(1.+4.*k2)^(%g)"' % (0.5+parq['hu']))
Flow(depthpf,[hkpb4, kpb],'math hk4=${SOURCES[0]} k=${SOURCES[1]} output="(%g)/(%g)/(k*hk4)"' % (parq['b'],parq['s2']*parq['cu']))
specsf = 'specsf' + lb + fexp
sumsf = 'sumsf' + lb + fexp
fumsf = 'fumsf' + lb + fexp
fdomsf = 'fdomsf' + lb + fexp
specpf = 'specpf' + lb + fexp
sumpf = 'sumpf' + lb + fexp
fumpf = 'fumpf' + lb + fexp
fdompf = 'fdompf' + lb + fexp
fdomf = 'fdomf' + lb + fexp
Flow(specsf,[depthsf, 'srick'],'math lc=${SOURCES[0]} s=${SOURCES[1]} output="s*exp(-x2/lc)"')
Flow(sumsf,specsf,'stack axis=1 norm=n | window')
Flow(fumsf,specsf,'math output="x1*input" | stack axis=1 norm=n | window')
Flow(fdomsf,[fumsf, sumsf],'math f=${SOURCES[0]} s=${SOURCES[1]} output="f/s" | put unit1=m unit2=Hz label2=f')
Flow(specpf,[depthpf, 'srick'],'math lc=${SOURCES[0]} s=${SOURCES[1]} output="s*exp(-x2/lc)"')
Flow(sumpf,specpf,'stack axis=1 norm=n | window')
Flow(fumpf,specpf,'math output="x1*input" | stack axis=1 norm=n | window')
Flow(fdompf,[fumpf, sumpf],'math f=${SOURCES[0]} s=${SOURCES[1]} output="f/s" | put unit1=m unit2=Hz label2=f')
titledfq = 'title="Dominant frequency \k100 \F5 b\F2 \k70 =\k70 ' + bstring + '\k10 m\g \G \F5 H\F2 \k60 =\k60 ' + parq['shu'] + '"'
Result(fdomf,[fdompf, fdomsf],
'''
cat ${SOURCES[0:2]} axis=2 |
put label2='f' unit2='Hz' |
graph dash=0,3 min1=0. max1=1500. min2=0. max2=68. font=2
parallel2=n plotfat=4,4 n2tic=7 o2num=0.0 d2num=10.0 %s
''' % (titledfq),stdin=0)
End() |