simspec: Simulate Spectra

View source: R/signal.R

simspecR Documentation

Simulate Spectra

Description

Simulate spectra from noise and a list of peaks.

Usage

simspec(n = 1L, npeaks = 50L,
	x = rlnorm(npeaks, 7, 0.3), y = rlnorm(npeaks, 1, 0.9),
	domain = c(0.9 * min(x), 1.1 * max(x)), size = 10000,
	sdx = 1e-5, sdy = sdymult * log1p(y), sdymult = 0.2,
	sdnoise = 0.1, resolution = 1000, fmax = 0.5,
	baseline = 0, decay = 10, units = "relative")

simspec1(x, y, xout, peakwidths = NA_real_,
	sdnoise = 0, resolution = 1000, fmax = 0.5)

Arguments

n

The number of spectra to simulate.

npeaks

The number of peaks to simulate. Not used if x and y are provided.

x, y

The locations and values of the spectral peaks.

xout, domain

The output domain variable or its range.

size

The number of samples in each spectrum.

sdx

The standard deviation of the error in the observed locations of peaks, in units indicated by units.

sdy

The standard deviation(s) for the distributions of observed peak values on the log scale.

sdymult

A multiplier used to calculate sdy based on the mean values of the peaks; used to simulate multiplicative variance. Not used if sdy is provided.

sdnoise

The standard deviation of the random noise in the spectra on the log scale.

resolution

The resolution as defined by x / dx, where x is the observed peak location and dx is the width of the peak at a proportion of its maximum height defined by fmax (defaults to full-width-at-half-maximum – FWHM – definition).

fmax

The fraction of the maximum peak height to use when defining the resolution.

peakwidths

The peak widths at fmax. Typically, these are calculated automatically from resolution.

baseline

The maximum intensity of the baseline. Note that baseline=0 means there is no baseline.

decay

A constant used to calculate the exponential decay of the baseline. Larger values mean the baseline decays more sharply.

units

The units for sdx. Either "absolute" or "relative".

Value

Either a numeric vector of the same length as size, giving the simulated spectrum, or a size x n matrix of simulated spectra.

Author(s)

Kylie A. Bemis

Examples

set.seed(1)
y <- simspec(2)
x <- attr(y, "domain")

plot(x, y[,1], type="l", ylim=c(-max(y), max(y)))
lines(x, -y[,2], col="red")

kuwisdelu/matter documentation built on Oct. 19, 2024, 10:31 a.m.