Learn R Programming

PAMscapes (version 0.7.0)

plotLTSA: Plot Long-Term Spectral Average (LTSA)

Description

Creates a long-term spectral average (LTSA) style plot of the data, a plot where the x-axis is time and the y-axis is frequency. Color represents the magnitude of sound. In order to compress the time axis, data are binned into time chunks and the median value within that time bin is displayed

Usage

plotLTSA(
  x,
  bin = "1hour",
  scale = c("log", "linear"),
  title = NULL,
  freqRange = NULL,
  dbRange = NULL,
  units = NULL,
  cmap = viridis_pal()(25),
  toTz = "UTC",
  alpha = 1,
  maxBins = 800,
  returnData = FALSE
)

Value

ggplot object of the LTSA plot

Arguments

x

a soundscape metric file that can be read in with checkSoundscapeInput, or a dataframe with UTC, frequency, and value

bin

amount of time to bin for each LTSA slice, format can be "#Unit" e.g. '2hour' or '1day'

scale

scaling for frequency axis, one of log or linear

title

optional title for plot

freqRange

if not NULL, a vector of two numbers specifying the range of frequencies (Hz) to plot. Providing NA for either value will use the max/min frequency present in the dataset

dbRange

if not NULL, a fixed limit to use for the color scaling of dB values in the plot

units

units for plot labeling, will attempt to read them from the input

cmap

color palette map to use for plot, default is viridis_pal

toTz

timezone to use for the time axis (input data must be UTC). Specification must be from OlsonNames

alpha

alpha to use for the plot fill

maxBins

the maximum number of time bins to create for the plot. If bin would divide the range of dates in x into more than maxBins, then a warning will be given and a larger time bin will be used that reduces the number of time bins plotted. Trying to show a large number of bins will cause this function to be much slower

returnData

if TRUE then no plot will be generated, instead the dataframe that would normally be used to make the plot will be returned

Author

Taiki Sakai taiki.sakai@noaa.gov

Examples

Run this code
hmd <- checkSoundscapeInput(system.file('extdata/MANTAExampleSmall1.csv', package='PAMscapes'))
# time range is too small for nice plots
plotLTSA(hmd, bin='1min', title='Every Minute')
plotLTSA(hmd, bin='2min', title='2 Minute Bins')


Run the code above in your browser using DataLab