[: Linux]
R NetCDF (http://www.metoffice.gov.uk/hadobs/hadisst/data/HadISST_sst.nc.gz). "" , :
library(raster)
library(xts)
library(caTools)
:
startYear <- 1950
endYear <- 2011
subp <- '1951-01-01/1980-12-01'
:
sst <- brick('HadISST_sst.nc')
Date <- substr(names(sst),2,11)
Date <- gsub('\\.', '\\-', Date)
Date <- as.Date(Date)
dstart <- paste(startYear,'01','01',sep='-'); dstart <- grep(dstart, Date)
dend <- paste(endYear,'12','01',sep='-'); dend <- grep(dend, Date)
sst <- subset(sst, dstart:dend)
Date <- Date[dstart:dend]
(lat = 35, lon = 120):
tserie <- as.vector(extract(sst, cbind(116, -35)))
tserie <- xts(tserie, order.by=Date)
:
clim <- as.numeric()
for(ii in 1:12){
clim[ii] <- mean(tserie[subp][(.indexmon(tserie[subp])+1) == ii])
}
clim <- xts(rep(clim, length(tserie)/12), order.by=Date)
:
tserie <- tserie - clim
:
par(las=1)
plot(tserie, t='n', main='HadISST')
lines(tserie, col='grey')
lines(xts(runmean(tserie, 12), order.by=Date), col='red', lwd=2)
legend('bottomleft', c('Monthly anomaly','12-month moving avg'), lty=c(1,1), lwd=c(1,2), col=c('grey','red'))