|
| 1 | +from rsf.proj import * |
| 2 | + |
| 3 | +# Make dependencies |
| 4 | +SConscript('../src/SConstruct') |
| 5 | + |
| 6 | +# Single graph |
| 7 | +Flow('sin', None, |
| 8 | + ''' |
| 9 | + math n1=41 o1=-4 d1=0.2 output='0.5*x1-sin(x1)' |
| 10 | + ''') |
| 11 | + |
| 12 | +Result('sin1','sin', |
| 13 | + ''' |
| 14 | + graph title="0.5x-sin(x)" min1=-4 max1=4 |
| 15 | + ''') |
| 16 | +Result('sin2','sin', |
| 17 | + ''' |
| 18 | + graph title="0.5x-sin(x)" min1=-4 max1=4 |
| 19 | + symbol=o symbolsz=12 grid=y |
| 20 | + ''') |
| 21 | + |
| 22 | +# Sigmoid model |
| 23 | +Flow('model',None, |
| 24 | + ''' |
| 25 | + sigmoid n1=200 n2=200 d1=.004 d2=.008 | |
| 26 | + smooth rect1=3 diff1=1 | smooth rect1=3 | |
| 27 | + put label2=Distance title='"Sigmoid Model"' |
| 28 | + ''') |
| 29 | + |
| 30 | +# Time-frequency spectrum |
| 31 | +Flow('ltft','model', |
| 32 | + ''' |
| 33 | + ltft niter=10 rect=5 | |
| 34 | + cabs |
| 35 | + ''') |
| 36 | + |
| 37 | +# Plot using madagascar |
| 38 | +Result('model', |
| 39 | + ''' |
| 40 | + grey title="Sigmoid Model" |
| 41 | + ''') |
| 42 | +Result('modelw','model', |
| 43 | + ''' |
| 44 | + wiggle transp=y yreverse=y poly=y |
| 45 | + title="Sigmoid Model" |
| 46 | + ''') |
| 47 | +Result('ltft','ltft', |
| 48 | + ''' |
| 49 | + byte bar=bar.rsf allpos=y clip=2e-4 | |
| 50 | + grey3 title="Time-Frequency Spectra" color=j |
| 51 | + frame1=100 frame2=25 frame3=100 flat=n |
| 52 | + bar=bar.rsf scalebar=y |
| 53 | + ''') |
| 54 | + |
| 55 | +# Figure combinations |
| 56 | +Plot('subfig1','model','grey') |
| 57 | +Plot('subfig2','model','wiggle transp=y yreverse=y poly=y') |
| 58 | + |
| 59 | +Result('combined','subfig1 subfig2','TwoRows') |
| 60 | + |
| 61 | +# Plot using sfmatplotlib |
| 62 | + |
| 63 | +Result('model1','model', |
| 64 | + ''' |
| 65 | + transp | |
| 66 | + sfmatplotlib imshow cmap=gray origin=upper format=pdf |
| 67 | + title="Sigmoid Model" xlabel="Distance (sample)" ylabel="Time (sample)" |
| 68 | + ''', suffix='.pdf') |
| 69 | + |
| 70 | +# Plot using python script |
| 71 | +## grey-scale |
| 72 | +mypyscript = '../src/greytest.exe' |
| 73 | +# Or |
| 74 | +# mypyscript = '../src/greytest.py' |
| 75 | +# and use `python ../src/greytest.py` |
| 76 | + |
| 77 | +Result('mygrey',['model', mypyscript], # Make your script dependent |
| 78 | + ''' |
| 79 | + ${SOURCES[1]} |
| 80 | + ''', suffix='.pdf') |
| 81 | + |
| 82 | +## wiggle provided by ChatGPT |
| 83 | +gptscript = '../src/wigtest.exe' |
| 84 | +Result('gptwig',['model', gptscript], |
| 85 | + ''' |
| 86 | + ${SOURCES[1]} |
| 87 | + ''', suffix='.pdf') |
| 88 | + |
| 89 | +## grey3 by python |
| 90 | +grey3script = '../src/grey3test.exe' |
| 91 | +Result('pygrey3',['ltft', grey3script], |
| 92 | + ''' |
| 93 | + ${SOURCES[1]} frame1=100 frame2=25 frame3=100 |
| 94 | + point1=0.8 point2=0.4 clip=2e-4 flat=n scalebar=y |
| 95 | + title="Time-Frequency Spectra" allpos=y color=jet |
| 96 | + ''', suffix='.pdf') |
| 97 | + |
| 98 | +# Plot using matlab/octave script (grey-scale) |
| 99 | +matlab = WhereIs('matlab') |
| 100 | +octave = WhereIs('octave') |
| 101 | +matscript = '../src/matgrey1.m' |
| 102 | +funcname = 'matgrey1' |
| 103 | + |
| 104 | +if matlab: |
| 105 | + Result('matgrey',['model', matscript], |
| 106 | + ''' |
| 107 | + %s -batch "addpath('../src/'); %s('${SOURCES[0]}', '${TARGETS[0]}', 'Sigmoid Model')" |
| 108 | + '''%(matlab, funcname), suffix='.pdf', stdin=0, stdout=-1) |
| 109 | + |
| 110 | +if octave: |
| 111 | + Result('octgrey',['model', matscript], |
| 112 | + ''' |
| 113 | + %s --eval "addpath('../src/'); %s('${SOURCES[0]}', '${TARGETS[0]}', 'Sigmoid Model'); exit;" |
| 114 | + '''%(octave, funcname), suffix='.pdf', stdin=0, stdout=-1) |
| 115 | + |
| 116 | +# Try GMT |
| 117 | +gmt = WhereIs('gmt') |
| 118 | +if gmt: |
| 119 | + gmtscript1 = '../src/gmt-1.sh' |
| 120 | + gmtscript2 = '../src/gmt-2.sh' |
| 121 | + Result('gmt1', gmtscript1,'bash ${SOURCES[0]} ${TARGETS[0]}', suffix='.pdf', stdin=0, stdout=-1) |
| 122 | + Result('gmt2', gmtscript2,'bash ${SOURCES[0]} ${TARGETS[0]}', suffix='.pdf', stdin=0, stdout=-1) |
| 123 | + |
| 124 | + # GMT Wiggle |
| 125 | + |
| 126 | + ## Need T-X Grid |
| 127 | + Flow('model1','model','dd form=ascii line=1 --out=${TARGETS[0]}', stdout=0) |
| 128 | + Flow('tgrid','model','math output="x1" | dd form=ascii line=1 --out=${TARGETS[0]}', stdout=0) |
| 129 | + Flow('xgrid','model','math output="x2" | dd form=ascii line=1 --out=${TARGETS[0]}', stdout=0) |
| 130 | + Flow('gmtmodel','tgrid xgrid model1', ' paste ${SOURCES[0:3]} ') |
| 131 | + Result('gmt3', ['gmtmodel'], |
| 132 | + ''' |
| 133 | + gmt wiggle -R0/0.8/0/1.6 -JX5i/5i -BWSne+t"Sigmoid Model" -B -Z0.1i -Gred+p -Gblue+n -Wdefault -gy0.001 -By+l"Distance (km)" -Bx+l"Time (s)" -pdf Fig/gmt3 |
| 134 | + ''', suffix='.pdf', stdout=-1, rsfflow=0) |
| 135 | + |
| 136 | +# Try fetch |
| 137 | +Fetch('Txx.HH','septour') |
| 138 | +Result('txx','Txx.HH','wiggle') |
| 139 | +Flow('windowed','Txx.HH','window n2=10 min1=0.4 max1=0.8') |
| 140 | +plotpar = \ |
| 141 | + ''' |
| 142 | + transp=y poly=y yreverse=y pclip=100 nc=100 allpos=n |
| 143 | + ''' |
| 144 | +for plot in ('wiggle','contour','grey'): |
| 145 | + Result(plot,'windowed',plot + plotpar) |
| 146 | + |
| 147 | + |
| 148 | +End() |
0 commit comments