PredictiveEcology / CBM_core

Other
0 stars 1 forks source link

Deal with species attribution #17

Open cboisvenue opened 5 days ago

cboisvenue commented 5 days ago

The spinup function (libcbmr::cbm_exn_spinup()) requires species passed via the spinup_parameters object. In our current small raster example, these are hard coded (line 333 in CBM_core). We, on the spadesCBM side, attach species to growth curves in CBM_dataPrep_SK. It is my current assumption (Celine) that the species we give in the spinup via spinup_parameters would be used on the Python side to either figure out the Boudewyn parameters, or track species, or sw_hw. But since we give the $growth_increments out of CBM_vol2biomass and that the match to specific species is in $gcMetaAllCols (created in CBM_vol2biomass), and that we define the sw_hw flag also as part of the spinup_parameters, we don't use the species specified in spinup_parameters .

Regardless, the species in spinup_parameters needs to match the species in we associate with each growth curves. Currently, on line 333 of CBM_core, species are assigned "1" if sw and "62" if hw. Those refer to the two species table in the SQLight database that we read in CBM_defaults, we don't currently read in the species and species_tr tables but they match to 1 == Spruce and 62 == Poplar. The species table from the SQLight has a column genus which matches back to another pair of tables in the SQLight (genus just has an id and genus_tr which links it to poplar). Note that these (genus and genus_tr tables) do not seem to be linked to the $canfi_species object that is necessary to get the parameters for the Boudewyn equations in CBM_vol2biomass. My guess (Celine) is that this link (from genus to canfi_species) is internally done when people use libcbm with higher level functions than the ones we call from spadesCBM. For us, species in spinup_parameters have to have the right species_tr$species_id, and that has to match the species we attach to each growth curve. For spadesCBM, it will have to be something like a messy match between the species names in species_tr$name from the SQLight, and $gcMetaAllCols created in CBM_vol2biomass. When we get to LandRCBM (spadesCBM that gets is growth and cohort information from LandR), we will have to match it to cohort-species.