-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_lorenz96_partial.jl
152 lines (124 loc) · 6.22 KB
/
test_lorenz96_partial.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using Statistics
using LinearAlgebra
using Random
using Distributions
using BlockArrays
include("da.jl")
import .DA
include("ens_forecast.jl")
import .ens_forecast
include("models.jl")
import .Models
include("integrators.jl")
import .Integrators
Random.seed!(10)
D = 40
models = [Models.lorenz96_err, Models.lorenz96_err2, Models.lorenz96_err3,
Models.lorenz96_err4]
model_errs_prescribed = [nothing, nothing, nothing, nothing]
model_true = Models.lorenz96_true
n_models = length(models)
#half_I = Array{Float64}(I(D)[1:20, :])
H = diagm(ones(D))[1:2:D, :]
obs_ops = [H, H, H, H]
ens_sizes = [20, 20, 20, 20]
model_sizes = [D, D, D, D]
integrators = [Integrators.rk4, Integrators.rk4, Integrators.rk4, Integrators.rk4]
integrator_true = Integrators.rk4
da_method = DA.ensrf
localization_radius = 4
localization = DA.gaspari_cohn_localization(localization_radius, D, cyclic=true)
x0 = randn(D)
t0 = 0.0
Δt = 0.05
outfreq = 1
transient = 2000
x = integrators[1](models[1], x0, t0, transient*outfreq*Δt, Δt, inplace=false)
R = Symmetric(diagm(0.25*ones(20)))
ens_errs = [Symmetric(diagm(0.25*ones(D))), Symmetric(diagm(0.25*ones(D))),
Symmetric(diagm(0.25*ones(D))), Symmetric(diagm(0.25*ones(D)))]
gen_ensembles = false
assimilate_obs = true
save_Q_hist = false
save_P_hist = false
leads = 1
x0 = x[end, :]
n_cycles = 3000*leads
ρ = 1e-3
ρ_all = 1e-2
window = 4
all_Q_p = []
for i=1:4
for j=1:4
Q_p = mortar(reshape([zeros(10, 10) for i=1:16], 4, 4))
Q_p[Block(i, j)] = ones(10, 10)
append!(all_Q_p, [Matrix(Q_p)])
end
end
all_Q_p = Vector{Matrix{Float64}}(all_Q_p)
infos = Vector(undef, n_models)
for model=1:n_models
Random.seed!(10)
model_errs = [0.1*diagm(ones(D))]
ens_size = sum(ens_sizes)
ensembles = [x0 .+ rand(MvNormal(Symmetric(diagm(0.25*ones(D)))), ens_size)]
info = ens_forecast.da_cycles(x0=x0, ensembles=ensembles, models=[models[model]],
model_true=model_true, obs_ops=[obs_ops[model]], H_true=H,
model_errs=model_errs,
model_errs_prescribed=[model_errs_prescribed[model]],
integrators=integrators, integrator_true=integrator_true, da_method=da_method,
localization=localization, ens_sizes=[ens_size], Δt=Δt,
window=window, n_cycles=n_cycles, outfreq=outfreq,
model_sizes=model_sizes, R=R, ens_errs=ens_errs, ρ=ρ,
ρ_all=ρ_all,
gen_ensembles=gen_ensembles,
assimilate_obs=assimilate_obs, save_analyses=false,
leads=leads, save_Q_hist=save_Q_hist,
save_P_hist=save_P_hist, Q_p=all_Q_p)
infos[model] = info
end
Random.seed!(10)
ensembles = [x0 .+ rand(MvNormal(Symmetric(diagm(0.25*ones(D)))), ens_sizes[model]) for model=1:n_models]
model_errs = [0.1*diagm(ones(D)) for model=1:n_models]
info_mm = ens_forecast.da_cycles(x0=x0, ensembles=ensembles, models=models,
model_true=model_true, obs_ops=obs_ops, H_true=H,
model_errs=model_errs,
model_errs_prescribed=model_errs_prescribed,
integrators=integrators, integrator_true=integrator_true, da_method=da_method,
localization=localization, ens_sizes=ens_sizes, Δt=Δt,
window=window, n_cycles=n_cycles, outfreq=outfreq,
model_sizes=model_sizes, R=R, ens_errs=ens_errs, ρ=ρ,
ρ_all=ρ_all,
all_orders=false, combine_forecasts=true,
gen_ensembles=gen_ensembles, assimilate_obs=assimilate_obs,
leads=leads, save_Q_hist=save_Q_hist, Q_p=all_Q_p)
Random.seed!(10)
ensembles = [x0 .+ rand(MvNormal(Symmetric(diagm(0.25*ones(D)))), ens_sizes[model]) for model=1:n_models]
model_errs = [0.1*diagm(ones(D)) for model=1:n_models]
info_mm2 = ens_forecast.da_cycles(x0=x0, ensembles=ensembles, models=models,
model_true=model_true, obs_ops=obs_ops, H_true=H,
model_errs=model_errs,
model_errs_prescribed=model_errs_prescribed,
integrators=integrators, integrator_true=integrator_true, da_method=da_method,
localization=localization, ens_sizes=ens_sizes, Δt=Δt,
window=window, n_cycles=n_cycles, outfreq=outfreq,
model_sizes=model_sizes, R=R, ens_errs=ens_errs, ρ=ρ,
ρ_all=ρ_all,
combine_forecasts=false, gen_ensembles=gen_ensembles,
assimilate_obs=assimilate_obs, leads=leads,
save_Q_hist=save_Q_hist, Q_p=all_Q_p)
Random.seed!(10)
ensembles = [x0 .+ rand(MvNormal(Symmetric(diagm(0.25*ones(D)))), ens_sizes[model]) for model=1:n_models]
model_errs = [0.1*diagm(ones(D)) for model=1:n_models]
info_mm_all = ens_forecast.da_cycles(x0=x0, ensembles=ensembles, models=models,
model_true=model_true, obs_ops=obs_ops, H_true=H,
model_errs=model_errs,
model_errs_prescribed=model_errs_prescribed,
integrators=integrators, integrator_true=integrator_true, da_method=da_method,
localization=localization, ens_sizes=ens_sizes, Δt=Δt,
window=window, n_cycles=n_cycles, outfreq=outfreq,
model_sizes=model_sizes, R=R, ens_errs=ens_errs, ρ=ρ,
ρ_all=ρ_all,
all_orders=true, combine_forecasts=true,
gen_ensembles=gen_ensembles, assimilate_obs=assimilate_obs,
leads=leads, save_Q_hist=save_Q_hist, Q_p=all_Q_p)