@@ -129,15 +129,29 @@ for (batch_index, batch_name) in enumerate(batch_names)
129
129
EKI_output = calibrate_J_parameters_EKI (FT, nuc_mode, params_list, IC_list, y_truth, end_sim, Γ)
130
130
UKI_output = calibrate_J_parameters_UKI (FT, nuc_mode, params_list, IC_list, y_truth, end_sim, Γ)
131
131
132
+ EKI_calibrated_parameters = EKI_output[1 ] # MEAN of parameters from ensembles in FINAL iteration
133
+ UKI_calibrated_parameters = UKI_output[1 ] # MEAN of parameters from ensembles in FINAL iteration
134
+ EKI_all_params = EKI_output[2 ] # parameters from EACH ensemble in EACH iteration
135
+ UKI_all_params = UKI_output[2 ] # parameters from EACH ensemble in EACH iteration
136
+ EKI_mean_each_iter = EKI_output[3 ] # MEAN of parameters from ensembles in EACH iteration
137
+ UKI_mean_each_iter = UKI_output[3 ] # MEAN of parameters from ensembles in EACH iteration
138
+ # EKI_final_iter_spread = EKI_output[4] # parameters for EACH ensemble in FINAL iteration
139
+ UKI_final_iter_spread = UKI_output[4 ] # parameters for EACH ensemble in FINAL iteration
140
+
132
141
EKI_n_iterations = size (EKI_output[2 ])[1 ]
133
142
EKI_n_ensembles = size (EKI_output[2 ][1 ])[2 ]
143
+ UKI_n_iterations = size (UKI_output[2 ])[1 ]
144
+ UKI_n_ensembles = size (UKI_output[2 ][1 ])[2 ]
145
+
146
+ EKI_calibrated_ensemble_means = ensemble_means (EKI_all_params, EKI_n_iterations, EKI_n_ensembles)
147
+ UKI_calibrated_ensemble_means = ensemble_means (UKI_all_params, UKI_n_iterations, UKI_n_ensembles)
134
148
135
- EKI_calibrated_parameters = EKI_output[1 ]
136
- UKI_calibrated_parameters = UKI_output[1 ]
137
- calibrated_ensemble_means = ensemble_means (EKI_output[2 ], EKI_n_iterations, EKI_n_ensembles)
138
149
merge! (EKI_calibrated_coeff_dict, Dict (batch_name => EKI_calibrated_parameters))
139
150
merge! (UKI_calibrated_coeff_dict, Dict (batch_name => UKI_calibrated_parameters))
140
151
152
+ EKI_loss_batch = []
153
+ UKI_loss_batch = []
154
+
141
155
# ## Plot for individual experiments.
142
156
for (exp_index, data_file) in enumerate (data_file_name_list)
143
157
if batch_name == " HOM"
@@ -160,20 +174,40 @@ for (batch_index, batch_name) in enumerate(batch_names)
160
174
push! (overview_data. UKI_calibrated_parcel, UKI_parcel)
161
175
end
162
176
177
+ # Parcel runs using ensemble means of parameters at each iteration for each exp in batch
178
+ EKI_loss_exp = []
179
+ UKI_loss_exp = []
180
+ for j in 1 : EKI_n_iterations
181
+ EKI_parcel_iteration = run_model ([params_list[exp_index]], nuc_mode, EKI_mean_each_iter[j], FT, [IC_list[exp_index]], end_sim)
182
+ EKI_loss_iteration = (EKI_parcel_iteration[9 , end ] / Nₜ[exp_index]) - frozen_frac_moving_mean[exp_index][end ]
183
+ append! (EKI_loss_exp, abs .(EKI_loss_iteration))
184
+ end
185
+ push! (EKI_loss_batch, EKI_loss_exp)
186
+ for k in 1 : UKI_n_iterations
187
+ UKI_parcel_iteration = run_model ([params_list[exp_index]], nuc_mode, UKI_mean_each_iter[k], FT, [IC_list[exp_index]], end_sim)
188
+ UKI_loss_iteration = (UKI_parcel_iteration[9 , end ] / Nₜ[exp_index]) - frozen_frac_moving_mean[exp_index][end ]
189
+ append! (UKI_loss_exp, abs .(UKI_loss_iteration))
190
+ end
191
+ push! (UKI_loss_batch, UKI_loss_exp)
192
+
163
193
# # Plots.
164
194
# # Plotting AIDA data.
165
195
AIDA_data = data_file in edf_data_names ? unpack_data (data_file) : unpack_data (data_file, total_t = t_max[exp_index])
166
196
(; AIDA_t_profile, AIDA_T_profile, AIDA_P_profile, AIDA_ICNC_profile, AIDA_e_profile) = AIDA_data
167
197
168
198
AIDA_ICNC_data_fig = plot_AIDA_ICNC_data (
169
- exp_names[exp_index],
199
+ exp_names[exp_index], start_time[exp_index],
170
200
AIDA_t_profile, AIDA_ICNC_profile,
171
201
t_profile[exp_index], ICNC_moving_avg[exp_index], frozen_frac_moving_mean[exp_index],
172
202
)
173
203
174
204
# # Calibrated coefficients.
175
205
# Did they converge?
176
- calibrated_coeffs_fig = plot_calibrated_coeffs (batch_name, EKI_n_iterations, calibrated_ensemble_means)
206
+ calibrated_coeffs_fig = plot_calibrated_coeffs (
207
+ batch_name,
208
+ EKI_n_iterations, EKI_calibrated_ensemble_means,
209
+ UKI_n_iterations, UKI_calibrated_ensemble_means,
210
+ )
177
211
178
212
# # Calibrated parcel simulations.
179
213
# Does the calibrated parcel give reasonable outputs?
@@ -192,21 +226,28 @@ for (batch_index, batch_name) in enumerate(batch_names)
192
226
)
193
227
194
228
# # Looking at spread in UKI calibrated parameters
195
- ϕ_UKI = UKI_output[2 ]
196
- UKI_parcel_1 = run_model ([params_list[exp_index]], nuc_mode, [ϕ_UKI[1 ,1 ], ϕ_UKI[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
197
- UKI_parcel_2 = run_model ([params_list[exp_index]], nuc_mode, [ϕ_UKI[1 ,1 ], ϕ_UKI[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
198
- UKI_parcel_3 = run_model ([params_list[exp_index]], nuc_mode, [ϕ_UKI[1 ,1 ], ϕ_UKI[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
199
- UKI_parcel_4 = run_model ([params_list[exp_index]], nuc_mode, [ϕ_UKI[1 ,1 ], ϕ_UKI[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
200
- UKI_parcel_5 = run_model ([params_list[exp_index]], nuc_mode, [ϕ_UKI[1 ,1 ], ϕ_UKI[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
229
+ UKI_parcel_1 = run_model ([params_list[exp_index]], nuc_mode, [UKI_final_iter_spread[1 ,1 ], UKI_final_iter_spread[2 ,1 ]], FT, [IC_list[exp_index]], end_sim)
230
+ UKI_parcel_2 = run_model ([params_list[exp_index]], nuc_mode, [UKI_final_iter_spread[1 ,2 ], UKI_final_iter_spread[2 ,2 ]], FT, [IC_list[exp_index]], end_sim)
231
+ UKI_parcel_3 = run_model ([params_list[exp_index]], nuc_mode, [UKI_final_iter_spread[1 ,3 ], UKI_final_iter_spread[2 ,3 ]], FT, [IC_list[exp_index]], end_sim)
232
+ UKI_parcel_4 = run_model ([params_list[exp_index]], nuc_mode, [UKI_final_iter_spread[1 ,4 ], UKI_final_iter_spread[2 ,4 ]], FT, [IC_list[exp_index]], end_sim)
233
+ UKI_parcel_5 = run_model ([params_list[exp_index]], nuc_mode, [UKI_final_iter_spread[1 ,5 ], UKI_final_iter_spread[2 ,5 ]], FT, [IC_list[exp_index]], end_sim)
201
234
202
235
UKI_spread_fig = plot_UKI_spread (
203
236
exp_names[exp_index],
204
237
t_profile[exp_index], frozen_frac_moving_mean[exp_index], Nₜ[exp_index],
205
238
UKI_parcel_1, UKI_parcel_2, UKI_parcel_3, UKI_parcel_4, UKI_parcel_5, UKI_parcel,
206
239
)
207
240
208
- end # plotting individual experiments
209
- end
241
+ end # iterating over experiments in batch
242
+
243
+ # # Plotting loss function over calibration iterations
244
+ loss_fig = plot_loss_func (
245
+ batch_name,
246
+ EKI_n_iterations, UKI_n_iterations,
247
+ EKI_loss_batch, UKI_loss_batch,
248
+ )
249
+
250
+ end # iterating over batches
210
251
211
252
# Plotting overview
212
253
plot_ICNC_overview (overview_data)
0 commit comments