periodogram {astrochron} R Documentation

## Simple periodogram

### Description

Calculate periodogram for stratigraphic series

### Usage

```periodogram(dat,padfac=2,demean=T,detrend=F,nrm=1,background=0,output=0,
f0=F,fNyq=T,xmin=0,xmax=Nyq,pl=1,genplot=T,verbose=T)
```

### Arguments

 `dat` Stratigraphic series to analyze. First column should be location (e.g., depth), second column should be data value. `padfac` Pad with zeros to (padfac*npts) points, where npts is the original number of data points. padfac will automatically promote the total padded series length to an even number, to ensure the Nyquist frequency is calculated. However, if padfac is set to 0, no padding will be implemented. `demean` Remove mean from data series? (T or F) `detrend` Remove linear trend from data series? (T or F) `nrm` Power normalization: 0 = no normalization; 1 = divide Fourier transform by npts. `background` Estimate noise model background spectrum and confidence levels? (0= No, 1= AR1, 2= Power Law) `output` Return output as new data frame? (0= no; 1= frequency,amplitude,power,phase (+ background fit and confidence levels, if background selected); 2= frequency,real coeff.,imag. coeff) `f0` Return results for the zero frequency? (T or F) `fNyq` Return results for the Nyquist frequency? (T or F) `xmin` Smallest frequency for plotting. `xmax` Largest frequency for plotting. `pl` Power spectrum plotting: 1 = log power, 2 = linear power `genplot` Generate summary plots? (T or F) `verbose` Verbose output? (T or F)

`mtm` and `lowspec`

### Examples

```# ***** PART 1: Demonstrate the impact of tapering
# generate example series with 10 periods: 100, 40, 29, 21, 19, 14, 10, 5, 4 and 3 ka.
ex=cycles(c(1/100,1/40,1/29,1/21,1/19,1/14,1/10,1/5,1/4,1/3),amp=c(1,.75,0.01,.5,.25,
0.01,0.1,0.05,0.001,0.01))

# set zero padding amount for spectral analyses

# calculate the periodogram with no tapering applied (a "rectangular window")

# save the frequency grid and the power for plotting
freq=res
pwr_rect=res

# now compare with results obtained after applying four different tapers:
#  Hann, 30% cosine taper, DPSS with a time-bandwidth product of 1, and DPSS
#  with a time-bandwidth product of 3

# now plot the results
ymin=min(rbind (log(pwr_rect[,1]),log(pwr_hann[,1]),log(pwr_cos[,1]),log(pwr_dpss1[,1]),
log(pwr_dpss3[,1]) ))
ymax=max(rbind (log(pwr_rect[,1]),log(pwr_hann[,1]),log(pwr_cos[,1]),log(pwr_dpss1[,1]),
log(pwr_dpss3[,1]) ))

pl(2)
plot(freq[,1],log(pwr_rect[,1]),type="l",ylim=c(ymin,ymax),lwd=2,ylab="log(Power)",
xlab="Frequency (cycles/ka)",
main="Comparison of rectangle (black), cosine (blue) and Hann (orange) taper",
cex.main=1)
lines(freq[,1],log(pwr_hann[,1]),col="orange",lwd=2)
lines(freq[,1],log(pwr_cos[,1]),col="blue")
points(c(1/100,1/40,1/29,1/21,1/19,1/14,1/10,1/5,1/4,1/3),rep(ymax,10),cex=.5,
col="purple")

plot(freq[,1],log(pwr_rect[,1]),type="l",ylim=c(ymin,ymax),lwd=2,ylab="log(Power)",
xlab="Frequency (cycles/ka)",
main="Comparison of rectangle (black), 1pi DPSS (green) and 3pi DPSS (red) taper",
cex.main=1)
lines(freq[,1],log(pwr_dpss1[,1]),col="green")
lines(freq[,1],log(pwr_dpss3[,1]),col="red",lwd=2)
points(c(1/100,1/40,1/29,1/21,1/19,1/14,1/10,1/5,1/4,1/3),rep(ymax,10),cex=.5,
col="purple")

# ***** PART 2: Now add a very small amount of red noise to the series
#               (with lag-1 correlation = 0.5)
ex2=ex
ex2=ex2+ar1(rho=.5,dt=1,npts=500,sd=.005,genplot=FALSE)

# compare the original series with the series+noise
pl(2)
plot(ex,type="l",lwd=2,lty=3,col="black",xlab="time (ka)",ylab="signal",
main="signal (black dotted) and signal+noise (red)"); lines(ex2,col="red")
plot(ex[,1],ex2[,2]-ex[,2],xlab="time (ka)",ylab="difference",
main="Difference between the two time series (very small!)")

# calculate the periodogram with no tapering applied (a "rectangular window")

# save the frequency grid and the power for plotting
freq.2=res.2
pwr_rect.2=res.2

# now compare with results obtained after applying four different tapers:
#  Hann, 30% cosine taper, DPSS with a time-bandwidth product of 1, and DPSS
#  with a time-bandwidth product of 3

# now plot the results
ymin=min(rbind (log(pwr_rect.2[,1]),log(pwr_hann.2[,1]),log(pwr_cos.2[,1]),
log(pwr_dpss1.2[,1]),log(pwr_dpss3.2[,1]) ))
ymax=max(rbind (log(pwr_rect.2[,1]),log(pwr_hann.2[,1]),log(pwr_cos.2[,1]),
log(pwr_dpss1.2[,1]),log(pwr_dpss3.2[,1]) ))

pl(2)
plot(freq.2[,1],log(pwr_rect.2[,1]),type="l",ylim=c(ymin,ymax),lwd=2,ylab="log(Power)",
xlab="Frequency (cycles/ka)",
main="Comparison of rectangle (black), cosine (blue) and Hann (orange) taper",
cex.main=1)
lines(freq.2[,1],log(pwr_hann.2[,1]),col="orange",lwd=2)
lines(freq.2[,1],log(pwr_cos.2[,1]),col="blue")
points(c(1/100,1/40,1/29,1/21,1/19,1/14,1/10,1/5,1/4,1/3),rep(ymax,10),cex=.5,
col="purple")

plot(freq.2[,1],log(pwr_rect.2[,1]),type="l",ylim=c(ymin,ymax),lwd=2,ylab="log(Power)",
xlab="Frequency (cycles/ka)",
main="Comparison of rectangle (black), 1pi DPSS (green) and 3pi DPSS (red) taper",
cex.main=1)
lines(freq.2[,1],log(pwr_dpss1.2[,1]),col="green")
lines(freq.2[,1],log(pwr_dpss3.2[,1]),col="red",lwd=2)
points(c(1/100,1/40,1/29,1/21,1/19,1/14,1/10,1/5,1/4,1/3),rep(ymax,10),cex=.5,
col="purple")