View source: R/spectralUtils.R
McNamaraPSD | R Documentation |
The McNamaraPSD() function implements the spectral density algorithm specified in the "Data Preparation and Processing" section of Seismic Noise Analysis System Using Power Spectral Density Probability Density Functions.
McNamaraPSD(tr, loFreq=.005, hiFreq=10, alignFreq=0.1, binned=TRUE)
tr |
a |
loFreq |
optional lo end of frequency binning range |
hiFreq |
optional hi end of frequency binning range |
alignFreq |
optional alignment frequency for determining frequency bins |
binned |
logical determining whether the return spectrum is binned |
This PSD algorithm is designed to be used on one to three hour segments of seismic data and will return a PSD
object
containing the (potentially binned) spectrum for that segment. See the psdList
function for
automatic segmenting of longer Stream
objects.
The McNamara PSD algorithm is similar to MATLAB's pwelch() function and has the following steps:
Calculate averaged spectrum
# Truncate incoming segment of trace data to nearest power of 2 samples. # Divide each truncated segment into 13 chunks with 75% overlap. The first # chunk begins at 0/16 and ends at 4/16. The 13'th chunk begins at 12/16 # and ends at 16/16. The chunks overlap like this: # # 1---5---9---3--- # 2---6---0--- # 3---7---1--- # 4---8---2--- # # Deman, detrend and taper the chunk. # Calculate the 'one-sided' spectrum for the chunk. # # Average together all 13 spectra to get an averaged spectrum.
Create smoothed version of spectrum with binning
When binned=TRUE
, McNamara style binning is
turned on and a smoothed spectrum is returned that contains many fewer points than the full spectrum.
When these arguments are not specified, binning is automatically turned off and the full spectrum is returned.
Frequencies for binning are generated at 1/8 octave intervals aligned to alignFreq
.
The power (dB) associated with each frequency bin is calculated by averaging over an entire octave
centered on that frequency.
Note: The spectra returned by McNamaraPSD() have not had instrument correction applied.
Use getEvalresp
to get instrument correction values for specific frequencies.
convert binned spectra to decibels
An R list
object with the following named elements:
freq, spec, snclq, starttime, endtime
Elements freq
and spec
are numeric vectors while snclq
, starttime
and endtime
are single values.
During the binning process, an arithmetic mean is used to average together power levels in decibels. This is equivalent to averaging of power levels before conversion to dB using a geometric mean.
Jonathan Callahan jonathan@mazamascience.com
Seismic Noise Analysis System Using Power Spectral Density Probability Density Functions (McNamara and Boaz 2005)
McNamaraBins
,
psdList
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.