##UPDATE ERSST DATA ## ERSST two degree cells ## ## ERSST v2 ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/V2/sst.ltm.19712000.nc ## JAn 2, 2009: last updated in May ## ERSST v3 ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/ ## ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.mnmean.nc # versions: 2, 3A, 3B Note that V3 is now the official version. V2 will no longer be updated. #It will still be available in our subdirtectory /Datasets/noaa.ersst/V2/ #http://www.ncdc.noaa.gov/oa/climate/research/sst/ersstv3.php). # * 2.0 degree latitude x 2.0 degree longitude global grid (89x180). # 88.0N - 88.0S, 0.0E - 358.0E. ####INFORMATION ##http://www.ncdc.noaa.gov/oa/climate/research/sst/ersstv3.php #http://www.cdc.noaa.gov/cdc/data.noaa.ersst.html #http://lwf.ncdc.noaa.gov/oa/climate/research/sst/sst.html. get.ersst.trp=function(url_normal= "ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.ltm.19712000.nc", url="ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.mnmean.nc" ,index_var=2) { #default is ersst3 #download normals download.file(url_normal,"temp.nc",mode="wb") #60 MB test=open.ncdf("temp.nc") climat <- get.var.ncdf( test, test$var[[index_var]] );dim(climat) #180 89 12 #180 89 12 #image.plot(seq(0,358,2),seq(-88,88,2),climat[,89:1,3],col=tim.colors(39),breaks=seq(-3,36,1)) climat=aperm(climat[,35:55,],c(3,1,2)) ;dim(climat) #12 180 21 climat=array(climat,dim=c(12,180*21));dim(climat) #12 3780 climat=c(climat);length(climat) #45360 MM second Long minute Lat hour #download data download.file(url,"temp.nc",mode="wb") #60 MB test=open.ncdf("temp.nc") sst <- get.var.ncdf( test, test$var[[index_var]] ) #180 89 dim(sst) #[1] 180 89 1864 #1854/1 to 2009/4 #2 deg longitude and 2 deg Lat # 88.0N - 88.0S, 0.0E - 358.0E http://www.cdc.noaa.gov/data/gridded/data.noaa.ersst.html temp=(sst< -9.9);sum(temp,na.rm=T);sst[temp]=NA #make TRP subset h= function(lat) 45+ (-lat)/2 #centered even cells ? #h(seq(18,-18,-2)) #36 to 54 #dim(sst) #180 89 1864 x=sst[1,45,];# plot.ts(x) #x[seq(1,1201,12)] # [1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 #[13] 27.35 27.04 27.11 27.56 27.71 26.87 27.70 27.47 27.11 26.96 27.80 27.37 sst=aperm(sst[,35:55,],c(3,1,2)) ;dim(sst) #1864 180 21 #the tropics (gridcell centers 20S to 20N) have j-indices from 35-55 #sst[seq(1,1201,12),1,11] #[1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 dim0=dim(sst);dim0 #1864 180 21 #make anomalies sst= array(sst,dim=c(dim0[1],180*21)) #1864 3780 N=dim(sst)[1];N #1864 dummy=array(NA,dim=c(12- N%%12,180*21) ) sst=rbind(sst,dummy);dim(sst) #1872 3780 N=nrow(sst) sst=array(sst,dim=c(12,N/12,3780)) #12 156 3780 #sst[1,,180*(11-1)+1] # [1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 sst=aperm(sst,c(2,1,3)) #sst[,1,180*(11-1)+1] # [1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 sst=array(sst,dim=c(N/12,12*3780)) #156 45360 #sst[,(180*(11-1)) *12+1] # [1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 #dim(sst) # 156 45360 sst=scale(sst,center=climat,scale=FALSE);dim(sst)#156 45360 #center using normals sst[,(180*(11-1)) *12+1] # [1] -0.23 -1.18 -0.70 -0.97 -1.28 -0.87 -0.62 -0.46 -0.81 -0.79 -0.60 -0.53 #now re-configure to original shape sst=array(sst,dim=c(N/12,12,3780));dim(sst) # 155 12 3780 #sst[,1,180*(11-1)+1] # 156 12 3780 # [1] -0.23 -1.18 -0.70 -0.97 -1.28 -0.87 -0.62 -0.46 -0.81 -0.79 -0.60 -0.53 sst=aperm(sst,c(2,1,3));dim(sst)# 12 156 3780 #sst[1,,180*(11-1)+1] # [1] -0.23 -1.18 -0.70 -0.97 -1.28 -0.87 -0.62 -0.46 -0.81 -0.79 -0.60 -0.53 sst=array(sst,dim=c(N,3780));dim(sst) #1872 3780 #sst[seq(1,1201,12),180*(11-1)+1] # [1] -0.23 -1.18 -0.70 -0.97 -1.28 -0.87 -0.62 -0.46 -0.81 -0.79 -0.60 -0.53 get.ersst.trp=ts(apply(sst,1,mean,na.rm=T),start=c(1854,1),freq=12) get.ersst.trp } get.climat=function(url_normal= "ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.ltm.19712000.nc") { download.file(url_normal ,"temp.nc",mode="wb") #60 MB test=open.ncdf("temp.nc") climat <- get.var.ncdf( test, test$var[[2]] );dim(climat) #180 89 12 #180 89 12 #image.plot(seq(0,358,2),seq(-88,88,2),climat[,89:1,3],col=tim.colors(39),breaks=seq(-3,36,1)) climat=aperm(climat,c(3,1,2)) ;dim(climat) #12 180 21 climat=array(climat,dim=c(12,180*89));dim(climat) #12 3780 return(climat) } get.ersst =function(url_normal= "ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.ltm.19712000.nc", url="ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.mnmean.nc" ,index_var=2,) { #default is ersst3 #download normals #download data download.file(url,"temp.nc",mode="wb") #60 MB test=open.ncdf("temp.nc") sst <- get.var.ncdf( test, test$var[[index_var]] ) #180 89 dim(sst) #[1] 180 89 1864 #1854/1 to 2009/4 #2 deg longitude and 2 deg Lat # 88.0N - 88.0S, 0.0E - 358.0E http://www.cdc.noaa.gov/data/gridded/data.noaa.ersst.html temp=(sst< -9.9);sum(temp,na.rm=T);sst[temp]=NA sst=aperm(sst,c(3,1,2)) ;dim(sst) #1864 180 21 #the tropics (gridcell centers 20S to 20N) have j-indices from 35-55 #sst[seq(1,1201,12),1,11] #[1] 27.69 26.74 27.22 26.95 26.64 27.05 27.30 27.46 27.11 27.13 27.32 27.39 dim0=dim(sst);dim0 #1864 180 21 #1854/1 to 2009/4 sst=array(sst,dim=c(dim0[1],dim0[2]*dim0[3]) );dim(sst) #1866 16020 sst=ts(sst,start=1854,freq=12);tsp(sst) sst=window(sst,start=1961) return(sst=sst,climat=climat) } ##ERSST v3 #inspect ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst # x=get.ersst.trp (url_normal= "ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.ltm.19712000.nc", # url="ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/sst.mnmean.nc" ,index_var=2) #updated 6/29 # ersstv3.trp=window(x,end=max( time(x)[!is.na(x)]) ) ##ERSST v2 #3 ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/V2 #x= get.ersst.trp (url_normal="ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/V2/sst.ltm.19712000.nc", # url="ftp://ftp.cdc.noaa.gov/Datasets/noaa.ersst/V2/sst.mnmean.nc")