Skip to contents

This function generates an averaged Power Spectral Density (PSD) plot multiple input Waves (e.g., population, species, etc,).

Usage

spectrum_pop(
  waves,
  binomial = NULL,
  freq_res = 400,
  s_rate_out = 96000,
  fun = "mean",
  wn = "hanning",
  flim = NULL,
  line_color = "green4",
  line_width = 1,
  sd_color = "dodgerblue",
  sd_alpha = 0.5,
  title_x = "Frequency (kHz)",
  title_y = "",
  show_x_labs = TRUE,
  show_y_labs = FALSE,
  show_n = TRUE,
  save_to = NULL,
  save = FALSE,
  width = 960,
  height = 540,
  dpi = 200
)

Arguments

binomial

Character. The binomial name of the species. Empty by default.

freq_res

Numeric. The frequency resolution to be used for the frequency spectrum analysis. Use this argument consistently for standardized measurements across recordings with different sampling rate. Default is 10 Hz per frequency bin.

s_rate_out

Sample rate of the output summary PSD, in kHz.

fun

Character. Select a function to compute each power spectrum. Options are "mean", "median", "sd", and "var".

wn

Character. Select a window function to for the FFT. Options are "hanning" (Default), "hamming", bartlett", "blackaman", "flattop", and "rectangular".

flim

Numeric list of length 2. Range of the frequency axis (KhZ).

line_color

Character. Color for the line representing the mean PSD.

line_width

Numeric. Width of the mean line.

sd_color

Character. Color for the standard deviation ribbon.

sd_alpha

Numeric. Transparency level for the SD ribbon. Default is 0.3 (30%).

title_x

Character. Title for the X-axis. Default is "Frequency (kHz)".

title_y

Character. Title for the Y-axis. Empty by default.

show_x_labs

Logical. If TRUE, the labels (i.e., numbers) are shown in the X-axis. Defaults to TRUE.

show_y_labs

Logical. If TRUE, the labels (i.e., numbers) are shown in the Y-axis. Defaults to FALSE

show_n

Logical. If TRUE, the number of samples (i.e., recordings) is shown as "n=" on the top-right of the plot.

save

Logical. Whether to save the plot immediately.

width

Numeric. Relative width of the output plot. Default is 960.

height

Numeric. Relative height of the output plot. Default is 540.

dpi

Numeric. Resolution in dots per inch. Default is 200.

wave

An object of class Wave containing the audio data to be analyzed.

Value

An averaged and smoothed power spectral density plot representing all the Waves in the list provided to the waves argument. The plot shows the mean and confidence interval (95% by default) along with the peak frequency, the scientific name of the species as provided in the binomial argument, and the number of samples (Wave objects) from which the mean was calculated.

Examples

 if (FALSE) { # \dontrun{
library(RthopteraSounds)
data(coryphoda)
data(tettigonia)
# Assume the two Waves are two individuals from the same species
waves_list <- c(coryphoda, tettigonia)
population_spectrum(waves = waves_list, freq_res = 50, show_x_labs = TRUE,
title_x = "", show_n = TRUE, binomial = "Coryphoda albidicollis")
} # }