#ftp://ice.ssec.wisc.edu/pub/aws/climate #MAKE INTERIM INFO #this is done manually by inspecting each directory year=1987:2002;N=length(year) info=rep(list(NA),N);names(info)=year info[[paste(1987)]]= c(8900:8928) info[[paste(1988)]]= c(8900:8931) info[[paste(1989)]]= c(8900:8931) info[[paste(1990)]]= c(8900:8933) info[[paste(1991)]]= c(8900:8937,8947,8980:8980) info[[paste(1992)]]= c(8900:8937,8947,8980:8984) info[[paste(1993)]]= c(8900:8937,8947,8980:8986) info[[paste(1994)]]= c(1355:1362,8900:8939,8947,8980:8988) info[[paste(1995)]]= c(1355:1364,8900:8939,8947,8980:8989) info[[paste(1996)]]= c(1355:1364,8900:8939,8947,8980:8988) info[[paste(1997)]]= c(1355:1364,8900:8939,8947,8980:8988) info[[paste(1998)]]= c(1355:1364,8697,8722,8900:8939,8947,8980:8988) info[[paste(1999)]]= c(1355:1364,8697,8722,8900:8939,8947,8980:8988) info[[paste(2000)]]= c(1355:1364,8697,8722,8900:8939,8947,8980:8988) info[[paste(2001)]]= c(8903,8938) info[[paste(2002)]]= c(8903,8938) #read data from files wisc=rep(list(NA),N);names(wisc)=year for( i in 2:N) { K=length(info[[i]]) wisc[[i]]=rep(list(NA),K);names(wisc[[i]])=info[[i]] for (j in 1:K) { loc=paste("ftp://ice.ssec.wisc.edu/pub/aws/climate/",year[i],"/climo",info[[i]][j],"_",year[i],".dat",sep="") wisc[[i]][[j]]=try(readLines(loc)) } } sapply(wisc[[1]],class) #failed read is try-error for(i in 1:N) { test=sapply(wisc[[i]],class) temp= (test=="try-error") info[[i]]=info[[i]][!temp] wisc[[i]]=wisc[[i]][!temp] } sapply(wisc,length) #1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 # 28 29 28 32 32 39 39 47 50 52 48 46 52 52 2 2 #make details summary details=NULL for(i in 1:N) { test=data.frame(rep(year[i],length(wisc[[i]])), names(wisc[[i]]), sapply(wisc[[i]],function(A) A[1]) ) names(test)=c("year","id","info") details=rbind(details,test) } nrow(details) #[1] 578 details[sort(c(grep("Harry",details$info), grep("HARRY",details$info))) ,] #1355 1994 1355 Station Argos ID: 1355 Station Name: Harry Year: 1994 #13551 1995 1355 Station Argos ID: 1355 Station Name: Harry Year: 1995 #13552 1996 1355 Station Argos ID: 1355 Station Name: Harry Year: 1996 #890012 1999 8900 Station Argos ID: 8900 Station Name: Harry Year: 1999 #890013 2000 8900 Station Argos ID: 8900 Station Name: Harry Year: 2000 details[sort(c(grep("Gill",details$info), grep("GILL",details$info))) ,] #8925 1987 8925 Station Argos ID: 8925 Station Name: GILL Year: 1987 89251 1988 8925 Station Argos ID: 8925 Station Name: GILL Year: 1988 89252 1989 8925 Station Argos ID: 8925 Station Name: GILL Year: 1989 89114 1991 8911 Station Argos ID: 8911 Station Name: GILL Year: 1991 89115 1992 8911 Station Argos ID: 8911 Station Name: GILL Year: 1992 89116 1993 8911 Station Argos ID: 8911 Station Name: GILL Year: 1993 89117 1994 8911 Station Argos ID: 8911 Station Name: Gill Year: 1994 89118 1995 8911 Station Argos ID: 8911 Station Name: Gill Year: 1995 89119 1996 8911 Station Argos ID: 8911 Station Name: Gill Year: 1996 891110 1997 8911 Station Argos ID: 8911 Station Name: Gill Year: 1997 891111 1998 8911 Station Argos ID: 8911 Station Name: Gill Year: 1998 891112 1999 8911 Station Argos ID: 8911 Station Name: Gill Year: 1999 891113 2000 8911 Station Argos ID: 8911 Station Name: Gill Year: 2000 details.wisc=details save(details,file="d:/climate/data/steig/details.wisc.tab") save(wisc,file="d:/climate/data/steig/wisc.tab")