Commit 374846f7 authored by Jana Ulrich's avatar Jana Ulrich
Browse files

ignore .Rhistory ... files

parent 4a6aea3a
plot(dT,x,xlab = 'Temperaturdifferenz [°C]')
plot(NA,xlim=c(0,5),ylim = c(0,50))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [°C]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [°C]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
abline(lm(x~dT),col=4)
lm <- lm(x~dT)
abline(lm,col=4)
summary(lm)
0.2582*2
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=2,height=1.5,paper='special')
par(lwd=1,cex=1,las=1, mar=c(2.7,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=5,height=4,paper='special')
par(lwd=1,cex=1,las=1, mar=c(2.7,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=5,height=4,paper='special')
par(lwd=1,cex=1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4,paper='special')
par(lwd=1,cex=1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4,paper='special')
par(lwd=1,cex=1.2,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=5,bty='n')
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = 1:20,title = 'Messreihe',col = rainbow(40)[1:20],pch=20,ncol=7,bty='n')
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'Regressionsgerade'),title = 'Messreihe',col = c(rainbow(40)[1:20],4),pch=c(rep(20,20),0)
,ncol=7,bty='n',lty = c(rep(0,20),1))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'Reg.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4),pch=c(rep(20,20),0)
,ncol=7,bty='n',lty = c(rep(0,20),1))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'Reg.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4),pch=c(rep(NA,20),0)
,ncol=7,bty='n',lty = c(rep(0,20),1))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'Reg.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'Reg.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6,height=4.5,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(0,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(3,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.1,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(5,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.05,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(5,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.05,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(5,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('topleft',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
pdf('Dokumente/Lehre/IP_Protokoll/Vorlage/Bilder/Plot1.pdf',width=6.2,height=4.5,paper='special')
par(lwd=1,cex=1.05,las=1, mar=c(3.5,3.5,0.5,0.5),mgp=c(2.4,0.6,0))
plot(NA,xlim=c(0,5),ylim = c(5,50),xlab = 'Temperaturdifferenz [K]',ylab = 'Aufstiegshöhe [cm]')
for(i in 1:20){
points(dT[((i-1)*10+1):(i*10)],x[((i-1)*10+1):(i*10)],col=rainbow(40)[i],pch=20)
}
legend('top',legend = c(1:20,'R.'),title = 'Messreihe',col = c(rainbow(40)[1:20],4)
,pch=c(rep(20,20),NA)
,ncol=7,bty='n',lty = c(rep(0,20),1))
lm <- lm(x~dT)
abline(lm,col=4)
dev.off()
summary(lm)
4.025/3.3
(4.025-3.3)/4.025
(4.025-3.3)/4.025*100
rnorm(4,3,2)
rnorm(4,3,2)
rnorm(4,3,2)
wupper <- sf::st_read('/home/jana.ulrich/Dokumente/IDF/data/wupper_einzugsgebiet/wupperRiverBasin_utm.shp')$geometry
wupper <- sf::st_transform(wupper,'+proj=longlat +datum=WGS84 +no_defs')
load('/home/jana.ulrich/Dokumente/IDF/Estimating_IDF_curves_consistently/data/Wupper_stations_meta.RData') # stations
# study area
xmin <- 6.94
xmax <- 7.6
ymin <- 50.99
ymax <- 51.31
# DWD 1min
dwd.meta <- read.table(file='/home/jana.ulrich/Dokumente/IDF/data/1_min_meta_DWD.txt',header = TRUE,
fill = TRUE,row.names = NULL,sep = ';')
dwd.min.wupper <- dwd.meta[(dwd.meta$geoLaenge>=xmin & dwd.meta$geoLaenge<=xmax &
dwd.meta$geoBreite >= ymin & dwd.meta$geoBreite <= ymax),]
# DWD 10min
dwd.meta <- read.table(file='/home/jana.ulrich/Dokumente/IDF/data/10_min_meta_DWD.txt',header = TRUE,
fill = TRUE,row.names = NULL,sep = ';')
dwd.10min.wupper <- dwd.meta[(dwd.meta$geoLaenge>=xmin & dwd.meta$geoLaenge<=xmax &
dwd.meta$geoBreite >= ymin & dwd.meta$geoBreite <= ymax),]
# DWD 60min
dwd.meta <- read.table(file='/home/jana.ulrich/Dokumente/IDF/data/60_min_meta_DWD.txt',header = TRUE,
fill = TRUE,row.names = NULL,sep = ';')
dwd.60min.wupper <- dwd.meta[(dwd.meta$geoLaenge>=xmin & dwd.meta$geoLaenge<=xmax &
dwd.meta$geoBreite >= ymin & dwd.meta$geoBreite <= ymax),]
plot(wupper)
points(meta$lon[1:39],meta$lat[1:39],pch=2,cex=0.7,lwd=1)
points(meta$lon[40:45],meta$lat[40:45],pch=0,cex=0.9,lwd=1)
points(dwd.60min.wupper$geoLaenge,dwd.60min.wupper$geoBreite,pch=20)
points(dwd.10min.wupper$geoLaenge,dwd.10min.wupper$geoBreite,pch=20,col=3)
points(dwd.min.wupper$geoLaenge,dwd.min.wupper$geoBreite,pch=20,col=2)
View(dwd.60min.wupper)
is.element(dwd.min.wupper$Stations_id,dwd.60min.wupper$Stations_id)
is.element(dwd.60min.wupper$Stations_id,dwd.min.wupper$Stations_id)
dwd.60min.wupper$von_datum[!is.element(dwd.60min.wupper$Stations_id,dwd.min.wupper$Stations_id)]
1(60)
1/60
2^((1:10)/60)
2^(1:10)
2^(0:10)
2^(0:10)/60
20:7)
2^(0:7)
(1:7)*24
(1:6)*24
(1:5)*24
2^(0:7)/24
128/60
128/24
128/60
128*60
2^(seq(0,7000,length.out = 8))/60
sqrt(128*60)
2^(seq(0,80,length.out = 8))/60
2^80
log(128*60,base = 2)
seq(0,12,length.out = 8)
seq(0,12,length.out = 7)
2^(seq(0,12,length.out = 7))/60
2^(seq(0,14,length.out = 8))/60
2^(seq(0,14,length.out = 8))
DWD.ftp <- "ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate"
res <- c("min","day")
var <- c("1_minute/precipitation/historical","daily/more_precip/historical")
path <- paste(DWD.ftp,var,sep = "/")
#### meta file ####
filename <- c("ein_min_rr_Beschreibung_Stationen.txt","RR_Tageswerte_Beschreibung_Stationen.txt")
storage.dir <- "/net/scratch/janaulrich/PhD/data/"
metafile <- paste0(storage.dir,"temp/meta_DWD_Berlin_rr_",res,".txt")
# download meta files for minutely and hourly data in wupper area
for(i in 1:2){
download.file(url = paste(path[i],filename[i],sep = "/"),
destfile = metafile[i], quiet=TRUE)
}
# read meta files (not so easy because of white spaces in station names)
read.metaDWD <- function(metafile){
lines <- readLines(metafile, encoding="latin1")
meta <- t(sapply(lines[3:length(lines)],function(x){
line <- unlist(strsplit(x, split = " "))
line <- line[line!=""]
if(length(line > 8)){
line <- c(line[1:6],paste(line[7:(length(line)-1)],collapse=" "),line[length(line)])
}
return(line)
},USE.NAMES = FALSE))
meta <- as.data.frame(meta,stringsAsFactors = FALSE)
colnames(meta) <- c(unlist(strsplit(lines[1],split = " ")))
# convert numbers
for(name in c("Stations_id","Stationshoehe","geoBreite","geoLaenge")){
meta[,name] <- as.numeric(meta[,name])
}
# convert dates
for(name in c("von_datum","bis_datum")){
meta[,name] <- as.Date(meta[,name],format = "%Y%m%d")
}
# wanted stations (Berlin, Potsdam):
ber.stat <- c(399,427,430,433,3987)
meta.wupper <- meta[meta$Stations_id %in% ber.stat,]
return(meta.wupper)
}
meta.berlin.day <- read.metaDWD(metafile[2])
# find all relevant files
filenames <- RCurl::getURL(paste0(path[2],'/'),
ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE)
str(filenames)
filenames <- filenames[4:length(filenames)]
str(filenames)
# find all relevant files
filenames <- RCurl::getURL(paste0(path[2],'/'),
ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE)
filenames <- strsplit(filenames, "\n")[[1]]
filenames <- filenames[4:length(filenames)]
str(filenames)
# find all relevant files
filenames <- RCurl::getURL(paste0(path[2],'/'),
ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE)
filenames <- strsplit(filenames, "\n")[[1]]
head(filenames)
grepl(filenames,'.zip')
grepl('.zip',filenames)
filenames <- filenames[grepl('.zip',filenames)]
head(filenames)
station_info <- sapply(filenames, function(str){strsplit(str,"_")[[1]]}, USE.NAMES = FALSE)
View(station_info)
str(station_info)
str(station_info[1,])
str(station_info[3,])
# wanted stations (Berlin, Potsdam):
ber.stat <- c(399,427,430,433,3987)
filenames <- filenames[station_info[3,] %in% ber.stat]
filenames <- strsplit(filenames, "\n")[[1]]
filenames <- filenames[grepl('.zip',filenames)]
station_info <- sapply(filenames, function(str){strsplit(str,"_")[[1]]}, USE.NAMES = FALSE)
as.numeric(station_info[3,])
station_info[3,]
# find all relevant files
filenames <- RCurl::getURL(paste0(path[2],'/'),
ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE)
filenames <- strsplit(filenames, "\n")[[1]]
filenames <- filenames[grepl('.zip',filenames)]
station_info <- sapply(filenames, function(str){strsplit(str,"_")[[1]]}, USE.NAMES = FALSE)
station_info[3,]
as.numeric(station_info[3,])
which(as.numeric(station_info[3,]) %in% ber.stat)
filenames <- filenames[as.numeric(station_info[3,]) %in% ber.stat]
a*3
filenames
destdir
storage.dir
path[2]
paste(path[2],file,sep = '/')
paste(path[2],filenames[1],sep = '/')
# download and unzip files
download.ftp.day <- function(file){
temp.file <- paste0(storage.dir,'/temp/',file)
download.file(paste(path[2],file,sep = '/')
,destfile = temp.file, quiet=TRUE) # download
unzip(temp.file,exdir = paste0(storage.dir,'/temp/')) # unzip
unlink(temp.file) # delete zip file
}
lapply(filenames,download.ftp.day)
# read files
dir(path = paste0(storage.dir,'temp'),pattern = 'produkt_nieder_tag')
read.files.day <- function(file){
read.table(file,header = TRUE,sep = ';') # read files
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d%H%M",tz='UTC')
# return data.frame with station ID, start date, end date, precip
return(data.frame(stat=stat.data$STATIONS_ID,date=date,RR=stat.data$RS))
}
#read files
berlin.prec.day <- pbapply::pblapply(filenames,read.files.day)
# read files
filenames <- dir(path = paste0(storage.dir,'temp'),pattern = 'produkt_nieder_tag',full.names = TRUE)
#read files
berlin.prec.day <- pbapply::pblapply(filenames,read.files.day)
read.files.day <- function(file){
stat.data <- read.table(file,header = TRUE,sep = ';') # read files
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d%H%M",tz='UTC')
# return data.frame with station ID, start date, end date, precip
return(data.frame(stat=stat.data$STATIONS_ID,date=date,RR=stat.data$RS))
}
#read files
berlin.prec.day <- pbapply::pblapply(filenames,read.files.day)
str(berlin.prec.day)
file <- filenames[1]
stat.data <- read.table(file,header = TRUE,sep = ';') # read files
stat.data$MESS_DATUM
as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d")
read.files.day <- function(file){
stat.data <- read.table(file,header = TRUE,sep = ';') # read files
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d")
# return data.frame with station ID, start date, end date, precip
return(data.frame(stat=stat.data$STATIONS_ID,date=date,RR=stat.data$RS))
}
#read files
berlin.prec.day <- pbapply::pblapply(filenames,read.files.day)
df <- berlin.prec.day[[1]]
date.range <- range(df$date)
berlin.prec.day[[1]]$date
which(is.na(df$date))
df[91,]
df[90,]
df[92,]
filenames[1]
as.POSIXlt('1893-04-02')
berlin.prec.day[[1]]$date[91] <- as.POSIXlt('1893-04-01')
as.POSIXlt('1893-04-01')
as.POSIXlt('1893-04-02')
as.POSIXlt('1893-04-01')
as.POSIXlt('18930401',format = "%Y%m%d")
file <- filenames[1]
stat.data <- read.table(file,header = TRUE,sep = ';') # read files
date <- as.POSIXlt(stat.data$MESS_DATUM),
format = "%Y%m%d")
date <- as.POSIXlt(stat.data$MESS_DATUM,
format = "%Y%m%d")
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d")
date[91]
which(is.na(date))
date[91]
date
sum(is.na(date))
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d",tz='UTC')
date
which(is.na(date))
read.files.day <- function(file){
stat.data <- read.table(file,header = TRUE,sep = ';') # read files
# convert dates
date <- as.POSIXlt(as.character(stat.data$MESS_DATUM),
format = "%Y%m%d",tz='UTC')
# return data.frame with station ID, start date, end date, precip
return(data.frame(stat=stat.data$STATIONS_ID,date=date,RR=stat.data$RS))
}
#read files
berlin.prec.day <- pbapply::pblapply(filenames,read.files.day)
df <- berlin.prec.day[[1]]
date.range <- range(df$date,na.rm = )
date.range <- range(df$date)
date.seq <- seq(date.range[1],date.range[2],by='day')
RR <- rep(NA,length(date.seq))
RR[date.seq %in% df$date] <- df$RR
sum(is.na(RR))
## some dates are missing
# find missing dates and fill with NA:
find.missing <- function(df){
date.range <- range(df$date)
date.seq <- seq(date.range[1],date.range[2],by='day')
RR <- rep(NA,length(date.seq))
RR[date.seq %in% df$date] <- df$RR
df.out <- data.frame('stat'=df$stat[1],'date'=date.seq,'RR'=RR)
return(df.out)
}
berlin.prec.day <- pbapply::pblapply(berlin.prec.day,find.missing)
berlin.prec.day <- pbapply::pblapply(berlin.prec.day,
function(df){
df$RR[df$RR==-999] <- NA
return(df)})
lapply(berlin.prec.day,function(df){sum(is.na(df$RR))})
lapply(berlin.prec.day,
function(df){as.character(df$date[!is.na(df$RR)][1])})
View(meta.berlin.day)
# save meta file
saveRDS(meta.berlin.day,file = paste0(storage.dir,'/meta_DWD_RR_berlin_day.rds'))
# save meta file
saveRDS(meta.berlin.day,file = paste0(storage.dir,'/meta_DWD_RR_berlin_day.rds'))
# save daily precip file
saveRDS(berlin.prec.day,file = paste0(storage.dir,'/DWD_RR_berlin_day.rds'))
# delete downloaded files
unlink(paste0(storage.dir,'temp/*'),recursive = TRUE)
sqrt(NA)
setwd("~/Dokumente/IDF/IDF/R")
setwd("~/Dokumente/IDF/IDF")
devtools::check()
devtools::install()
......@@ -3,4 +3,4 @@
.RData
.Ruserdata
.Rbuildignore
.Rproj
*.Rproj
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment