################ ##RATPAC-A TROPICAL ################## ####ftp://ftp.ncdc.noaa.gov/pub/data/ratpac/ratpac-a/RATPAC-A-annual-levels.txt ##Get Annual Information # see examination of files in radiosonde/ratpac.txt #20S- 20N is not updated to 2009 get.ratpac.trp=function(zone="TROPICS (30S- 30N)" ) { url="ftp://ftp.ncdc.noaa.gov/pub/data/ratpac/ratpac-a/RATPAC-A-annual-levels.txt" #this is annual 1958-2008 #NH,SH, Trop, NH Extra, SH Extra # surf 850 700 500 400 300 250 200 150 100 70 50 30 fred=readLines(url) temp=(substr(fred,1,4)=="year") index=(1:length(fred))[temp] # 2 55 108 161 214 267 320 # fred[(index[4]-1):(index[5]-2)] ratpac=rep(list(NA),length(index));K=length(index) names(ratpac)=substr(fred[index-1],2,nchar(fred[index-1])) names(ratpac)=gsub(" $+","",names(ratpac) ) name2=scan(url,skip=1,n=14,what="") index=c(index,length(fred)+1) for (i in 1:K) { ratpac[[i]]=read.table(url,skip=index[i],nrow= index[i+1]-index[i]-2) names(ratpac[[i]])=name2 temp=(ratpac[[i]] ==999);ratpac[[i]][temp]=NA } names(ratpac) #[1] "NH" "SH" "GLOBE" "TROPICS (30S- 30N)" "NH Extratropics " # [6] "SH Extratropics " "TROPICS (20S-20N)" ratpac[[7]][1:2,] # year surf 850 700 500 400 300 250 200 150 100 70 50 30 #1 1958 0.08 0.33 0.43 0.41 0.45 0.28 0.23 0.02 -0.16 0.22 0.14 0.20 0.53 #2 1959 -0.01 0.10 -0.03 -0.01 -0.08 -0.36 -0.30 -0.26 -0.12 0.30 1.01 1.21 1.16 sapply( ratpac, function(A) range(A$year) ) # 1958 2008 # NH SH GLOBE TROPICS (30S- 30N) NH Extratropics SH Extratropics TROPICS (20S-20N) #[1,] 1958 1958 1958 1958 1958 1958 1958 #[2,] 2009 2009 2009 2009 2009 2009 2008 ratpac.trp=ts(ratpac[[paste(zone)]],start=1958) ratpac_t2lt.trp= apply(ratpac.trp[,c("850","700")],1, function(x) weighted.mean(x,c(.33,.67)) ) ratpac_t2lt.trp=ts (ratpac_t2lt.trp,start=1958,freq=1) #### ANNUAL ******* ratpac_t2lt.trp= window(ratpac_t2lt.trp,end= max(time(ratpac_t2lt.trp)[!is.na(ratpac_t2lt.trp)]) ) return(ratpac_t2lt.trp) } # ratpac.trp= get.ratpac.trp()