The following script will call a simple running mean three times with appropriate window size to do effect triple running mean, as described in the article (as amended for the asymmetric kernel to minimise negative leakage):
https://climategrog.wordpress.com/2013/05/19/triple-running-mean-filters/
It requires the runmean.awk script found here:
https://climategrog.wordpress.com/2013/11/02/574/
Select code with mouse to copy elsewhere.
#!/bin/bash # call runmean.awk three times to compose triple running mean # usage: ./r3m.sh file window_len ; default window is 12 data point if [ "x$1" == "x" ]; then echo "$0 : err no file name, usage: $0 filename " exit 1; else fn=$1 fi if [ "x$2" == "x" ]; then win=12; else win=$2; fi #win2=`awk "BEGIN{print $win/ 1.3371}"` #win3=`awk "BEGIN{print $win/ 1.3371/ 1.3371}"` # asymmetric stages with following window ratios: k=1.15; k2=1.58 win2=`awk "BEGIN{print $win/ "$k"}"` win3=`awk "BEGIN{print $win/ "$k2" }"` outfile=`echo $fn | awk '{ print substr($1,1,length($1)-4) }'` outfile+="-3rm"$win".dat" echo "# triple running mean : $win $win2 $win3 " > $outfile # echo $fn; echo $win; echo $win2; echo $win3 cat $fn | ./runmean.awk - $win | ./runmean.awk - $win2 | ./runmean.awk - $win3 >> $outfile #echo "# cat $fn | ./runmean.awk - $win | ./runmean.awk - $win2 | ./runmean.awk - $win3 >> $outfile" echo "# triple running mean : $win $win2 $win3 " echo "# outfile = "$outfile;
Advertisements