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

ids <- findID("Berlin", exactmatch=FALSE)
head(ids)
##    Berlin (Rosenthal)    Berlin Brandenburg      Berlin-Adlershof 
##                   394                   427                   395 
## Berlin-Alexanderplatz       Berlin-Biesdorf   Berlin-Blankenfelde 
##                   399                 17471                 17491
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-012024-04-305152.513.3 Berlin-Dahlem (FU)BerlinmonthlyklhistoricalTRUE1.12e+05
4001889-01-012024-04-306052.613.5 Berlin-BuchBerlinmonthlyklhistoricalTRUE4.94e+04
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-012024-04-304852.513.4 Berlin-TempelhofBerlinmonthlyklhistoricalTRUE3.15e+04
4241901-01-011980-12-313652.513.5 Berlin-OstkreuzBerlinmonthlyklhistoricalTRUE2.92e+04
31471951-03-012024-04-3039048.812.2 Mallersdorf-Pfaffenberg-OberlindhartBayernmonthlyklhistoricalTRUE2.67e+04
4221892-01-011964-12-313552.513.4 Berlin-MitteBerlinmonthlyklhistoricalTRUE2.67e+04
4081883-01-011951-11-303552.513.4 Berlin-InvalidenstrasseBerlinmonthlyklhistoricalTRUE2.52e+04
4271957-01-012024-04-304652.413.5 Berlin BrandenburgBrandenburgmonthlyklhistoricalTRUE2.46e+04
4301961-01-012021-04-303652.613.3 Berlin-TegelBerlinmonthlyklhistoricalTRUE2.2e+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-012023-07-316152.513.6 Berlin-MarzahnBerlinmonthlyklhistoricalTRUE1.1e+04 
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.20e+03
4341947-01-011960-12-313552.513.5 Berlin-TreptowBerlinmonthlyklhistoricalTRUE5.11e+03
3951948-07-011953-12-313852.413.5 Berlin-AdlershofBerlinmonthlyklhistoricalTRUE2.01e+03
4051951-04-011954-12-313752.513.7 Berlin-FriedrichshagenBerlinmonthlyklhistoricalTRUE1.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)