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
2020Convert to DataFrame
Converting Pseudoensemble to DataFrame:
df = convert(DataFrame, pensemble)
first(df,5)5×3 DataFrame
| Row | Year | Configuration | Distribution |
|---|---|---|---|
| Int64 | String | Distribu… | |
| 1 | 1961 | LN24HA | Distributions.LogNormal{Float64}(μ=6.74475, σ=0.328861) |
| 2 | 1962 | LN24HA | Distributions.LogNormal{Float64}(μ=6.66903, σ=0.60999) |
| 3 | 1963 | LN24HA | Distributions.LogNormal{Float64}(μ=7.12515, σ=0.640745) |
| 4 | 1964 | LN24HA | Distributions.LogNormal{Float64}(μ=7.12626, σ=0.484738) |
| 5 | 1965 | LN24HA | Distributions.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
| Row | Year | Configuration | Distribution | y | ymin | ymax |
|---|---|---|---|---|---|---|
| Int64 | String | Distribu… | Float64 | Float64 | Float64 | |
| 1 | 1961 | LN24HA | Distributions.LogNormal{Float64}(μ=6.74475, σ=0.328861) | 849.59 | 680.577 | 1060.58 |
| 2 | 1962 | LN24HA | Distributions.LogNormal{Float64}(μ=6.66903, σ=0.60999) | 787.629 | 521.962 | 1188.51 |
| 3 | 1963 | LN24HA | Distributions.LogNormal{Float64}(μ=7.12515, σ=0.640745) | 1242.84 | 806.72 | 1914.72 |
| 4 | 1964 | LN24HA | Distributions.LogNormal{Float64}(μ=7.12626, σ=0.484738) | 1244.22 | 897.229 | 1725.4 |
| 5 | 1965 | LN24HA | Distributions.LogNormal{Float64}(μ=6.38777, σ=0.461077) | 594.528 | 435.623 | 811.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))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]"))