Skip to content

Commit

Permalink
fixed test and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
amylu00 committed Feb 6, 2025
1 parent a7c9729 commit af9d72e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
10 changes: 6 additions & 4 deletions papers/ice_nucleation_2024/AIDA_calibrations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ data_file_names = [
["in07_19_aida.edf"],
]
plot_names = ["IN05", "IN0701", "IN0719"]
end_sim = 25 # Loss func looks at last end_sim timesteps only
start_time_list = [[Int32(150), Int32(180), Int32(80)], [Int32(50)], [Int32(35)]] # freezing onset
end_time_list = [[Int32(290), Int32(290), Int32(170)], [Int32(400)], [Int32(400)]] # approximate time freezing stops
moving_average_n = 20 # average every n points
end_sim = 25 # Loss func looks at last end_sim timesteps only
start_time_list = # freezing onset
[[Int32(150), Int32(180), Int32(80)], [Int32(50)], [Int32(35)]]
end_time_list = # approximate time freezing stops
[[Int32(290), Int32(290), Int32(170)], [Int32(400)], [Int32(400)]]
moving_average_n = 20 # average every n points
updrafts = [[FT(1.5), FT(1.4), FT(5)], [FT(1.5)], [FT(1.5)]] # updrafts matching AIDA cooling rate

# Additional definitions
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
ClimaParams = "0.10.6"
ClimaParams = "0.10.18"
KernelAbstractions = "0.9"
MLJFlux = "0.4"
Optim = "<1.9.3"
32 changes: 10 additions & 22 deletions test/ice_nucleation_calibration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function test_J_calibration(FT, IN_mode)
IC = perf_model_IC(FT, IN_mode)
end_sim = 25

pseudo_data = perf_model_pseudo_data(FT, IN_mode, params, IC, end_sim)
pseudo_data = perf_model_pseudo_data(FT, IN_mode, [params], [IC], end_sim)
Γ = pseudo_data[2]
y_truth = pseudo_data[1]
coeff_true = pseudo_data[3]

EKI_output = calibrate_J_parameters_EKI(
FT,
IN_mode,
params,
IC,
[params],
[IC],
y_truth,
end_sim,
Γ,
Expand All @@ -28,8 +28,8 @@ function test_J_calibration(FT, IN_mode)
UKI_output = calibrate_J_parameters_UKI(
FT,
IN_mode,
params,
IC,
[params],
[IC],
y_truth,
end_sim,
Γ,
Expand All @@ -39,46 +39,34 @@ function test_J_calibration(FT, IN_mode)
EKI_calibrated_parameters = EKI_output[1]
UKI_calibrated_parameters = UKI_output[1]
EKI_calibrated_soln =
run_model(params, EKI_calibrated_parameters, FT, IC, end_sim)
run_model([params], IN_mode, EKI_calibrated_parameters, FT, [IC], end_sim)
UKI_calibrated_soln =
run_model(params, UKI_calibrated_parameters, FT, IC, end_sim)
true_soln = run_model(params, coeff_true, FT, IC, end_sim)
run_model([params], IN_mode, UKI_calibrated_parameters, FT, [IC], end_sim)
true_soln = run_model([params], IN_mode, coeff_true, FT, [IC], end_sim)

TT.@testset "EKI Perfect Model Calibrations on AIDA" begin
# test that coeffs are close to "true" values and that end ICNC are similar
# test that end ICNC are similar
if IN_mode == "ABDINM"
TT.@test EKI_calibrated_parameters[1] coeff_true[1] rtol = FT(0.3)
TT.@test EKI_calibrated_parameters[2] coeff_true[2] rtol = FT(1.5)
TT.@test EKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
elseif IN_mode == "ABIFM"
TT.@test EKI_calibrated_parameters[3] coeff_true[3] rtol = FT(0.3)
TT.@test EKI_calibrated_parameters[4] coeff_true[4] rtol = FT(0.3)
TT.@test EKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
elseif IN_mode == "ABHOM"
TT.@test EKI_calibrated_parameters[5] coeff_true[5] rtol = FT(0.3)
TT.@test EKI_calibrated_parameters[6] coeff_true[6] rtol = FT(0.3)
TT.@test EKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
end
end

TT.@testset "UKI Perfect Model Calibrations on AIDA" begin
# test that coeffs are close to "true" values and that end ICNC are similar
# test that end ICNC are similar
if IN_mode == "ABDINM"
TT.@test UKI_calibrated_parameters[1] coeff_true[1] rtol = FT(0.3)
TT.@test UKI_calibrated_parameters[2] coeff_true[2] rtol = FT(1.5)
TT.@test UKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
elseif IN_mode == "ABIFM"
TT.@test UKI_calibrated_parameters[3] coeff_true[3] rtol = FT(0.3)
TT.@test UKI_calibrated_parameters[4] coeff_true[4] rtol = FT(0.3)
TT.@test UKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
elseif IN_mode == "ABHOM"
TT.@test UKI_calibrated_parameters[5] coeff_true[5] rtol = FT(0.3)
TT.@test UKI_calibrated_parameters[6] coeff_true[6] rtol = FT(0.3)
TT.@test UKI_calibrated_soln[9, end] true_soln[9, end] rtol =
FT(0.3)
end
Expand Down
2 changes: 1 addition & 1 deletion test/performance_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function benchmark_test(FT)
bench_press(
CMN.conv_q_vap_to_q_liq_ice_MM2015,
(liquid, tps, TD.PhasePartition(FT(0.00145)), FT(0.8), FT(263)),
60,
70,
)

# 0-moment
Expand Down

0 comments on commit af9d72e

Please sign in to comment.