Pseudoensemble

The Pseudoensemble data structure is illustrated using the unobserved riverflows at an ungauged section of the Chaudière River in Québec from 1960 to 2020.

Load the data

Loading the pseudo-observations into an object of type Pseudoensemble:

filename = "SLSO00003"
pensemble = ErrorsInVariablesExtremes.load_discharge_distribution(filename)
6-element Vector{Pseudodata}:
 Pseudodata:
  name: LN24HA
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

 Pseudodata:
  name: MG24HA
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

 Pseudodata:
  name: MG24HI
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

 Pseudodata:
  name: MG24HK
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

 Pseudodata:
  name: MG24HQ
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

 Pseudodata:
  name: MG24HS
  year: Vector{Int64}[60]
  value:Vector{Distributions.LogNormal{Float64}}[60]

The vector of years can be extracted:

years = pensemble[1].year;
60-element Vector{Int64}:
 1961
 1962
 1963
 1964
 1965
 1966
 1967
 1968
 1969
 1970
    ⋮
 2012
 2013
 2014
 2015
 2016
 2017
 2018
 2019
 2020

Convert to DataFrame

Converting Pseudoensemble to DataFrame:

df = convert(DataFrame, pensemble)
first(df,5)
5×3 DataFrame
RowYearConfigurationDistribution
Int64StringDistribu…
11961LN24HADistributions.LogNormal{Float64}(μ=6.74475, σ=0.328861)
21962LN24HADistributions.LogNormal{Float64}(μ=6.66903, σ=0.60999)
31963LN24HADistributions.LogNormal{Float64}(μ=7.12515, σ=0.640745)
41964LN24HADistributions.LogNormal{Float64}(μ=7.12626, σ=0.484738)
51965LN24HADistributions.LogNormal{Float64}(μ=6.38777, σ=0.461077)

Extracting the statistics

# Interval confidence level
α = 0.5

# Median
df[:, :y] = median.(df.Distribution)

# Lower bound of the confidence interval
df[:, :ymin] = quantile.(df.Distribution, α/2)

# Upper bound of the confidence interval
df[:, :ymax] = quantile.(df.Distribution, 1-α/2)

first(df, 5)
5×6 DataFrame
RowYearConfigurationDistributionyyminymax
Int64StringDistribu…Float64Float64Float64
11961LN24HADistributions.LogNormal{Float64}(μ=6.74475, σ=0.328861)849.59680.5771060.58
21962LN24HADistributions.LogNormal{Float64}(μ=6.66903, σ=0.60999)787.629521.9621188.51
31963LN24HADistributions.LogNormal{Float64}(μ=7.12515, σ=0.640745)1242.84806.721914.72
41964LN24HADistributions.LogNormal{Float64}(μ=7.12626, σ=0.484738)1244.22897.2291725.4
51965LN24HADistributions.LogNormal{Float64}(μ=6.38777, σ=0.461077)594.528435.623811.399

Display the discharge of one specific configuration

config = "LN24HA"
df2 = filter(row -> row.Configuration ==config, df)

set_default_plot_size(12cm, 8cm)
plot(df2, x=:Year, y=:y, Geom.line, Geom.point,
    ymin=:ymin, ymax=:ymax, Geom.ribbon,
    Guide.ylabel("Discharge [m³/s]"),
    Guide.title(config))
Example block output

Display the discharge of all configurations

set_default_plot_size(12cm, 8cm)
fig = plot(df, x=:Year, y=:y, color=:Configuration, Geom.line,
    ymin=:ymin, ymax=:ymax, Geom.ribbon,
    Guide.ylabel("Discharge [m³/s]"))
Example block output