//--------------------------------------------------------------------- /// <summary> /// Combines all young cohorts into a single cohort whose age is the /// succession timestep - 1 and whose biomass is the sum of all the /// biomasses of the young cohorts. /// </summary> /// <remarks> /// The age of the combined cohort is set to the succession timestep - /// 1 so that when the combined cohort undergoes annual growth, its /// age will end up at the succession timestep. /// <p> /// For this method, young cohorts are those whose age is less than or /// equal to the succession timestep. We include the cohort whose age /// is equal to the timestep because such a cohort is generated when /// reproduction occurs during a succession timestep. /// </remarks> public void CombineYoungCohorts() { // Work from the end of cohort data since the array is in old-to- // young order. int youngCount = 0; int totalBiomass = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { CohortData data = cohortData[i]; if (data.Age <= Cohorts.SuccessionTimeStep) { youngCount++; totalBiomass += data.Biomass; } else { break; } } if (youngCount > 0) { cohortData.RemoveRange(cohortData.Count - youngCount, youngCount); cohortData.Add(new CohortData((ushort)(Cohorts.SuccessionTimeStep - 1), totalBiomass)); } }
//--------------------------------------------------------------------- /// <summary> /// Combines all young cohorts into a single cohort whose age is the /// succession timestep - 1 and whose biomass is the sum of all the /// biomasses of the young cohorts. /// </summary> /// <remarks> /// The age of the combined cohort is set to the succession timestep - /// 1 so that when the combined cohort undergoes annual growth, its /// age will end up at the succession timestep. /// <p> /// For this method, young cohorts are those whose age is less than or /// equal to the succession timestep. We include the cohort whose age /// is equal to the timestep because such a cohort is generated when /// reproduction occurs during a succession timestep. /// </remarks> public void CombineYoungCohorts() { // Work from the end of cohort data since the array is in old-to- // young order. int youngCount = 0; int totalBiomass = 0; int combinedCurrentFoliage = 0; int combinedTotalFoliage = 0; //Budworm // Defoliation History is averaged across cohorts by year double[] defolSum = new double[10]; double[] defolHistory = new double[10]; for (int i = cohortData.Count - 1; i >= 0; i--) { CohortData data = cohortData[i]; if (data.Age <= Cohorts.SuccessionTimeStep) { youngCount++; totalBiomass += data.Biomass; combinedCurrentFoliage += data.CurrentFoliage; combinedTotalFoliage += data.TotalFoliage; for (int d = 0; d < 10; d++) { double cohortDefol = data.DefoliationHistory[d]; defolSum[d] += cohortDefol; } } else { break; } } for (int d = 0; d < 10; d++) { defolHistory[d] = defolSum[d] / youngCount; } if (youngCount > 0) { cohortData.RemoveRange(cohortData.Count - youngCount, youngCount); cohortData.Add(new CohortData((ushort)(Cohorts.SuccessionTimeStep - 1), totalBiomass, defolHistory, combinedCurrentFoliage, combinedTotalFoliage)); } }
//--------------------------------------------------------------------- public Cohort(ISpecies species, CohortData cohortData) { this.species = species; this.data = cohortData; }