Docstrings
EcoNetPostProcessing.extract_last_timesteps — Methodextract_last_timesteps(solution; idxs = nothing, quiet = false, kwargs...)Returns the biomass matrix of species x time over the last timesteps.
Arguments
last: the number of last timesteps to consider. A percentage can also be also be provided as aStringending by%. Defaulted to 1.idxs: vector of species indexes or names. Set tonothingby default.quiet: ignores warning issue while extracting timesteps before last species extinction
If idxs is an integer, it returns a vector of the species biomass instead of a matrix.
Examples
julia> fw = Foodweb([0 0; 1 0])
m = default_model(fw)
B0, t_end = [1, 1], 1_000
sol = simulate(m, B0, t_end);
julia> last = extract_last_timesteps(sol; last = 1, idxs = [2, 1]);
last ≈ sol.u[end][[2, 1]]
true
julia> last = extract_last_timesteps(sol; last = 1, idxs = ["s2", "s1"]);
last ≈ sol.u[end][[2, 1]]
true
julia> last2 = extract_last_timesteps(sol; last = 1, idxs = [2])
last2 ≈ sol.u[end][[2]]
true
julia> last2 = extract_last_timesteps(sol; last = 1, idxs = "s2")
last2 ≈ sol.u[end][[2]]
trueEcoNetPostProcessing.get_alive_species — Methodget_alive_species(solution; idxs = nothing, threshold = 0)Returns a tuple with species having a biomass above threshold at the end of a simulation.
Examples
julia> foodweb = Foodweb([0 0; 0 0]);
m = default_model(foodweb);
sol = simulate(m, [0, 0.5], 20; show_degenerated = false);
get_alive_species(sol)
(species = [:s2], idxs = [2])
julia> sol = simulate(m, [0.5, 0], 20; show_degenerated = false);
get_alive_species(sol)
(species = [:s1], idxs = [1])
julia> sol = simulate(m, [0.5, 0.5], 20; show_degenerated = false);
get_alive_species(sol)
(species = [:s1, :s2], idxs = [1, 2])
julia> sol = simulate(m, [0, 0], 20; show_degenerated = false);
get_alive_species(sol)
(species = Symbol[], idxs = Int64[])EcoNetPostProcessing.get_dBdt — Methodget_dBdt(m::Model)Generate the function returning the vector of species growth rate (dB/dt) given the vector of their biomass (B), given a Model from EcologicalNetworksDynamics.
The output is aimed to be passed to the jacobian function of ForwardDiff. For more information see ForwardDiff documentation.
See also jacobian.
EcoNetPostProcessing.get_interaction — Methodget_interaction(m::Model, B::AbstractVector)Compute the interaction of the model m. Because interactions are density-dependent, the vectory of species biomass B should be specified. A[i, j] is the interaction from species j to species i, and is formally defined as the derivative of the per capita growth of species i with respect to variation in biomass of species j. See Novak et al. 2016.
See also sensitivity.
EcoNetPostProcessing.get_pgr — Methodget_pgr(m::Model)Generate the function returning the vector of species per capita growth rate (1/B x dB/dt) given the vector of their biomass (B), given a Model from EcologicalNetworksDynamics.
See also sensitivity.
EcoNetPostProcessing.keystoneness — Methodkeystoneness(m::Model, B::AbstractVector)Compute species keystoneness from a given model m at the point given by the vector of species biomass B. Most of the time B should be the vector of species equilibrium biomass. Keystoneness of species i is defined as the sum abs(S[i, j]) for j different from i. It quantifies how a change in the growth rate of species i impacts all other species.
For a formal definition see Li et al. 2025.
See also sensitivity.
EcoNetPostProcessing.process_idxs — Methodprocess_idxs(solution; idxs = nothing)Check and sanitize the species indices or names provided (idxs). Used in extract_last_timesteps.
EcoNetPostProcessing.reactivity — Methodreactivity(j::AbstractMatrix)Compute community reactivity from the jacobian. Reactivity corresponds to the worst initial response of the community to a pulse disturbance.
For technical details see Arnoldi et al. 2019
See also jacobian.
EcoNetPostProcessing.resilience — Methodresilience(j::AbstractMatrix)Compute community resilience from the jacobian. Resilience corresponds here to the dominant eigenvalues of the Jacobian.
For technical details see Arnoldi et al. 2019
See also jacobian.
EcoNetPostProcessing.resistance — Methodresistance(m::Model, B::AbstractVector; response_of = :all, perturbation_on = :all, aggregated = false)Compute the resistance of species or the entire community to a press disturbance (such as an increase in mortality). Resistance computation is based on the sensitivity matrix. To get resistance computed from simulated dynamics use resistance_simulation.
Main arguments
mspecifies the dynamical model.Bis the vector of species equilibrium biomass.
Keyword arguments
response_ofthe response_of which species is measured, by default set to:all.perturbation_onwhich species is affected by the press, by default set to:all.agregatedif true return the resistance on the species selected byresponse_of, can be used typically to compute the resistance at the community level. By default set to false, so that resistance is evaluated at the species level.
See also sensitivity.
EcoNetPostProcessing.resistance_simulation — Methodresistance_simulation(
m::Model,
B::AbstractVector;
mortality_increment::AbstractVector = fill(0.1, m.richness),
response_of = :all,
aggregated = false,
normalized = true,)
Compute the resistance of species or group of species to a mortality increase. Resistance is computed from simulation outputs. For analytical computation see resistance. For small mortality_increment values both function should be equivalent.
Resistance is defined as the change in biomass relative to the mortality increment, when normalized is true. When normalized is false, the absolute change in biomass is returned.
When aggregated is set to true, the total change in biomass is computed, and is normalized by the mean mortality increment.
Note that if normalized is true and the mortality increment of species is set to 0, its resistance value will be set to :undefined because of division by 0. To bypass this behaviour, set :normalized to false, and then use the normalization of your choice on the output.
Main arguments
mspecifies the dynamical model.Bis the vector of species equilibrium biomass.
Keyword arguments
response_ofthe response_of which species is measured, by default set to:all.mortality_incrementvector which species the increase in mortality rate for each species.agggregatedif true return the resistance on the species selected byresponse_of, can be used typically to compute the resistance at the community level. By default set to false, so that resistance is evaluated at the species level.normalizedis the change in biomass normalized by the mortality increment. By default set totrue.
See also sensitivity.
EcoNetPostProcessing.robustness — Methodrobustness(m::Model; t_end = 1_000, n_rep = 100, threshold = 1e-6)Compute the community robustness. Robustness is defined as the inverse of the number of secondary extinctions. The number of average number of secondary extinctions is averaged over n_rep random extinction sequences. Each extinction sequences set the order of species extinction, and terminate when all species are extinct.
Main argument
mspecifies the community.
Keyword arguemnts
t_endsimulation duration (default to 1_000)n_repnumber of extinction sequences (default to 100)thresholdbiomass value under which species are considered extinct (default to 1e-6)
See also secondary_extinctions.
EcoNetPostProcessing.secondary_extinctions — Methodsecondary_extinctions(
m::Model,
extinct_sp::Integer,
B_start::AbstractVector;
t_end = 1_000,
threshold = 1e-6,)
Compute secondary extinctions following the primary extinction of extinct_sp of a model m with initial biomasses B_start.
Keyword arguments
t_endspecifies the duration of simulationthresholdgives the biomass below which a species is considered extinct.
See also robustness.
EcoNetPostProcessing.sensitivity — Methodsensitivity(m::Model, B::AbstractVector)Compute the sensitivity matrix of the model m. Because interactions are density-dependent, the vectory of species biomass B should be specified. The sensitivity matrix is defined as the inverse of the interaction matrix. See Novak et al. 2016.
ForwardDiff.jacobian — Methodjacobian(m::Model, B::AbstractVector)Compute the jacobian of the system specied by the model B. The jacobian is evaluated in B which gives species biomass.