13 - use case: longest time series in Berlin

13.1 select station

Choose station in Berlin with longest monthly average recordings (according to metadata, which is not always correct).

ids <- findID("Berlin", exactmatch=FALSE)
head(ids)
##      Berlin-Adlershof Berlin-Alexanderplatz           Berlin-Buch 
##                   395                   399                   400 
## Berlin-Charlottenburg    Berlin-Dahlem (FU)  Berlin-Dahlem (LFAG) 
##                   401                   403                   402
data("metaIndex")
berlin <- metaIndex[with(metaIndex, 
              Stations_id %in% ids & res=="monthly" & var=="kl" & per=="historical"),]
berlin$ndays <- as.numeric(berlin$bis_datum - berlin$von_datum)
berlin <- berryFunctions::sortDF(berlin, ndays)
berlin$von_datum <- as.character(berlin$von_datum) # avoid huxtable error
berlin$bis_datum <- as.character(berlin$bis_datum)
berlin # Dahlem (FU) has data since 1719 !
Stations_idvon_datumbis_datumStationshoehegeoBreitegeoLaengeStationsnameBundeslandresvarperhasfilendays
4031719-01-012020-08-315152.513.3 Berlin-Dahlem (FU)BerlinmonthlyklhistoricalTRUE1.1e+05 
4021830-01-011962-12-315552.513.3 Berlin-Dahlem (LFAG)BerlinmonthlyklhistoricalTRUE4.86e+04
4291890-07-011987-01-313252.613.2 Berlin-SpandauBerlinmonthlyklhistoricalTRUE3.53e+04
4331938-01-012020-08-314852.513.4 Berlin-TempelhofBerlinmonthlyklhistoricalTRUE3.02e+04
4001951-01-012020-08-316052.613.5 Berlin-BuchBerlinmonthlyklhistoricalTRUE2.54e+04
4081883-01-011951-11-303552.513.4 Berlin-InvalidenstrasseBerlinmonthlyklhistoricalTRUE2.52e+04
4271957-01-012020-08-314652.413.5 Berlin-SchoenefeldBrandenburgmonthlyklhistoricalTRUE2.33e+04
4301961-01-012020-08-313652.613.3 Berlin-TegelBerlinmonthlyklhistoricalTRUE2.18e+04
51381945-01-012003-12-3144647.89.16Ueberlingen/BodenseeBaden-WuerttembergmonthlyklhistoricalTRUE2.15e+04
4351964-01-012006-12-314552.413.2 Berlin-ZehlendorfBerlinmonthlyklhistoricalTRUE1.57e+04
3991975-01-012015-05-313652.513.4 Berlin-AlexanderplatzBerlinmonthlyklhistoricalTRUE1.48e+04
4251946-01-011982-06-303852.413.5 Berlin-RudowBerlinmonthlyklhistoricalTRUE1.33e+04
4201993-05-012020-08-316052.513.6 Berlin-MarzahnBerlinmonthlyklhistoricalTRUE9.98e+03
4241954-01-011980-12-313652.513.5 Berlin-OstkreuzBerlinmonthlyklhistoricalTRUE9.86e+03
4171930-09-011956-10-314352.413.3 Berlin-Lichterfelde (Sued)BerlinmonthlyklhistoricalTRUE9.56e+03
4101996-06-012020-05-313352.413.7 Berlin-KaniswallBerlinmonthlyklhistoricalTRUE8.76e+03
4071958-01-011978-03-314852.613.3 Berlin-FrohnauBerlinmonthlyklhistoricalTRUE7.39e+03
4321978-04-011994-12-313652.613.3 Berlin-Tegeler FliesstalBerlinmonthlyklhistoricalTRUE6.12e+03
4161982-07-011996-09-304752.413.4 Berlin-LichtenradeBerlinmonthlyklhistoricalTRUE5.2e+03 
4341947-01-011960-12-313552.513.5 Berlin-TreptowBerlinmonthlyklhistoricalTRUE5.11e+03
4221956-01-011964-12-313552.513.4 Berlin-MitteBerlinmonthlyklhistoricalTRUE3.29e+03
3951948-07-011953-12-313852.413.5 Berlin-AdlershofBerlinmonthlyklhistoricalTRUE2.01e+03
4051951-04-011954-12-313752.513.6 Berlin-FriedrichshagenBerlinmonthlyklhistoricalTRUE1.37e+03

13.2 download and inspect data

url <- selectDWD("Berlin-Dahlem (FU)", res="monthly", var="kl", per="h")
kl <- dataDWD(url, varnames=TRUE, dir="../localdata")
plot(kl$MESS_DATUM, kl$MO_TT.Lufttemperatur, type="l", las=1) # pretty complete

13.3 aggregates by month

monthly <- tapply(kl$MO_TT.Lufttemperatur, format(kl$MESS_DATUM,"%m"), quantile, probs=0:10/10)
monthly <- sapply(monthly, I)

plot(1, type="n", xlim=c(1,12), ylim=range(monthly), xaxt="n", las=1, 
     xlab="Vis by Berry B, github.com/brry/rdwd", ylab="monthly temperature average",
     main="Temperature variation in Berlin is highest in winter")
axis(1, 2:12-0.5, labels=FALSE)
axis(1, 1:12, substr(month.abb,1,1), tick=FALSE, line=-0.5)
for(m in 1:12) for(q in 1:5) lines(c(m,m), monthly[c(q,12-q),m], lend=1, 
                                   col=berryFunctions::addAlpha("red",0.2), lwd=5)
for(m in 1:12) points(m, mean(monthly[,m]), pch=3)