#!/usr/bin/env bash # Testing gmt spectrum1d power spectrum values
ps=power1D.ps
# First to generate a signal with fixed frequency using math.
# --------------------------------------------------------------------------- # This is the math example from GMT developer, but hard to understand. So we do not use it here. # gmt math -T0/10239/1 T 10240 DIV 360 MUL 400 MUL COSD = t.txt # ---------------------------------------------------------------------------
# --------------------------------------------------------------------------- # This is the math example that easy to understand. gmt math -T0/200/0.5 T 20 DIV 360 MUL COSD T 4 DIV 360 MUL SIND 3 MUL ADD = t.txt # The same with up line but with unit of radian. # gmt math -T0/200/0.5 T 20 DIV 6.28 MUL COS T 4 DIV 6.28 MUL SIN 3 MUL ADD = t.txt # ---------------------------------------------------------------------------
# The same result using -N cut -f2 t.txt | gmt spectrum1d -S256 -W -Nv4 -D0.5 gmt psxy -R -J -O -K v4.xpower -W2.25p,red >> $ps
# wavelength is the reverse of the frequency, the result is the same but a increasing x-axis and a decreasing x-axis gmt spectrum1d t.txt -S256 --GMT_FFT=brenner -N -i1 -D0.5> pow5.txt # The X-axes length of wavelength is the reciprocal of frequency. gmt psxy -R0.00390625/5/1e-19/1e5 -JX6il/6.5il -O -K pow5.txt -BSE -Bxa2f3+l"Frenquency" -W0.5p,green >> $ps gmt psxy -R -J -O -W0.25p,green,- << EOF >> $ps 0.251e-19 0.251e5 EOF
gmt psconvert $ps -A -Tg
结果如下图
ATTENTION
GMT功率谱使用的Welch方法,输出的数值服从Parseval 定理。 The sum of the squares of your input data should equal the sum of the squares of the outputs from spectrum1d.