Introduction

This example demonstrates the use of rPeaks for the deconvolution of monthly sunspots data using a Lorentzian profile.

First, load the packages we need

library(datasets)
library(rPeaks)
library(stats)
library(graphics)

Next, generate the spectrum

smf <- abs(fft(spec.taper(as.vector(sunspot.month),p=0.5)))

Remove the background from the spectrum

p <- smf-SpectrumBackground(smf,iterations=100)

Generate a Lorentzian responce vector with FWHM=pi*5

x <- 1:100
Z <-1/(1+((x-pi*5)/5)^2)

Deconvolve the low-frequency region of spectrum

l <- SpectrumDeconvolution(p[1:500],Z,iterations=20,boost=1.1,
                           repetitions=4)

Now, plot the results

plot(p,type="p", xlim=c(0,200), ylim=c(0,80000))
lines(l,col="red")


jrminter/rPeaks documentation built on April 29, 2020, 6:25 p.m.