18 - use case: longest time series in Berlin

18.1 select station

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

rdwd::updateRdwd()
library(rdwd)
ids <- findID("Berlin", exactmatch=FALSE)
head(ids)
##      Berlin-Adlershof Berlin-Alexanderplatz       Berlin-Biesdorf 
##                   395                   399                 17471 
##   Berlin-Blankenfelde    Berlin-Borsigwalde          Berlin-Britz 
##                 17491                 17484                 17462
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_datumStationshoehegeoBreitegeoLaengeStationsnameBundeslandAbgaberesvarperhasfilendays
4031719-01-012025-04-305152.513.3 Berlin-Dahlem (FU)BerlinFreimonthlyklhistoricalTRUE1.12e+05
4001889-01-012025-04-306052.613.5 Berlin-BuchBerlinFreimonthlyklhistoricalTRUE4.98e+04
4021830-01-011962-12-315552.513.3 Berlin-Dahlem (LFAG)BerlinFreimonthlyklhistoricalTRUE4.86e+04
4291890-07-011987-01-313252.613.2 Berlin-SpandauBerlinFreimonthlyklhistoricalTRUE3.53e+04
4331938-01-012025-04-304852.513.4 Berlin-TempelhofBerlinFreimonthlyklhistoricalTRUE3.19e+04
4241901-01-011980-12-313652.513.5 Berlin-OstkreuzBerlinFreimonthlyklhistoricalTRUE2.92e+04
31471951-03-012025-04-3039048.812.2 Mallersdorf-Pfaffenberg-OberlindhartBayernFreimonthlyklhistoricalTRUE2.71e+04
4221892-01-011964-12-313552.513.4 Berlin-MitteBerlinFreimonthlyklhistoricalTRUE2.67e+04
4081883-01-011951-11-303552.513.4 Berlin-InvalidenstrasseBerlinFreimonthlyklhistoricalTRUE2.52e+04
4271957-01-012025-04-304652.413.5 Berlin BrandenburgBrandenburgFreimonthlyklhistoricalTRUE2.5e+04 
4301961-01-012021-04-303652.613.3 Berlin-TegelBerlinFreimonthlyklhistoricalTRUE2.2e+04 
51381945-01-012003-12-3144647.89.16Ueberlingen/BodenseeBaden-WuerttembergFreimonthlyklhistoricalTRUE2.15e+04
4351964-01-012006-12-314552.413.2 Berlin-ZehlendorfBerlinFreimonthlyklhistoricalTRUE1.57e+04
3991975-01-012015-05-313652.513.4 Berlin-AlexanderplatzBerlinFreimonthlyklhistoricalTRUE1.48e+04
4251946-01-011982-06-303852.413.5 Berlin-RudowBerlinFreimonthlyklhistoricalTRUE1.33e+04
4201993-05-012023-07-316152.513.6 Berlin-MarzahnBerlinFreimonthlyklhistoricalTRUE1.1e+04 
4171930-09-011956-10-314352.413.3 Berlin-Lichterfelde (Sued)BerlinFreimonthlyklhistoricalTRUE9.56e+03
4101996-06-012020-05-313352.413.7 Berlin-KaniswallBerlinFreimonthlyklhistoricalTRUE8.76e+03
4071958-01-011978-03-314852.613.3 Berlin-FrohnauBerlinFreimonthlyklhistoricalTRUE7.39e+03
4321978-04-011994-12-313652.613.3 Berlin-Tegeler FliesstalBerlinFreimonthlyklhistoricalTRUE6.12e+03
4161982-07-011996-09-304752.413.4 Berlin-LichtenradeBerlinFreimonthlyklhistoricalTRUE5.2e+03 
4341947-01-011960-12-313552.513.5 Berlin-TreptowBerlinFreimonthlyklhistoricalTRUE5.11e+03
3951948-07-011953-12-313852.413.5 Berlin-AdlershofBerlinFreimonthlyklhistoricalTRUE2.01e+03
4051951-04-011954-12-313752.513.6 Berlin-FriedrichshagenBerlinFreimonthlyklhistoricalTRUE1.37e+03

18.2 download and inspect data

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

18.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)