Filtering

The data I chose represent the northern hemisphere land and ocean lower-stratosphere temperature anomaly from UAH (v5.6). I used a 4, 12(1 year), and 48 month moving average filter to highlight the different frequencies. I think the 4 month filter has a nice cycle between the years 1985 and 1992-ish and again from 1998 to the present. I used a 4, 18, and 60 month Hanning filter to the data.There are large missing stretches on my 60 month filter,that I am unsure about.

setwd("E:/spring16")
nhtl<-read.csv("uah.NH.TLS5.csv",header=TRUE)
anom<-nhtl$Series
date <- nhtl$Date.Decimal
ma4 <- filter(x=anom, filter=rep(x=1/4,times=4), sides=2)
ma12 <- filter(x=anom, filter=rep(x=1/12,times=12), sides=2)##year
ma48 <- filter(x=anom, filter=rep(x=1/48,times=48), sides=2)
par(tcl=0.5,mar=rep(3,4),mgp=c(1.1,0.1,0),xaxs="i")
plot(date,anom,type="l",xlab="Time",ylab="Degree C (Anoms.)",col="grey")
abline(h=1)
lines(date,ma4, col = "red", lwd = 2)
lines(date,ma12, col = "green", lwd = 2)
lines(date,ma48, col = "blue", lwd = 2)
axis(3);axis(4)
##hanning filters here 
library("dplR", lib.loc="~/R/win-library/3.2")
## Warning: package 'dplR' was built under R version 3.2.5

han4 <- hanning(anom,n=4)
han18 <- hanning(anom,n=18)
han60 <- hanning(anom,n=60)
par(tcl=0.5,mar=rep(3,4),mgp=c(1.1,0.1,0),xaxs="i")
plot(date,anom,type="l",xlab="Time",ylab="Degree c (Anoms.)",col="grey")
abline(h=1)
lines(date,han4, col = "red", lwd = 2)
lines(date,han18, col = "green", lwd = 2)
lines(date,han60, col = "blue", lwd = 2)
axis(3);axis(4)

Splines!!

I see a large difference between the two smaller splines and the larger one of 0.75. The two smaller ones seem very similar to me.

loe.05 <- loess(anom~date,span =0.05)$y
loe.33 <- loess(anom~date,span=0.33)$y
loe.75 <- loess(anom~date,span=0.75)$y
date2 <- date[-c(111,222,388)]
par(tcl=0.5,mar=rep(3,4),mgp=c(1.1,0.1,0),xaxs="i")
plot(date,anom,type="l",xlab="Time",ylab="Degree c (Anoms.)",col="grey")
abline(h=1)
lines(date2,loe.05, col = "red", lwd = 2.5)
lines(date2,loe.33, col = "green", lwd = 1.5)
lines(date2,loe.75, col = "blue", lwd = 0.5)
axis(3);axis(4)

Maybe not the best way to plot these data. Loess is nice in that I am able to see the ends of my data series. I am unsure if my code did what I intended; the lines all look the same regardless of smoothing degree…

12 month filter

anom.yr<- filter(x=anom, filter=rep(x=1,times=12), sides=1)
anom.Year <- anom.yr[seq(from=10,to=length(anom.yr),by=12)]
yyears=1979:2015
par(tcl=0.5,mar=rep(3,4),mgp=c(1.1,0.1,0),xaxs="i")
plot(yyears,anom.Year,type="h",xlab="Year",ylab="Degree C",col="green",lwd=3)
axis(3);axis(4)

Spectral analysis

Here we/I try to pull out the dominant cycles in three climate data sets. The ENSO has the shortest period of about 3.24 years. The PDO and AMO have much longer periods of about 50.6 and 67.9 years. I am going to speculate that these short and long climate patterns have far reaching affects on the biology of many organisms.

library(repmis)
## Warning: package 'repmis' was built under R version 3.2.5
githubURL <- "https://github.com/AndyBunn/TeachingData/raw/master/climate_Time_Series_Extravaganza.Rdata"
source_data(githubURL)
## Downloading data from: https://github.com/AndyBunn/TeachingData/raw/master/climate_Time_Series_Extravaganza.Rdata
## SHA-1 hash of the downloaded data file is:
## 5f5b467b42520fdfbb85cfc8a1fbcc45197e0e56
##  [1] "loti.ts"      "loti.zoo"     "ice.ts"       "ice.zoo"     
##  [5] "sealevel.ts"  "sealevel.zoo" "sunspots.ts"  "sunspots.zoo"
##  [9] "enso.ts"      "enso.zoo"     "amo.ts"       "amo.zoo"     
## [13] "pdo.ts"       "pdo.zoo"      "ohc.ts"       "ohc.zoo"     
## [17] "co2.ts"       "co2.zoo"
oceans3 <- cbind(ENSO=enso.ts,PDO=pdo.ts,AMO=amo.ts)
par(tcl=0.5,mar=rep(2.5,4),mgp=c(1.1,0.1,0),xaxs="i")
plot(oceans3,main="Three Ocean Patterns")

enso.spect<-spectrum(enso.ts,log="no")

library("spectral.methods")
## Warning: package 'spectral.methods' was built under R version 3.2.5
enso.new=calcFrequency(enso.ts, plot.periodogram = TRUE)
enso.new
## [1] 0.02572774

I browsed the internet and came across the package used above. It says the dominant frequency is 0.0257 when I divide that by 12 to put that in yearly terms it comes out to be about a 3 and a quarter year cycle.

pdo.spect<-spectrum(pdo.ts,log="no")

pdo.new=calcFrequency(pdo.ts,plot.periodogram = TRUE)
pdo.new
## [1] 0.001647732

Whoa! This suggests there is a dominant 50.6 year cycle. This is interesting that climate can have such long and short patterns in time.

amo.spect<-spectrum(amo.ts,log="no")

amo.new=print(calcFrequency(amo.ts,plot.periodogram = TRUE))
## [1] 0.001226862
amo.new
## [1] 0.001226862

This analysis suggests that there is a 67.9 year cycle ocean temp data. Pretty effing nifty, too bad we do not have a longer set a data to analyze. Also, the plot.periodogram = TRUE was plotting a periodogram of the data but in a different window. I am kinda sad it is not showing up in my r markdown document.