public void Planting() { // For readability Species.IDataset spp = core.Species; ISpecies[] speciesToPlant = new ISpecies[] { spp[1], spp[4], spp[8] }; Planting.SpeciesList plantingSpeciesList = new Planting.SpeciesList(speciesToPlant, core.Species); foreach (ActiveSite activeSite in landscape) { Reproduction.ScheduleForPlanting(plantingSpeciesList, activeSite); } // Don't expected seeding algorithm to be called since each active // set will be planted expectedSpecies.Clear(); foreach (ActiveSite activeSite in landscape) { expectedSite = activeSite; actualSpecies_SeedingAlg.Clear(); actualSpecies_AddNewCohort.Clear(); if (activeSite.SharesData) { if (activeSite.LocationInBlock == new Location(1, 1)) { SetList(speciesThatReproduce, speciesToPlant); } else { // At all other active sites in the block, nothing else // should reproduce (because first site in block had // planting occur) SetList(speciesThatReproduce); } } else { SetList(speciesThatReproduce, speciesToPlant); } Reproduction.Do(activeSite); Assert.AreEqual(expectedSpecies, actualSpecies_SeedingAlg); Assert.AreEqual(speciesThatReproduce, actualSpecies_AddNewCohort); } }
//--------------------------------------------------------------------- public void ApplyTo(ActiveSite site) { if (isDebugEnabled) { log.DebugFormat(" Applying LCC {0} to site {1}", GetType().Name, site.Location); } // For now, we don't do anything with the counts of cohorts cut. CohortCounts cohortCounts = new CohortCounts(); cohortCutter.Cut(site, cohortCounts); if (speciesToPlant != null) { Reproduction.ScheduleForPlanting(speciesToPlant, site); } }
/// <summary> /// Does the actual work of harvesting individual sites /// </summary> public void HarvestSite(ActiveSite site, Stand stand) { // Site selection may have spread to other stands beyond the // original stand. Stand standForCurrentSite = SiteVars.Stand[site]; // Always record the prescription even if nothing harvested; Supports plantOnly prescriptions SiteVars.Prescription[site] = this; SiteVars.PrescriptionName[site] = this.Name; if (isDebugEnabled) { log.DebugFormat(" Cutting cohorts at {0} in stand {1}{2}", site, SiteVars.Stand[site].MapCode, (standForCurrentSite == stand) ? "" : string.Format(" (initial stand {0})", stand.MapCode)); } cohortCutter.Cut(site, cohortCounts); if (cohortCounts.AllSpecies > 0) { SiteVars.CohortsDamaged[site] = cohortCounts.AllSpecies; standForCurrentSite.DamageTable.IncrementCounts(cohortCounts); stand.LastAreaHarvested += Model.Core.CellArea; if (isDebugEnabled) { log.DebugFormat(" # of cohorts damaged = {0}; stand.LastAreaHarvested = {1}", SiteVars.CohortsDamaged[site], stand.LastAreaHarvested); } HarvestExtensionMain.OnSiteHarvest(this, site); } if (speciesToPlant != null) { if (isDebugEnabled) { Model.Core.UI.WriteLine(" {0} {1}", speciesToPlant.ToString(), site.ToString()); } Reproduction.ScheduleForPlanting(speciesToPlant, site); } }
/// <summary> ///Used to change the intensity of defoliation parameters across Landis. /// </summary> /// <param name="site"></param> public void ApplyTo(ActiveSite site, bool newLandUse) { if (newLandUse) { CohortDefoliation.Compute = InsectDefoliate; if (!repeat) { harvestTime = Model.Core.CurrentTime; //Model.Core.UI.WriteLine("Setting defoliation harvest time: " + harvestTime); } } else { if (!repeat) //When repeat harvest is off, shut down the delegate if the land use doesn't transition { CohortDefoliation.Compute = DontCompute; } } if (speciesToPlant != null) { Reproduction.ScheduleForPlanting(speciesToPlant, site); } }
//--------------------------------------------------------------------- /// <summary> /// Harvests a stand (and possibly its neighbors) according to the /// prescription's site-selection method. /// </summary> /// <returns> /// The area that was harvested (units: hectares). /// </returns> // This is called by AppliedPrescription public virtual void Harvest(Stand stand) { //set prescription name for stand stand.PrescriptionName = this.Name; stand.HarvestedRank = AppliedPrescription.CurrentRank; stand.LastPrescription = this; stand.MinTimeSinceDamage = this.minTimeSinceDamage; //set current stand currentStand = stand; currentStand.ClearDamageTable(); // SelectSites(stand) is where either complete, complete stand spreading, or partial stand // spreading are activated. // tjs - This is what gets the sites that will be harvested foreach (ActiveSite site in siteSelector.SelectSites(stand)) { currentSite = site; SiteVars.Cohorts[site].RemoveMarkedCohorts(this); if (SiteVars.CohortsDamaged[site] > 0) { stand.LastAreaHarvested += Model.Core.CellArea; SiteVars.Prescription[site] = this; } if (speciesToPlant != null) { Reproduction.ScheduleForPlanting(speciesToPlant, site); } } return; }
//--------------------------------------------------------------------- /// <summary> /// Harvests a stand (and possibly its neighbors) according to the /// prescription's site-selection method. /// </summary> /// <returns> /// The area that was harvested (units: hectares). /// </returns> // This is called by AppliedPrescription public virtual void Harvest(Stand stand) { if (isDebugEnabled) { log.DebugFormat(" Harvesting stand {0} by {1} ...", stand.MapCode, Name); } //set prescription name for stand stand.PrescriptionName = this.Name; stand.HarvestedRank = AppliedPrescription.CurrentRank; stand.LastPrescription = this; stand.MinTimeSinceDamage = this.minTimeSinceDamage; //set current stand currentStand = stand; currentStand.ClearDamageTable(); // SelectSites(stand) is where either complete, complete stand spreading, or partial stand // spreading are activated. // tjs - This is what gets the sites that will be harvested foreach (ActiveSite site in siteSelector.SelectSites(stand)) { // Site selection may have spread to other stands beyond the // original stand. Stand standForCurrentSite = SiteVars.Stand[site]; // Always record the prescription even if nothing harvested; Supports plantOnly prescriptions SiteVars.Prescription[site] = this; SiteVars.PrescriptionName[site] = this.Name; if (isDebugEnabled) { log.DebugFormat(" Cutting cohorts at {0} in stand {1}{2}", site, SiteVars.Stand[site].MapCode, (standForCurrentSite == stand) ? "" : string.Format(" (initial stand {0})", stand.MapCode)); } cohortCutter.Cut(site, cohortCounts); if (cohortCounts.AllSpecies > 0) { SiteVars.CohortsDamaged[site] = cohortCounts.AllSpecies; standForCurrentSite.DamageTable.IncrementCounts(cohortCounts); stand.LastAreaHarvested += Model.Core.CellArea; if (isDebugEnabled) { log.DebugFormat(" # of cohorts damaged = {0}; stand.LastAreaHarvested = {1}", SiteVars.CohortsDamaged[site], stand.LastAreaHarvested); } HarvestExtensionMain.OnSiteHarvest(this, site); } if (speciesToPlant != null) { Model.Core.UI.WriteLine(" {0} {1}", speciesToPlant.ToString(), site.ToString()); Reproduction.ScheduleForPlanting(speciesToPlant, site); } } return; }