Skip to content

Commit 88e58cd

Browse files
committed
Add ObservationRecipe.reconstruct_vars [skip ci]
1 parent dc3845f commit 88e58cd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ext/observation_recipe.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,30 @@ function ObservationRecipe.reconstruct_diag_cov(obs::EKP.Observation)
654654
return vars
655655
end
656656

657+
"""
658+
ObservationRecipe.reconstruct_vars(obs::EKP.Observation)
659+
660+
Reconstruct the `OutputVar`s from the `samples` in `obs`.
661+
"""
662+
function ObservationRecipe.reconstruct_vars(obs::EKP.Observation)
663+
all_metadata = EKP.get_metadata(obs)
664+
samples = EKP.get_samples(obs)
665+
stacked_sample = reduce(vcat, samples)
666+
667+
start_index = 1
668+
vars = OutputVar[]
669+
for metadata in all_metadata
670+
data_size = ClimaAnalysis.flattened_length(metadata)
671+
var = ClimaAnalysis.unflatten(
672+
metadata,
673+
view(stacked_sample, start_index:(start_index + data_size - 1)),
674+
)
675+
push!(vars, var)
676+
start_index += data_size
677+
end
678+
return vars
679+
end
680+
657681
"""
658682
_get_minibatch_indices_for_nth_iteration(ekp::EKP.EnsembleKalmanProcess, N)
659683

0 commit comments

Comments
 (0)