Hi All,
I have like a few hundred sac traces and want to calculate the average (and
std dev) trace...
I am positive that writing the data in ascii and then working with scripts
(awk etc...) you could achieve this. But I wonder if I could calculate this
directly from sac more efficiently.
Best,
Aderson Nascimento
I have like a few hundred sac traces and want to calculate the average (and
std dev) trace...
I am positive that writing the data in ascii and then working with scripts
(awk etc...) you could achieve this. But I wonder if I could calculate this
directly from sac more efficiently.
Best,
Aderson Nascimento
-
Hi,
I've worked around with this script. Probably there's a more efficient way
but it seems to work.
I am sending my solution in case someone needs.
Best
Aderson
=====
#
# reading all sac files
#
echo "reading all sac files"
sac <<END
r *.SAC
rmean
rtr
w append .rmean.rtrend
q
END
#
# calculating sac average trace
#
echo "calculating sac average trace"
ls -1 *.rmean.rtrend | awk '{if (NR == 1) print "r "$1;else print "addf
"$1} END {print "div "NR"\nw average_trace.sac\nq"}' | sac
#
# calculating the squared differences
#
echo "calculating the squared differences"
sac <<END
r *.rmean.rtrend
subf average_trace.sac
sqr
w append .sqr.difference
q
END
#
# calculating the average of the squared differences
#
echo "calculating the average of the squared differences"
ls -1 *.sqr.difference | awk '{if (NR == 1) print "r "$1;else print "addf
"$1} END {print "div "NR"\nw average_sqr_differences.sac\nq"}' | sac
#
# calculating now the squared root of average of the squared differences =
standard deviation
#
echo "calculating now the squared root of average of the squared
differences = standard deviation"
sac <<END
r average_sqr_differences.sac
sqrt
w std_dev.sac
q
END
#
# now calculating the plus and minus files
#
echo "now calculating the plus and minus files"
sac <<END
r average_trace.sac
addf std_dev.sac
w plus_std_dev.sac
inicm
r average_trace.sac
subf std_dev.sac
w minus_std_dev.sac
q
END
#
# cleaning up
#
\rm *.rmean.rtrend
\rm *.sqr.difference
==========
2016-07-24 19:07 GMT-03:00 Aderson Farias do Nascimento <
nascimentoafd<at>gmail.com>:
Hi All,
I have like a few hundred sac traces and want to calculate the average
(and std dev) trace...
I am positive that writing the data in ascii and then working with scripts
(awk etc...) you could achieve this. But I wonder if I could calculate this
directly from sac more efficiently.
Best,
Aderson Nascimento
-
Dear All -
See Chapter 8 in the SAC book. In particular, the stacking subprocess, SSS, provides ways to sum multiple traces and provide the mean and standard deviation with different summation methods (linear, Nth root, phase weighting).
On 25 Jul 2016, at 00:08, Aderson Nascimento <nascimentoafd<at>gmail.com> wrote:
Hi All,
George Helffrich
I have like a few hundred sac traces and want to calculate the average (and std dev) trace...
I am positive that writing the data in ascii and then working with scripts (awk etc...) you could achieve this. But I wonder if I could calculate this directly from sac more efficiently.
Best,
Aderson Nascimento
----------------------
SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)
Sent via IRIS Message Center (http://ds.iris.edu/message-center/)
Update subscription preferences at http://ds.iris.edu/account/profile/
george.helffrich<at>bris.ac.uk
-
Thanks, George!
I'll look for the book.
Best
Aderson
2016-07-25 8:06 GMT-03:00 George Helffrich <George.Helffrich<at>bristol.ac.uk>:
Dear All -
See Chapter 8 in the SAC book. In particular, the stacking
subprocess, SSS, provides ways to sum multiple traces and provide the mean
and standard deviation with different summation methods (linear, Nth root,
phase weighting).
On 25 Jul 2016, at 00:08, Aderson Nascimento <nascimentoafd<at>gmail.com>
wrote:
Hi All,
(and std dev) trace...
I have like a few hundred sac traces and want to calculate the average
I am positive that writing the data in ascii and then working with
scripts (awk etc...) you could achieve this. But I wonder if I could
calculate this directly from sac more efficiently.
Best,
George Helffrich
Aderson Nascimento
----------------------
SAC Help (http://ds.iris.edu/message-center/topic/sac-help/)
Sent via IRIS Message Center (http://ds.iris.edu/message-center/)
Update subscription preferences at http://ds.iris.edu/account/profile/
george.helffrich<at>bris.ac.uk
-