# NOT RUN {
# Excluded from CRAN checks, but run in localtests
# File selection and download:
datadir <- localtestdir()
radbase <- paste0(gridbase,"/hourly/radolan/historical/asc/")
radfile <- "2018/RW-201809.tar" # 25 MB to download
file <- dataDWD(radfile, base=radbase, joinbf=TRUE, dir=datadir,
dfargs=list(mode="wb"), read=FALSE) # download with mode=wb!!!
#asc <- readDWD(file) # 4 GB in mem. ~ 20 secs unzip, 30 secs read, 10 min divide
asc <- readDWD(file, selection=1:5, dividebyten=TRUE)
asc <- projectRasterDWD(asc)
raster::plot(asc[[1]], main=names(asc)[1])
addBorders()
rng <- range(raster::cellStats(asc, "range"))
nframes <- 3 # raster::nlayers(asc) for all (time intensive!)
viddir <- paste0(tempdir(),"/RadolanVideo")
dir.create(viddir)
png(paste0(viddir,"/Radolan_%03d.png"), width=7, height=5, units="in", res=300)
dummy <- pbsapply(1:nframes, function(i)
raster::plot(asc[[i]], main=names(asc)[i], zlim=rng)) # 3 secs per layer
dev.off()
berryFunctions::openFile(paste0(viddir,"/Radolan_001.png"))
# Time series of a given point in space:
plot(as.vector(asc[800,800,]), type="l", xlab="Time [hours]")
# if dividebyten=FALSE, raster stores things out of memory in the exdir.
# by default, this is in tempdir, hence you would need to save asc manually:
# raster::writeRaster(asc, paste0(datadir,"/RW2018-09"), overwrite=TRUE)
# }
Run the code above in your browser using DataCamp Workspace