psd

Adaptive, sine-multitaper power spectral density estimation in R

https://github.com/abarbour/psd

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 3 committers (33.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.9%) to scientific vocabulary

Keywords

multitaper power-spectral-density power-spectrum psd r spectral-density-estimates spectrum
Last synced: 6 months ago · JSON representation

Repository

Adaptive, sine-multitaper power spectral density estimation in R

Basic Info
Statistics
  • Stars: 9
  • Watchers: 2
  • Forks: 6
  • Open Issues: 2
  • Releases: 0
Topics
multitaper power-spectral-density power-spectrum psd r spectral-density-estimates spectrum
Created about 14 years ago · Last pushed 10 months ago
Metadata Files
Readme

README.md

psd

Adaptive, sine multitaper power spectral density estimation for R

by Andrew J Barbour, Jonathan Kennel, and Robert L Parker

R-CMD-check Code Coverage Downloads License Citation <!-- badges: end -->

Latest News

As of version 2.0, one can calculate the multivariate PSD ("cross spectra") between two signals.

Description

This is an R package for computing univariate power spectral density estimates with little or no tuning effort. We employ sine multitapers, allowing the number to vary with frequency in order to reduce mean square error, the sum of squared bias and variance, at each point. The approximate criterion of Riedel and Sidorenko (1995) is modified to prevent runaway averaging that otherwise occurs when the curvature of the spectrum goes to zero. An iterative procedure refines the number of tapers employed at each frequency. The resultant power spectra possess significantly lower variances than those of traditional, non-adaptive estimators. The sine tapers also provide useful spectral leakage suppression. Resolution and uncertainty can be estimated from the number of degrees of freedom (twice the number of tapers).

This technique is particularly suited to long time series, because it demands only one numerical Fourier transform, and requires no costly additional computation of taper functions, like the Slepian functions. It also avoids the degradation of the low-frequency performance associated with record segmentation in Welch's method. Above all, the adaptive process relieves the user of the need to set a tuning parameter, such as time-bandwidth product or segment length, that fixes frequency resolution for the entire frequency interval; instead it provides frequency-dependent spectral resolution tailored to the shape of the spectrum itself.

psd elegantly handles spectra with large dynamic range and mixed-bandwidth features|features typically found in geophysical datasets.

How to Cite

Bob and Andy have a paper in Computers & Geosciences to accompany this software (download a pdf, 1MB); it describes the theory behind the estimation process, and how we apply it in practice. If you find psd useful in your research, we kindly request you cite our paper. See also:

citation("psd")

Getting Started

You can to install the package and it's dependencies with CRAN (from within the R environment):

install.packages("psd")

then load the package library

library(psd)

We have included a dataset to play with, namely Tohoku, which represents recordings of high-frequency borehole strainmeter data during teleseismic waves from the 2011 Mw 9.0 Tohoku earthquake (original data source). Access and inspect these data with:

data(Tohoku)
print(str(Tohoku))

The 'preseismic' data has interesting spectral features, so we subset it, and analyze the areal strain (the change in borehole diameter):

Dat <- subset(Tohoku, epoch=="preseismic")
Areal <- ts(Dat$areal)

For the purposes of improving the accuracy of the spectrum, we remove a linear trend:

Dat <- prewhiten(Areal, plot=FALSE)

Now we can calculate the adaptive PSD:

mtpsd <- pspectrum(Dat[['prew_lm']], plot=TRUE)
print(class(mtpsd))

In the previous example the plot=TRUE flag produces a comparison with a basic periodogram, but we can also visualize the spectrum with builtin plotting methods:

plot(mtpsd, log="dB")

The spectral uncertainty can be easily calculated:

sprop <- spectral_properties(mtpsd)
with(sprop, {
    plot(taper/max(taper), type="h", ylim=c(0,2), col="dark grey") 
    lines(stderr.chi.lower)
    lines(stderr.chi.upper)
})

Installing the Development Version

Should you wish to install the development version of this software, the remotes library will be useful:

library(remotes)
remotes::install_github("abarbour/psd")

GitHub Events

Total
  • Push event: 7
  • Create event: 1
Last Year
  • Push event: 7
  • Create event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 429
  • Total Committers: 3
  • Avg Commits per committer: 143.0
  • Development Distribution Score (DDS): 0.333
Past Year
  • Commits: 7
  • Committers: 1
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Andy Barbour a****r@g****m 286
Andy Barbour a****r@u****u 109
jkennel j****l@u****a 34
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 6
  • Total pull requests: 3
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 1 day
  • Total issue authors: 4
  • Total pull request authors: 1
  • Average comments per issue: 2.83
  • Average comments per pull request: 2.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • abarbour (2)
  • gmgeorg (2)
  • HaoLi111 (1)
  • sbcalaff (1)
Pull Request Authors
  • jkennel (3)
Top Labels
Issue Labels
cross spectrum (1)
Pull Request Labels
cross spectrum (1)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 1,267 last-month
  • Total docker downloads: 43,390
  • Total dependent packages: 4
  • Total dependent repositories: 6
  • Total versions: 11
  • Total maintainers: 1
cran.r-project.org: psd

Adaptive, Sine-Multitaper Power Spectral Density and Cross Spectrum Estimation

  • Versions: 11
  • Dependent Packages: 4
  • Dependent Repositories: 6
  • Downloads: 1,267 Last month
  • Docker Downloads: 43,390
Rankings
Docker downloads count: 0.6%
Dependent packages count: 9.3%
Dependent repos count: 11.9%
Forks count: 12.2%
Average: 13.1%
Stargazers count: 17.4%
Downloads: 27.2%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 2.14.1 depends
  • RColorBrewer * imports
  • Rcpp >= 0.11.5 imports
  • RSEIS * suggests
  • bspec * suggests
  • fftw >= 1.0.3 suggests
  • formatR * suggests
  • ggplot2 >= 0.9 suggests
  • knitr * suggests
  • multitaper * suggests
  • plyr * suggests
  • rbenchmark * suggests
  • reshape2 * suggests
  • rmarkdown * suggests
  • signal * suggests
  • testthat >= 2.1.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
  • r-lib/actions/setup-tinytex v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v1 composite
  • r-lib/actions/setup-r-dependencies v1 composite