Exercise time series analysis and plotting

Felix Cremer, Fabian Gans

Max Planck Institute for Biogeochemistry
NFDI4Earth Advancing Tools

Aim of the exercise session

Dataset

Possible time series analyses

  • Dryness Index moving average tp - pet
  • mean seasonal cycle
  • median seasonal cycle
  • Leap years
  • FFT
  • RQA
  • Histogram per decade
# Data loading
using DataFrames
using CSV
jena = CSV.read("examples/data/jena.csv", DataFrame)
t2mmints = jena[!, :Variable_t2mmin]
datets = jena[!, :]

Mean seasonal cycle

function yearhistsview(ts, dates)
    years = unique(year.(jena.Ti))
    yearbins = []
    for y in years 
        ybegin = findfirst(x->year(x)==y, dates)
        ylast = findlast(x-> year(x)==y, dates)
        ydata = view(ts,ybegin:ylast)
        push!(yearbins, ydata)
    end
end

yearbins = yearhist(jena.Variable_t2m, jena.Ti)
dts_clim = DateTime(2020, 1, 1, 0):Day(1):DateTime(2020, 12, 31, 23)

t2m_clim = zeros(length(dts_clim))

@time begin

for (i, dt) in enumerate(dts_clim)

    t2m_clim[i] = mean(view(t2m_jena, dayofyear(dt) .== dayofyear.(dts_jena)))

end

end

@time begin

for (i, dt) in enumerate(dts_clim)

    t2m_clim[i] = mean(view(t2m_jena, dayofyear(dt) .== dayofyear.(dts_jena)))

end

end

Plotting

using GLMakie
plot(jena.Ti, t2mmints)