plotPSD {PAMscapes}R Documentation

Plot Power Spectral Density

Description

Plots the distribution of summarised sound levels across frequency, either as lines of quantile levels or a heatmap showing the full distribution. Multiple PSD sources can be combined and plotted as long as they have identical frequency levels.

Usage

plotPSD(
  x,
  style = c("quantile", "density"),
  scale = c("log", "linear"),
  q = 0.5,
  color = "black",
  freqRange = NULL,
  dbRange = NULL,
  dbInt = 1,
  units = "dB re: 1uPa^2/Hz",
  cmap = viridis_pal()(25),
  by = NULL,
  title = NULL,
  progress = TRUE
)

prepPSDData(
  x,
  freqRange = NULL,
  style = c("density", "quantile"),
  dbInt = 1,
  progress = TRUE
)

Arguments

x

a dataframe or list of dataframes, or file path or vector of file paths, or the output from prepPSDData

style

character specifying plot style to create, either "quantile", "density", or a vector with both

scale

scale to use for frequency axis, one of "log" or "linear"

q

quantile to plot

color

color for quantile

freqRange

range of frequencies to plot

dbRange

range of dB values to plot

dbInt

bin interval size for density plot

units

units for dB axis of plot

cmap

color map to use for density plot

by

optional column to plot different quantile lines by, only affects style='quantile'

title

optional title for plot

progress

logical flag to show progress bar

Details

prepPSDData is called by the plotting code, and does not necessarily need to be called separately from plotPSD. Loading PSD data can be time consuming, so it may be useful to load the data first, then it is easier to spend time adjusting plot settings.

The output of prepPSDData is a list with 5 elements:

frequency

- the frequency values of the input data

freqRange

- the value of the "freqRange" parameter if it was supplied

dbVals

- the dB values of breakpoints used for "density" plotting

quantileData

- the data used for quantile plots. These are stored as "tidgest" objects serialized using as.list.tdigest, from which quantiles can be computed

densityData

- the data used fro quantile plots. These are stored as a matrix of bin counts - each column corresponds to the "frequency" output, each row corresponds to bins defined using "dbVals" as boundaries

Value

a ggplot object for plotPSD, see details for prepPSDData

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples


psd <- checkSoundscapeInput(system.file('extdata/PSDSmall.csv', package='PAMscapes'))
# Plotting only first 1000 columns for brevity
plotPSD(psd[1:1000], style='density')
plotPSD(psd[1:1000], style='quantile', q=.05)


[Package PAMscapes version 0.6.0 Index]