SciMLBase.jl icon indicating copy to clipboard operation
SciMLBase.jl copied to clipboard

EnsembleSummary plots can ignore idxs

Open isaacsas opened this issue 2 years ago • 5 comments

using Catalyst, DifferentialEquations, Plots
rn = @reaction_network begin
       1.0, A --> 0
       2.0, B --> 0
       4.0, C --> 0
       end
dprob = DiscreteProblem(rn, [:A => 100, :B => 10, :C => 5], (0.0,20.0))
jprob = JumpProblem(rn, dprob, Direct())
eprob = EnsembleProblem(jprob)
sims = solve(eprob, SSAStepper(), trajectories=100)
@unpack A,C = rn
plot(sims, idxs=[A,C])

plots just the trajectories for species A and C, while

summ = EnsembleSummary(sims)
plot(summ; idxs=[A,C])

plots all three species.

isaacsas avatar Jan 11 '23 15:01 isaacsas

i have a similar issue! i mine is similar but i don't have dictionary output, it fails with just a vector output

cfrontin avatar Mar 28 '23 20:03 cfrontin

Similar issue here. Looking at the plot recipe for EnsembleSummary, I don't see the idxs keyword described in the documentation, but rather a trajectories keyword to which one can provide the indices of the desired variables. So, in @isaacsas' case, I'd try plot(summ; idxs=(1,3)).

On top of that, in my case I have an ODESystem preprocessed by structural_simplify (MTK), and I would like to plot a variable of summ which is in sims.prob.f.paramsyms but not in sims.prob.f.syms (using the variable names of @isaacsas' example). I wonder if there's an easy way to do that.

natema avatar Jun 20 '23 12:06 natema

Yeah this is just a bug in the plot recipe. Right now the answer is to plot each individually until someone gets around to handling it.

ChrisRackauckas avatar Jun 20 '23 12:06 ChrisRackauckas

Just to suggest an alternative to each plotting individually, for large systems. AFAIS, the order of the variable is preserved by solve and EnsembleSummary, so one way to retrieve the corresponding trajectory indices is with println.(enumerate(states(sys)) where sys is the ODESystem.

natema avatar Jun 20 '23 13:06 natema

That works for variables other than the ones that are just the observed

ChrisRackauckas avatar Jun 20 '23 13:06 ChrisRackauckas