R is able to read NetCDF format
(http://www.metoffice.gov.uk/hadobs/hadisst/data/HadISST_sst.nc.gz).
In order to read such data you can use the "raster" package, after decompression, such as:
library(raster)
library(xts)
library(caTools)
Some time definitions:
startYear <- 1950 # starting period
endYear <- 2011 # end of the period
subp <- '1951-01-01/1980-12-01' # period for the climatology calculation
Open the file:
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]
Now, extract the time series for a specific point (lat=35, lon=120):
tserie <- as.vector(extract(sst, cbind(116, -35)))
tserie <- xts(tserie, order.by=Date)
Calculate the climatology for the subp period:
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)
Calculate anomalies:
tserie <- tserie - clim
Plot the result:
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'))