##12 CRU NH #potential target 1961-1990 #http://www.cru.uea.ac.uk/cru/data/temperature/crutem3nh.txt #http://www.metoffice.gov.uk/hadobs/crutem3/diagnostics/hemispheric/northern/ get.crutem=function(dset="cru",hemi="nh",annual=FALSE) { if(dset=="cru") { url<-paste("http://www.cru.uea.ac.uk/cru/data/temperature/crutem3",hemi,".txt",sep="") #1850 2008 h<-scan(url) start0<-h[1] N<-length(h) h<-array(h,dim=c(27,N/27)) h<-t(h) crutem3=ts(c(t(h[,2:13])),start=c(1850,1),freq=12) temp=(crutem3==0)&(time(crutem3)>=floor(tsp(crutem3)[2])) crutem3[temp]=NA if(annual) crutem3<-ts(h[,14],start=start0) #1850 - crutem3=window(crutem3,end=max( time(crutem3)[!is.na(crutem3)]) ) return(crutem3) } if(dset=="had") { alias=c(gl="global/nh+sh",nh="hemispheric/northern", sh="hemispheric/southern") url=paste("http://hadobs.metoffice.com/crutem3/diagnostics/",alias[hemi],"/nh+sh/monthly",sep="") D=read.table(url) #dim(D) #158 12 #start 1850 names(D)=c("mm","anom","u_sample","l_sample","u_coverage","l_coverage","u_bias","l_bias","u_sample_cover","l_sample_cover", "u_total","l_total") N=nrow(D) D$year=as.numeric(substr(D$mm,1,4)) D$month=as.numeric(substr(D$mm,6,7)) D$mm=100*D$year+D$month if (sum( !is.na(match( diff(D$month),c(1,-11))) ) ==0 ) crutem3=ts(D[,2],start=c(1850,1),freq=12) else { x=ts(NA,start=c(1850,1),end=c(D$year[N],D$month[N]),freq=12) M=length(x);month= (1:M)%%12; month[month==0]=12;year=floor(time(x)) timegrid= 100*year+month test=match(timegrid,D$mm);temp=!is.na(test) x[temp]=D$anom[test[temp]] crutem3=x } if(annual) crutem3=annavg(crutem3) return(crutem3) } } # # crutem=get.crutem.hemi(dset="cru",hemi="nh",annual=TRUE) # crutem[["had"]]=get.crutem.glb(dset="had") # cru=ts.union(crutem[[1]],crutem[[2]]) # plot.ts(cru[,1]-cru[,2])