Skip to content

Commit

Permalink
Merge pull request #602 from SebastianM-C/ensemble_plot
Browse files Browse the repository at this point in the history
update ensemble indexing in the plot recipe
  • Loading branch information
ChrisRackauckas authored Jan 24, 2024
2 parents df27cdc + b01a10d commit cb23cdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/ensemble/ensemble_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ timestep_mean(sim, ::Colon) = timeseries_steps_mean(sim)
function timestep_median(sim, i)
arr = componentwise_vectors_timestep(sim, i)
if typeof(first(arr)) <: AbstractArray
return reshape([median(x) for x in arr], size(sim.u[1][i])...)
return reshape([median(x) for x in arr], size(sim.u[1].u[i])...)
else
return median(arr)
end
Expand All @@ -37,7 +37,7 @@ timestep_median(sim, ::Colon) = timeseries_steps_median(sim)
function timestep_quantile(sim, q, i)
arr = componentwise_vectors_timestep(sim, i)
if typeof(first(arr)) <: AbstractArray
return reshape([quantile(x, q) for x in arr], size(sim.u[1][i])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[i])...)
else
return quantile(arr, q)
end
Expand Down Expand Up @@ -97,15 +97,15 @@ timepoint_mean(sim, t) = componentwise_mean(get_timepoint(sim, t))
function timepoint_median(sim, t)
arr = componentwise_vectors_timepoint(sim, t)
if typeof(first(arr)) <: AbstractArray
return reshape([median(x) for x in arr], size(sim.u[1][1])...)
return reshape([median(x) for x in arr], size(sim.u[1].u[1])...)
else
return median(arr)
end
end
function timepoint_quantile(sim, q, t)
arr = componentwise_vectors_timepoint(sim, t)
if typeof(first(arr)) <: AbstractArray
return reshape([quantile(x, q) for x in arr], size(sim.u[1][1])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[1])...)
else
return quantile(arr, q)
end
Expand All @@ -122,7 +122,7 @@ function timepoint_weighted_meancov(sim, W, t1, t2)
end

function SciMLBase.EnsembleSummary(sim::SciMLBase.AbstractEnsembleSolution{T, N},
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
if sim.u[1] isa SciMLSolution
m, v = timeseries_point_meanvar(sim, t)
med = timeseries_point_median(sim, t)
Expand Down
8 changes: 4 additions & 4 deletions src/ensemble/ensemble_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ end
nothing,
trajectories = eachindex(sim))
for i in trajectories
size(sim[i].u, 1) == 0 && continue
size(sim.u[i].u, 1) == 0 && continue
@series begin
legend := false
xlims --> (-Inf, Inf)
ylims --> (-Inf, Inf)
zlims --> (-Inf, Inf)
marker_z --> zcolors[i]
sim[i]
sim.u[i]
end
end
end
Expand All @@ -170,12 +170,12 @@ end
1.96 for i in 1:length(sim.v)]))
ci_high = ci_low
else
ci_low = [[sqrt(sim.v[i] / length(sim.num_monte)) .* 1.96
ci_low = [[sqrt(sim.v.u[i] / length(sim.num_monte)) .* 1.96
for i in 1:length(sim.v)]]
ci_high = ci_low
end
elseif ci_type == :quantile
if sim.med[1] isa AbstractArray
if sim.med.u[1] isa AbstractArray
u = vecarr_to_vectors(sim.med)
else
u = [sim.med.u]
Expand Down

0 comments on commit cb23cdc

Please sign in to comment.