DrylandEcology / STEPWAT2

folder
4 stars 5 forks source link

Calculate new biomass variables needed for new wildlfire cheatgrass cycle implementation #521

Closed kpalmqui closed 1 year ago

kpalmqui commented 2 years ago

Two new biomass variables need to be calculated and stored for use in the new wildfire cheatgrass cycle implementation:

  1. annual forb and grass biomass (afgAGB) = a.cool.forb + a.warm.forb + a.cool.grass

  2. perennial forb and grass biomass (pfgAGB) = p.cool.forb + p.warm.forb + p.cool.grass + p.warm.grass

See RGroup_GetBiomass for potential function to use and _getCheatgrassBiomass for an example of grabbing biomass for a particular species

mnovo323 commented 2 years ago

Because these issues are for implementing the new cheatgrass wildfire, I think we should put them in mortality where the old wildfire code lives. We could create a new function for getting the biomass of a list of species, then call that function to get afgAGB and pfgAGB. _getCheatgrassBiomass will absolutely work, but it loops through the array of all species every time, and my gut tells me there is a more efficient way of doing that. With the small numbers of species we're working with though, the time saved by not looping through every species will be negligible, however.

The code for my proposed function could look something like: _getSpNameArrayBiomass(char **species) { SppIndex sp; // this is to get the length of the species array, I.e. the number of species to get the biomass for. int length = sizeof(species)/sizeof(species[0]); float totalBiomass = 0; for(int i = 0; i < length; i++) { ForEachSpecies(sp) { if (strcmp(species[i], Species[sp]->name) == 0) { totalBiomass += Species_GetBiomass(sp); } } } }

The time complexity for this function would be O(n * m), where n is the total number of species, and m is the length of the species array we want to find the biomass for. This is not as efficient as it could be, but it will work and for the small amounts of species, I'm not sure it matters.

mnovo323 commented 2 years ago

Also, I apologize for the code formatting. Apparently when you put a code block in the comments, it doesn't format how you type it.

mnovo323 commented 2 years ago

Final solution per our meeting: In the final simulate cheatgrass wildfire function, have two arrays containing the strings "a.cool.forb, a.warm.forb, a.cool.grass", etc. then loop through those arrays of strings and sum the biomass of those functional groups using RGroup_GetBiomass to two separate variables afgAGB and pfgAGB.

kpalmqui commented 2 years ago

An additional update to this issue:

Currently this year's afg and pfg biomass is used to determine wildfire probability. We now want to pass the average biomass over the previous three years into the equation that calculates wildfire probability instead. This can be done by first calculating the 3-year running average for each functional type using get_running_mean and the summing the relevant functional type biomass values (as is currently done) to get afg and pfg biomass. _updateCheatgrassPrecip provides an example of how this could be done. The 3-year running average should include biomass of the current year and the previous two years.

An additional complication here is that if a wildfire has occurred in the current year or previous 2 years, we do not want to include biomass in the wildfire year in the runnning average. Instead, we would want to calculate the average biomass since the wildfire year. For example, it is year 122 and a wildfire occurred in year 120, mean biomass could be calculated for years 121 and 122 only. We track wildfire events using the boolean wildfire.

mnovo323 commented 2 years ago

Proposal:

add this information to the structure I commented about under #522 and add related methods to ST_mortality.c

kpalmqui commented 1 year ago

Resolved by https://github.com/DrylandEcology/STEPWAT2/commit/1b60be281ebfbd19370ee64a91a64392771d8f9c