PredictiveEcology / Biomass_core

Core vegetation dynamics module for LandR. based on LANDIS-II Biomass Succession Extension v3.2.1
Other
2 stars 4 forks source link

speciesEcoregion subsetting during `init` may need revision #79

Open CeresBarros opened 1 year ago

CeresBarros commented 1 year ago

Biomass_core does the following during init

speciesEcoregion[, identifier := year > P(sim)$successionTimestep]   <--------------- why?
  speciesEcoregion_True <- speciesEcoregion[identifier == TRUE, ]
  speciesEcoregion_False <- speciesEcoregion[identifier == FALSE, ]
  if (NROW(speciesEcoregion_False)) {
    speciesEcoregion_True_addon <- speciesEcoregion_False[year == max(year), ]
    speciesEcoregion_True <- rbindlist(list(speciesEcoregion_True_addon, speciesEcoregion_True))
  }
  sim$speciesEcoregion <- speciesEcoregion_True[, ':='(year = year - min(year), identifier = NULL)]

I believe this ensures that when there are trait values for years lower than successionTimestep, the simulation uses the last available year prior to successionTimestep. I am unsure why this is important and think this can be problematic when the user supplies a table that has species traits calculated for several years of the simulation. When cohortData and speciesEcoregion are joined using updateSpeciesEcoregionAttributes the function searches for traits with year <= time(sim) and from those takes the max(year) . Hence, given the code above the following will happen

  1. if a simulation runs from start(sim) == 0 to end(sim) == 100, with a successionTimestep == 10, all trait values for years 0-9 are ignored.
  2. if a simulation runs from year start(sim) == 2000 to end(sim) == 2100, irrespective of the time step, all years will be "rescaled" to 0-100 meaning that again only the last available year of values is used during the simulation.

I am unsure of the true intention of the code snippet posted above, as there are no comments. So I ask @eliotmcintire, @achubaty , @ianmseddy if you have any clue as to what the code is trying to achieve (if different from my interpretation) and also whether it would be possible to think of a way that preserves the original years in the table

CeresBarros commented 1 year ago

I looked at the LANDIS-II documentation for Biomass Succession Extension v3.2.1 and there it says that a year 0 must be present in speciesEcoregion. I wonder if this is the reason behind the "rescaling" of years mentioned above.