Skip to content

Commit

Permalink
Remove conditional in calibration model interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Jul 19, 2024
1 parent bf25448 commit 39f292d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function run_forward_model(atmos_config::CA.AtmosConfig)
simulation = CA.get_simulation(atmos_config)
sol_res = CA.solve_atmos!(simulation)
if sol_res.ret_code == :simulation_crashed
!isnothing(sol_res.sol) && sol_res.sol .= NaN
error(
"The ClimaAtmos simulation has crashed. See the stack trace for details.",
)
Expand Down
8 changes: 7 additions & 1 deletion calibration/model_interface.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# When Julia 1.10+ is used interactively, stacktraces contain reduced type information to make them shorter.
# On the other hand, the full type information is printed when julia is not run interactively.
# Given that ClimaCore objects are heavily parametrized, non-abbreviated stacktraces are hard to read,
# so we force abbreviated stacktraces even in non-interactive runs.
# (See also Base.type_limited_string_from_context())
redirect_stderr(IOContext(stderr, :stacktrace_types_limited => Ref(false)))

import ClimaAtmos as CA
import YAML
import ClimaComms
Expand Down Expand Up @@ -61,7 +68,6 @@ function run_forward_model(atmos_config::CA.AtmosConfig)
simulation = CA.get_simulation(atmos_config)
sol_res = CA.solve_atmos!(simulation)
if sol_res.ret_code == :simulation_crashed
!isnothing(sol_res.sol) && sol_res.sol .= NaN
error(
"The ClimaAtmos simulation has crashed. See the stack trace for details.",
)
Expand Down
10 changes: 5 additions & 5 deletions calibration/test/e2e_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import Statistics: var, mean
using Test

# Paths and setup
experiment_dir = joinpath(pkgdir(CA), "calibration", "test")
model_interface = joinpath(pkgdir(CA), "calibration", "model_interface.jl")
const experiment_dir = joinpath(pkgdir(CA), "calibration", "test")
const model_interface =
joinpath(pkgdir(CA), "calibration", "model_interface.jl")
const output_dir = joinpath("output", "calibration_end_to_end_test")
include(model_interface)

# Observation map
function CAL.observation_map(iteration)
ensemble_size = 10
output_dir = "calibration_end_to_end_test"
single_member_dims = (1,)
G_ensemble = Array{Float64}(undef, single_member_dims..., ensemble_size)

Expand Down Expand Up @@ -67,7 +68,6 @@ noise = 0.1 * I
n_iterations = 3
ensemble_size = 10
prior = CAL.get_prior(joinpath(experiment_dir, "prior.toml"))
output_dir = "calibration_end_to_end_test"
experiment_config = CAL.ExperimentConfig(;
n_iterations,
ensemble_size,
Expand All @@ -94,7 +94,7 @@ if !(@isdefined backend)
end
@info "Running calibration E2E test" backend
if backend <: CAL.SlurmBackend
slurm_kwargs = CAL.kwargs(time = 10)
slurm_kwargs = CAL.kwargs(time = 15)
test_eki = CAL.calibrate(
backend,
experiment_config;
Expand Down
2 changes: 1 addition & 1 deletion calibration/test/model_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config: column
h_elem: 1
insolation: timevarying
job_id: calibration_end_to_end_test
output_dir: calibration_end_to_end_test
output_dir: output/calibration_end_to_end_test
output_default_diagnostics: false
dt_rad: 6hours
rad: clearsky
Expand Down

0 comments on commit 39f292d

Please sign in to comment.