Open giannamars opened 4 years ago
Really good to see someone using this. You should be able to see that output in the interface. The issue is running it without the interface and still getting the data?
How it works is PlottableVars
are passed in to the model. It could have a better name like StoredVars
I guess. But these will make sure all environmental variables and internal flux get stored. Regular Vars
aren't stored - for performance when doing big simulations.
vars
are usually set before these files are loaded:
https://github.com/rafaqz/DEBplant/tree/master/models
They all have a vars parameter near the top. So if you set the vars first:
vars = (PlottableVars(), PlottableVars())
The model run will store all the values in model.records[x].J
. Or of course define your own combinations. You can make them in the interface or just write out the code.
For changing the fitted parameters you can use my Flatten.jl and FieldMetadata.jl packages.
using FieldMetadata, Flatten
import FieldMetadata: @flattenable, flattenable
@flattenable Allometry begin
β0 | false
β1 | false
α | false
end
And just turn on/off parameters in any components you need to. Then flatten(model, Real)
will give you back the parameters you want in a tuple you can splat to a vector for Optim.jl. reconstruct(model, optimvalues, Real)
will rebuild the model with updated values passed from Optim.jl. Check they are the right ones with fieldnameflatten
.
I haven't done it with DEB but I have an example in Dispersal.jl that I use all the time, I'm literally running that right now.
metaflatten(model, bounds, Real)
will also give you all the default parameter ranges for Optim.jl, also missing the parameters you have removed with flattenable
. You can set new bounds
you want as well exactly the same as flattenable but with a Tuple
istead of true/false
. These packages are kinda weird as they hook into the julia method table to store values, instead of the model structs - but they work, and mean you don't have to make the parameter vectors yourself. That's how the ui can just swap out components and rebuild the right sliders without changing any code. Changing flatten as above will also change the ui.jl sliders.
Also bear in mind that this repository is just my scripts, and they are a little clunky as they were for a specific purpose of getting my research and a paper done. They aren't so general or clear as the code in DynamicEnergyBudgets.jl that it's using underneath.
But if this is useful we should make it a package. I will try to officially release DynamicEnergyBudgets.jl soon, but we could also have DynamicEnergyBudgetsUI.jl with the scripts here better wrapped, but separate so you don't need all the graphical stuff for modelling.
Anyway, let me know how you go.
Hi rafaqz,
I'm trying to fit DEBPlant to some proxy data for the root growth flux J_VR,groR. Is there a way to output model.records[2].J[1,2,:] at the same time steps as sol.u?
Second, I'm trying to only fit the DEB core parameters and fix all other parameters. I've tried passing only model.shared.core_pars to ODEProblem, but using e.g. DiffEqParamEstim + Optim.optimize requires the full 22-dim parameter vector. Do you have a fitting routine for DEBPlant or a suggestion of packages to use?