-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cbd859
commit 8964bc4
Showing
18 changed files
with
140 additions
and
2,324 deletions.
There are no files selected for viewing
2,113 changes: 0 additions & 2,113 deletions
2,113
experiments/sphere_held_suarez_rhoe_equilmoist/Manifest.toml
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
experiments/sphere_held_suarez_rhoe_equilmoist/Project.toml
This file was deleted.
Oops, something went wrong.
Binary file not shown.
6 changes: 0 additions & 6 deletions
6
experiments/sphere_held_suarez_rhoe_equilmoist/ekp_config.yml
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
experiments/sphere_held_suarez_rhoe_equilmoist/generate_observations.sbatch
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
experiments/sphere_held_suarez_rhoe_equilmoist/model_config.yml
This file was deleted.
Oops, something went wrong.
79 changes: 0 additions & 79 deletions
79
experiments/sphere_held_suarez_rhoe_equilmoist/model_interface.jl
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-808 Bytes
experiments/sphere_held_suarez_rhoe_equilmoist/obs_noise_cov.jld2
Binary file not shown.
45 changes: 0 additions & 45 deletions
45
experiments/sphere_held_suarez_rhoe_equilmoist/observation_map.jl
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import CalibrateAtmos | ||
|
||
# This can live in CalibrateAtmos | ||
# using ArgParse | ||
# s = ArgParseSettings() | ||
# @add_arg_table! s begin | ||
# "--ntasks", "-n" | ||
# help = "Set number of tasks to launch" | ||
# default = 1 | ||
# "--time", "-t" | ||
# help = "Set max wallclock time" | ||
# default = "0:45:00" | ||
# "--cpus_per_task", "-c" | ||
# default = 1 | ||
# arg_type = Int | ||
# "--gpus_per_task", "-g" | ||
# default = 0 | ||
# arg_type = Int | ||
# # "--constraint" | ||
# # default = "" | ||
# # arg_type = String | ||
# end | ||
|
||
# slurm_calibration(parsed_args = ArgParse.parse_args(s)) = slurm_calibration( | ||
# parsed_args["time"], | ||
# parsed_args["ntasks"], | ||
# parsed_args["cpus_per_task"], | ||
# parsed_args["gpus_per_task"], | ||
# ) | ||
|
||
function slurm_calibration(; experiment_dir = dirname(Base.active_project()), model_interface_path = | ||
abspath(joinpath(experiment_dir, "..", "..", "model_interface.jl")), | ||
time_limit = "0:45:00", ntasks = 1, cpus_per_task = 1, gpus_per_task = 0, verbose = false) | ||
partition = gpus_per_task > 0 ? "gpu" : "expansion" | ||
|
||
experiment_dir = dirname(Base.active_project()) | ||
obs_map_path = joinpath(experiment_dir, "observation_map.jl") | ||
include(obs_map_path) | ||
|
||
# Experiment config is created from a YAML file within the experiment_dir | ||
config = CalibrateAtmos.ExperimentConfig(experiment_dir) | ||
(; n_iterations, output_dir, ensemble_size, prior) = config | ||
|
||
@info "Initializing calibration" n_iterations ensemble_size output_dir | ||
CalibrateAtmos.initialize(config) | ||
|
||
eki = nothing | ||
for i in 0:(n_iterations - 1) | ||
@info "Iteration $i" | ||
tasks = asyncmap(1:ensemble_size; ntasks = ensemble_size) do j | ||
include(obs_map_path) | ||
member_output = joinpath( | ||
CalibrateAtmos.path_to_ensemble_member(output_dir, i, j), | ||
"model_log.txt", | ||
) | ||
fwd_model_cmd = ` | ||
srun | ||
--job-name=run_$(i)_$(j) \ | ||
--time=$time_limit \ | ||
--ntasks=$ntasks \ | ||
--partition=$partition \ | ||
--cpus-per-task=$cpus_per_task \ | ||
--gpus-per-task=$gpus_per_task \ | ||
julia --project=$experiment_dir -e " | ||
import CalibrateAtmos as CAL | ||
iteration = $i; member = $j | ||
model_interface = \"$model_interface_path\"; include(model_interface) | ||
experiment_dir = \"$experiment_dir\" | ||
experiment_config = CAL.ExperimentConfig(experiment_dir) | ||
experiment_id = experiment_config.id | ||
physical_model = CAL.get_forward_model(Val(Symbol(experiment_id))) | ||
model_config = CAL.get_config(physical_model, member, iteration, experiment_dir) | ||
CAL.run_forward_model(physical_model, model_config) | ||
@info \"Forward Model Run Completed\" experiment_id physical_model iteration member" | ||
` | ||
try | ||
@info "Running ensemble member $j" | ||
verbose && j == 1 && println( | ||
"Ensemble member 1 command: \n" * join(fwd_model_cmd.exec, " ") * "\n", | ||
) | ||
run(pipeline(fwd_model_cmd; stdout = member_output, stderr = member_output)) | ||
return true | ||
catch e | ||
if verbose | ||
@warn """ | ||
Ensemble member $j raised an error. See model log for failed run: | ||
$(replace(readchomp(member_output), "\\n" => "\n")) | ||
""" | ||
else | ||
@warn """ | ||
Ensemble member $j raised an error. See $member_output for output log. | ||
""" | ||
end | ||
return false | ||
end | ||
end | ||
|
||
ensemble_exit_codes = map(fetch, tasks) | ||
|
||
if !any(ensemble_exit_codes) | ||
error( | ||
"Full ensemble for iteration $i has failed. See individual model logs for details." | ||
) | ||
elseif !all(ensemble_exit_codes) | ||
@warn "Failed ensemble members: $(findall(!, ensemble_exit_codes))" | ||
end | ||
|
||
@info "Completed Iteration $i, Updating Ensemble" | ||
include(obs_map_path) | ||
methods(observation_map) | ||
G_ensemble = CalibrateAtmos.observation_map(Val(Symbol(config.id)), i) | ||
CalibrateAtmos.save_G_ensemble(config, i, G_ensemble) | ||
eki = CalibrateAtmos.update_ensemble(config, i) | ||
end | ||
|
||
if config.generate_plots | ||
include(joinpath(experiment_dir, "postprocessing.jl")) | ||
convergence_plot(eki, prior; output = output_dir) | ||
end | ||
end | ||
|
||
slurm_calibration(;verbose=true) |
Oops, something went wrong.