Skip to content

Commit 322226e

Browse files
committed
Add postprocess_g_ensemble
1 parent 391e946 commit 322226e

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ClimaCalibrate.forward_model
77
ClimaCalibrate.observation_map
88
ClimaCalibrate.analyze_iteration
9+
ClimaCalibrate.postprocess_g_ensemble
910
```
1011

1112
## Worker Interface

docs/src/quickstart.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ end
4949

5050
### Optional postprocessing
5151

52+
It may be the case that `observation_map` is insufficient as you need to more information,
53+
such as information from the `ekp` object to compute `G_ensemble`. Further postprocessing of the
54+
`G_ensemble` object can be done by implementing the `postprocess_g_ensemble` as shown
55+
below.
56+
57+
```julia
58+
function postprocess_g_ensemble(ekp, g_ensemble, prior, output_dir, iteration)
59+
return g_ensemble
60+
end
61+
```
62+
5263
After each evaluation of the observation map and before updating the ensemble, it may be
5364
helpful to print the errors from the `ekp` object or plot `G_ensemble`. This can be done
5465
by implementing the `analyze_iteration` as shown below.

src/ekp_interface.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ Compute the observation map and update the given EKP object.
377377
"""
378378
function observation_map_and_update!(ekp, output_dir, iteration, prior)
379379
g_ensemble = observation_map(iteration)
380+
g_ensemble =
381+
postprocess_g_ensemble(ekp, g_ensemble, prior, output_dir, iteration)
380382
save_G_ensemble(output_dir, iteration, g_ensemble)
381383
terminate = update_ensemble!(ekp, g_ensemble, output_dir, iteration, prior)
382384
analyze_iteration(ekp, g_ensemble, prior, output_dir, iteration)

src/model_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For example, one may want to print information from the `eki` object or plot
3737
`g_ensemble`.
3838
"""
3939
function analyze_iteration(ekp, g_ensemble, prior, output_dir, iteration)
40-
@info "Mean constrained parameter: $(EKP.get_ϕ_mean_final(prior, ekp))"
40+
@info "Mean constrained parameter(s): $(EKP.get_ϕ_mean_final(prior, ekp))"
4141
@info "Covariance-weighted error: $(last(EKP.get_error(ekp)))"
4242
return nothing
4343
end

test/model_interface.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import ClimaCalibrate
33
using EnsembleKalmanProcesses.ParameterDistributions
44
using Test
55

6-
# Tests for ensuring ClimaCalibrate has protected interfaces. The API tested below must be defined for each model,
7-
# otherwise ClimaCalibrate will throw an error.
6+
# Tests for ensuring ClimaCalibrate has protected interfaces. The API tested
7+
# below must be defined for each model, otherwise ClimaCalibrate will throw an
8+
# error. However, `analyze_iteration` and `postprocess_g_ensemble` are
9+
# optional to implement.
810

911
@testset "Model Interface stubs" begin
1012
@test_throws ErrorException("forward_model not implemented") ClimaCalibrate.forward_model(
@@ -15,4 +17,5 @@ using Test
1517
1,
1618
)
1719
@test isnothing(ClimaCalibrate.analyze_iteration(1, 1, 1, 1, 1))
20+
@test 2 == ClimaCalibrate.postprocess_g_ensemble(1, 2, 3, 4, 5)
1821
end

0 commit comments

Comments
 (0)