-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend extinct_species()
#110
Comments
Thanks a lot! |
You mean the index of the corresponding time step?
Mmmh... this will be redundant information, because then one element of the dictionary would be something like |
Yes 🙏
Excellent! |
I sense that this pair of functions will be increasingly useful as the simulated variables will be soon extended to contain not only species biomasses (see #113). Althought I would prefer they be named
|
About the index of the time step, I am also thinking of creating a sweet function |
I'm sorry I don't understand what you mean here. Do you expect that we could extract extinct/alive species from a solution at a given time dy doing things like: alive_then = alive_species(timestep_index(100.0, solution)) or something? |
Don't forget to address this weakness here within the scope of this PR. |
Currently I use this framework to determine alive species: function living_species(
solution::SciMLBase.ODESolution;
threshold = 0,
idxs = nothing,
kwargs...,
)
measure_on = extract_last_timesteps(solution; idxs, kwargs...)
alive_sp = living_species(measure_on; threshold)
sp = get_parameters(solution).network.species
tmp_idxs = process_idxs(solution, idxs)
idxs = tmp_idxs[alive_sp]
species = sp[idxs]
(; species, idxs)
end
living_species(mat::AbstractMatrix; threshold = 0) =
findall(>(threshold), biomass(mat).species)
living_species(n::AbstractVector; threshold = 0) = findall(>(threshold), n) A living species at time On top of this, I warn user if their simulation extraction over the function extract_last_timesteps(solution; idxs = nothing, quiet = false, kwargs...)
....
quiet || check_last_extinction(solution; idxs = idxs, last = last)
...
end To do this, I need to get the function get_extinction_timesteps(solution; idxs = nothing)
idxs = process_idxs(solution, idxs;)
sp = get_parameters(solution).network.species[idxs]
ext_t = findfirst.(isequal(0), eachrow(solution[idxs, :]))
extinct = ext_t .!== nothing
(
species = sp[extinct],
idxs = idxs[extinct],
extinction_timestep = something.(ext_t[extinct]),
)
end
function get_extinction_timesteps(m::AbstractVector; threshold = 0)
findfirst(x -> x <= threshold, m)
end It is there that I would need something like |
Blocked on #137. |
TODO
get_extinct_species(extinction_events, t)
that given the dictionary ofextinction_events
return the list of extinct species at the time stept
get_alive_species
, the sister ofget_extinction_species
that return alive species instead of dead species, as in some cases in can be more convenient in this wayThe text was updated successfully, but these errors were encountered: