当前位置: 首页>>代码示例>>C#>>正文


C# Stand.ClearDamageTable方法代码示例

本文整理汇总了C#中Stand.ClearDamageTable方法的典型用法代码示例。如果您正苦于以下问题:C# Stand.ClearDamageTable方法的具体用法?C# Stand.ClearDamageTable怎么用?C# Stand.ClearDamageTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stand的用法示例。


在下文中一共展示了Stand.ClearDamageTable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteLogEntry

        //---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int standPrescriptionNumber = 0;

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = SiteVars.Prescription[site].Number;
                    SiteVars.PrescriptionName[site] = SiteVars.Prescription[site].Name;
                    SiteVars.TimeOfLastEvent[site] = PlugIn.ModelCore.CurrentTime;
                }
                int cohortsDamagedAtSite = SiteVars.CohortsDamaged[site];
                cohortsDamaged += cohortsDamagedAtSite;
                if (cohortsDamagedAtSite > 0) {
                    damagedSites++;
                }
            }


            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;

            //csv string for log file, contains species kill count
            string species_count = "";

            //if this is the right species match, add it's count to the csv string
            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                bool assigned = false;

                //loop through dictionary of species kill count
                foreach (KeyValuePair<string, int> kvp in stand.DamageTable) {
                    if (species.Name == kvp.Key) {
                        assigned = true;
                        species_count += kvp.Value + ",";
                        totalSpeciesCohorts[standPrescriptionNumber, species.Index] += kvp.Value;
                    }
                }
                if (!assigned) {
                    //put a 0 there if it's not assigned (because none were found in the dictionary)
                    species_count += "0,";
                }
            }

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
                //current time
                //management area's map code
                //the prescription that caused this harvest
                //stand's map code
                //stand's age
                //stand's current rank
                //total sites in the stand
                //damaged sites from this stand
                //cohorts killed in this stand, by this harvest
            //and only record stands where a site has been damaged
            log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                          PlugIn.ModelCore.CurrentTime, mgmtArea.MapCode, stand.PrescriptionName, stand.MapCode, stand.EventId,
                          stand.Age, stand.HarvestedRank, stand.SiteCount, damagedSites, cohortsDamaged, species_count);


        }
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:68,代码来源:PlugIn.cs

示例2: Harvest

        //---------------------------------------------------------------------
        
        /// <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];

                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;
                    SiteVars.Prescription[site] = this;
                    if (isDebugEnabled)
                        log.DebugFormat("    # of cohorts damaged = {0}; stand.LastAreaHarvested = {1}",
                                        SiteVars.CohortsDamaged[site],
                                        stand.LastAreaHarvested);
                }

                if (speciesToPlant != null)
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);
            
            } 
            return; 
        } 
开发者ID:LANDIS-II-Foundation,项目名称:Libraries,代码行数:64,代码来源:Prescription.cs

示例3: WriteLogEntry

        //---------------------------------------------------------------------

        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int cohortsKilled = 0;
            int standPrescriptionNumber = 0;
            double biomassRemoved = 0.0;
            double biomassRemovedPerHa = 0.0;
            //ModelCore.UI.WriteLine("BiomassHarvest:  PlugIn.cs: WriteLogEntry: mgmtArea {0}, Stand {1} ", mgmtArea.Prescriptions.Count, stand.MapCode);

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (BaseHarvest.SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = BaseHarvest.SiteVars.Prescription[site].Number;
                    BaseHarvest.SiteVars.PrescriptionName[site] = BaseHarvest.SiteVars.Prescription[site].Name;
                    BaseHarvest.SiteVars.TimeOfLastEvent[site] = modelCore.CurrentTime;
                }

                cohortsDamaged += SiteVars.CohortsPartiallyDamaged[site];
                cohortsKilled += BaseHarvest.SiteVars.CohortsDamaged[site];


                if (SiteVars.CohortsPartiallyDamaged[site] > 0 ||  BaseHarvest.SiteVars.CohortsDamaged[site] > 0)
                {
                    damagedSites++;

                    //Conversion from [g m-2] to [Mg ha-1] to [Mg]
                    biomassRemoved += SiteVars.BiomassRemoved[site] / 100.0 * modelCore.CellArea;
                }
            }

            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;
            totalCohortsDamaged[standPrescriptionNumber] += cohortsDamaged;
            totalCohortsKilled[standPrescriptionNumber] += cohortsKilled;


            //csv string for log file, contains species kill count
            string species_count = "";
            //if this is the right species match, add it's count to the csv string
            foreach (ISpecies species in modelCore.Species) {
                bool assigned = false;

                //loop through dictionary of species kill count
                foreach (KeyValuePair<string, int> kvp in stand.DamageTable) {
                    if (species.Name == kvp.Key) {
                        assigned = true;
                        species_count += "," + kvp.Value;
                        totalSpeciesCohorts[standPrescriptionNumber, species.Index] += kvp.Value;
                    }
                }
                if (!assigned) {
                    //put a 0 there if it's not assigned (because none were found in the dictionary)
                    species_count += ",0";
                    totalSpeciesCohorts[standPrescriptionNumber, species.Index] += 0;
                }
            }

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
            biomassRemovedPerHa = biomassRemoved / (double) damagedSites / modelCore.CellArea;

            if(biomassRemoved <= 0.0)
                return;

            log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9:0.000},{10:0.000},{11},{12}{13}",
                          modelCore.CurrentTime,
                          mgmtArea.MapCode,
                          stand.PrescriptionName,
                          stand.MapCode,
                          stand.EventId,
                          stand.Age,
                          stand.HarvestedRank,
                          stand.SiteCount,
                          damagedSites,
                          biomassRemoved,  // Mg
                          biomassRemovedPerHa, // Mg/ha
                          cohortsDamaged,
                          cohortsKilled,
                          species_count);
        }
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:86,代码来源:PlugIn.cs

示例4: Harvest

        //---------------------------------------------------------------------

        /// <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>
        public virtual double Harvest(Stand stand)
        {
            //UI.WriteLine("{0} HARVESTING STAND {1}, set-aside = {2}", this.Name, stand.MapCode, stand.IsSetAside);
            //set prescription name for stand
            stand.PrescriptionName = this.Name;
            stand.HarvestedRank = PlugIn.CurrentRank;
            //set current stand
            currentStand = stand;
            currentStand.ClearDamageTable();
            foreach (ActiveSite site in siteSelector.SelectSites(stand)) {
                currentSite = site;

                ISiteCohorts cohorts = Model.LandscapeCohorts[site];
                cohorts.DamageBy(this);
                SiteVars.Prescription[site] = this;

                if (speciesToPlant != null)
                    Succession.Reproduction.ScheduleForPlanting(speciesToPlant, site);
            }
            return siteSelector.AreaSelected;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Disturbance,代码行数:30,代码来源:Prescription.cs

示例5: Harvest

        //---------------------------------------------------------------------
        
        /// <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 = PlugIn.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);         

                //  In order for easement prescriptions to properly "spread", we need to count
                //  each site in its area harvested even if no cohorts are damaged.
                //if (SiteVars.CohortsDamaged[site] > 0)
                {
                    stand.LastAreaHarvested += PlugIn.ModelCore.CellArea;
                }    

                //  With land-use, a prescription doesn't necessarily damage a site's cohorts
                //  (for example, an easement prescription).  So, always assign the current
                //  prescription to the site, regardless if any cohorts were damaged.  This
                //  will cause the prescription to appear on the timestep's prescription map.
                SiteVars.Prescription[site] = this;

                if (speciesToPlant != null)
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);

                if (landUseAfterHarvest != null)
                    LandUse.SiteVar[site] = landUseAfterHarvest;
            } 
            return; 
        } 
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Disturbance,代码行数:54,代码来源:Prescription.cs

示例6: WriteLogEntry

        //---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int standPrescriptionNumber = 0;

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = SiteVars.Prescription[site].Number;
                    SiteVars.PrescriptionName[site] = SiteVars.Prescription[site].Name;
                    SiteVars.TimeOfLastEvent[site] = PlugIn.ModelCore.CurrentTime;
                }
                int cohortsDamagedAtSite = SiteVars.CohortsDamaged[site];
                cohortsDamaged += cohortsDamagedAtSite;
                if (cohortsDamagedAtSite > 0) {
                    damagedSites++;
                }
            }


            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;

            //csv string for log file, contains species kill count
            string species_count = "";

            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                int cohortCount = stand.DamageTable[species];
                species_count += string.Format("{0},", cohortCount);
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
            }

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
                //current time
                //management area's map code
                //the prescription that caused this harvest
                //stand's map code
                //stand's age
                //stand's current rank
                //total sites in the stand
                //damaged sites from this stand
                //cohorts killed in this stand, by this harvest
            //and only record stands where a site has been damaged
            log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                          PlugIn.ModelCore.CurrentTime, mgmtArea.MapCode, stand.PrescriptionName, stand.MapCode, stand.EventId,
                          stand.Age, stand.HarvestedRank, stand.SiteCount, damagedSites, cohortsDamaged, species_count);


        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Disturbance,代码行数:56,代码来源:PlugIn.cs

示例7: WriteLogEntry

        //---------------------------------------------------------------------

        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int cohortsKilled = 0;
            int standPrescriptionNumber = 0;
            double biomassRemoved = 0.0;
            double biomassRemovedPerHa = 0.0;
            //ModelCore.UI.WriteLine("BiomassHarvest:  PlugIn.cs: WriteLogEntry: mgmtArea {0}, Stand {1} ", mgmtArea.Prescriptions.Count, stand.MapCode);

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (HarvestMgmtLib.SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = HarvestMgmtLib.SiteVars.Prescription[site].Number;
                    HarvestMgmtLib.SiteVars.PrescriptionName[site] = HarvestMgmtLib.SiteVars.Prescription[site].Name;
                    HarvestMgmtLib.SiteVars.TimeOfLastEvent[site] = modelCore.CurrentTime;
                }

                cohortsDamaged += SiteVars.CohortsPartiallyDamaged[site];
                cohortsKilled += HarvestMgmtLib.SiteVars.CohortsDamaged[site];


                if (SiteVars.CohortsPartiallyDamaged[site] > 0 || HarvestMgmtLib.SiteVars.CohortsDamaged[site] > 0)
                {
                    damagedSites++;

                    //Conversion from [g m-2] to [Mg ha-1] to [Mg]
                    biomassRemoved += SiteVars.BiomassRemoved[site] / 100.0 * modelCore.CellArea;
                }
            }

            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;
            totalCohortsDamaged[standPrescriptionNumber] += cohortsDamaged;
            totalCohortsKilled[standPrescriptionNumber] += cohortsKilled;


            //csv string for log file, contains species kill count
            string species_count = "";
            foreach (ISpecies species in modelCore.Species) {
                int cohortCount = stand.DamageTable[species];
                species_count += string.Format("{0},", cohortCount);
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
            }

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
            biomassRemovedPerHa = biomassRemoved / (double) damagedSites / modelCore.CellArea;

            if(biomassRemoved <= 0.0)
                return;

            log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9:0.000},{10:0.000},{11},{12}{13}",
                          modelCore.CurrentTime,
                          mgmtArea.MapCode,
                          stand.PrescriptionName,
                          stand.MapCode,
                          stand.EventId,
                          stand.Age,
                          stand.HarvestedRank,
                          stand.SiteCount,
                          damagedSites,
                          biomassRemoved,  // Mg
                          biomassRemovedPerHa, // Mg/ha
                          cohortsDamaged,
                          cohortsKilled,
                          species_count);
        }
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:73,代码来源:PlugIn.cs

示例8: Harvest

        //---------------------------------------------------------------------
        
        /// <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 = PlugIn.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 += PlugIn.ModelCore.CellArea;
                    SiteVars.Prescription[site] = this;
                }    

                if (speciesToPlant != null)
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);
            
            } 
            return; 
        } 
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Disturbance,代码行数:45,代码来源:Prescription.cs

示例9: WriteLogEntry

        //---------------------------------------------------------------------

        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int cohortsKilled = 0;
            int standPrescriptionNumber = 0;
            double biomassRemoved = 0.0;
            double biomassRemovedPerHa = 0.0;

            foreach (ActiveSite site in stand)
            {
                //set the prescription name for this site
                if (BaseHarvest.SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = BaseHarvest.SiteVars.Prescription[site].Number;
                    BaseHarvest.SiteVars.PrescriptionName[site] = BaseHarvest.SiteVars.Prescription[site].Name;
                    BaseHarvest.SiteVars.TimeOfLastEvent[site] = modelCore.CurrentTime;
                }

                cohortsDamaged += SiteVars.CohortsPartiallyDamaged[site];
                cohortsKilled += BaseHarvest.SiteVars.CohortsDamaged[site];


                if (SiteVars.CohortsPartiallyDamaged[site] > 0 || BaseHarvest.SiteVars.CohortsDamaged[site] > 0)
                {
                    damagedSites++;

                    //Conversion from [g m-2] to [Mg]
                    biomassRemoved += SiteVars.BiomassRemoved[site] / 100.0 * modelCore.CellArea;
                }
            }
            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;
            totalCohortsDamaged[standPrescriptionNumber] += cohortsDamaged;
            totalCohortsKilled[standPrescriptionNumber] += cohortsKilled;


            //string for log file, contains species harvest count
            double[] species_count = new double[modelCore.Species.Count];
            
            //if this is the right species match, add it's count to the csv string
            foreach (ISpecies species in modelCore.Species) 
            {
                bool assigned = false;

                //loop through dictionary of species kill count
                foreach (KeyValuePair<string, int> kvp in stand.DamageTable) {
                    if (species.Name == kvp.Key) {
                        assigned = true;
                        species_count[species.Index] += kvp.Value;
                    }
                }
                if (!assigned) {
                    //put a 0 there if it's not assigned (because none were found in the dictionary)
                    species_count[species.Index] = 0.0;
                }
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += (double) species_count[species.Index];
            }


            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
            biomassRemovedPerHa = biomassRemoved / (double)damagedSites / modelCore.CellArea;

            if (biomassRemoved <= 0.0)
                return;

            eventLog.Clear();
            EventsLog el = new EventsLog();
            el.Time = modelCore.CurrentTime;
            el.ManagementArea = mgmtArea.MapCode;
            el.Prescription = stand.PrescriptionName;
            el.StandMapCode = stand.MapCode;
            el.EventID = stand.EventId;
            el.StandAge = stand.Age;
            el.StandRank = stand.HarvestedRank;
            el.StandSiteCount = stand.SiteCount;
            el.HarvestedSites = damagedSites;
            el.MgBiomassRemoved = biomassRemoved;  // Mg
            el.MgBioRemovedPerDamagedHa = biomassRemovedPerHa; // Mg/ha
            el.CohortsHarvestedPartial = cohortsDamaged;
            el.CohortsHarvestedComplete = cohortsKilled;
            el.CohortsHarvested_ = species_count;

            eventLog.AddObject(el);
            eventLog.WriteToFile();

        }
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:92,代码来源:PlugIn.cs

示例10: Harvest

        //---------------------------------------------------------------------
        
        /// <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("  Prescription {0} is harvesting stand {1}", this.Name, stand.MapCode);

            //set prescription name for stand
            stand.PrescriptionName = this.Name;
            stand.HarvestedRank = PlugIn.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);         

                //  In order for easement prescriptions to properly "spread", we need to count
                //  each site in its area harvested even if no cohorts are damaged.
                //if (SiteVars.CohortsDamaged[site] > 0)
                {
                    stand.LastAreaHarvested += PlugIn.ModelCore.CellArea;
                }    

                //  With land-use, a prescription doesn't necessarily damage a site's cohorts
                //  (for example, an easement prescription).  So, always assign the current
                //  prescription to the site, regardless if any cohorts were damaged.  This
                //  will cause the prescription to appear on the timestep's prescription map.
                SiteVars.Prescription[site] = this;

                if (speciesToPlant != null)
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);

                if (landUseAfterHarvest != null)
                {
                    if (isDebugEnabled)
                    {
                        string landUseBefore = (LandUse.SiteVar[site] == null) ? "(null)" : LandUse.SiteVar[site].Name;
                        log.DebugFormat("    site {0}, land use: {1} --> {2}", site, landUseBefore, landUseAfterHarvest.Name);
                        if (landUseBefore != "forest")
                            log.DebugFormat("     stand rank = {0}", stand.Rank);
                    }
                    LandUse.SiteVar[site] = landUseAfterHarvest;

                    // Now that the site's land-use has changed, set its stand aside for the rest
                    // of the scenario.  Note: because of stand-spreading algorithm, the site may
                    // not belong to the stand that this method was called with.
                    SiteVars.Stand[site].SetAsideUntil(PlugIn.ModelCore.EndTime + 1);
                }
            } 
            return; 
        } 
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:71,代码来源:Prescription.cs

示例11: WriteLogEntry

        //---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int cohortsKilled = 0;
            int standPrescriptionNumber = 0;
            double biomassRemoved = 0.0;
            double biomassRemovedPerHa = 0.0;
            IDictionary<ISpecies, double> totalBiomassBySpecies = new Dictionary<ISpecies, double>();

            //ModelCore.UI.WriteLine("BiomassHarvest:  PlugIn.cs: WriteLogEntry: mgmtArea {0}, Stand {1} ", mgmtArea.Prescriptions.Count, stand.MapCode);

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (HarvestMgmtLib.SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = HarvestMgmtLib.SiteVars.Prescription[site].Number;
                    HarvestMgmtLib.SiteVars.PrescriptionName[site] = HarvestMgmtLib.SiteVars.Prescription[site].Name;
                    HarvestMgmtLib.SiteVars.TimeOfLastEvent[site] = modelCore.CurrentTime;
                }

                cohortsDamaged += Landis.Library.BiomassHarvest.SiteVars.CohortsPartiallyDamaged[site];
                cohortsKilled += (HarvestMgmtLib.SiteVars.CohortsDamaged[site] - Landis.Library.BiomassHarvest.SiteVars.CohortsPartiallyDamaged[site]);

                if (Landis.Library.BiomassHarvest.SiteVars.CohortsPartiallyDamaged[site] > 0 || HarvestMgmtLib.SiteVars.CohortsDamaged[site] > 0)
                {
                    damagedSites++;

                    //Conversion from [g m-2] to [Mg ha-1] to [Mg]
                    biomassRemoved += SiteVars.BiomassRemoved[site] / 100.0 * modelCore.CellArea;
                    IDictionary<ISpecies, int> siteBiomassBySpecies = SiteVars.BiomassBySpecies[site];
                    if (siteBiomassBySpecies != null)
                    {
                        // Sum up total biomass for each species
                        foreach (ISpecies species in modelCore.Species)
                        {
                            int addValue = 0;
                            siteBiomassBySpecies.TryGetValue(species, out addValue);
                            double oldValue;
                            if (totalBiomassBySpecies.TryGetValue(species, out oldValue))
                            {
                                totalBiomassBySpecies[species] += addValue / 100.0 * modelCore.CellArea;
                            }
                            else
                            {
                                totalBiomassBySpecies.Add(species, addValue / 100.0 * modelCore.CellArea);
                            }
                        }
                    }
                }
            }

            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;
            totalCohortsDamaged[standPrescriptionNumber] += cohortsDamaged;
            totalCohortsKilled[standPrescriptionNumber] += cohortsKilled;
            totalBiomassRemoved[standPrescriptionNumber] += biomassRemoved;

            //csv string for log file, contains species affected count
            //string species_count = "";
            //csv string for log file, contains biomass by species
            //string species_biomass = "";
            double[] species_cohorts = new double[modelCore.Species.Count];
            double[] species_biomass = new double[modelCore.Species.Count];

            double biomass_value;
            foreach (ISpecies species in modelCore.Species) {
                int cohortCount = stand.DamageTable[species];
                //species_count += string.Format("{0},", cohortCount);
                species_cohorts[species.Index] = cohortCount;
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
                totalBiomassBySpecies.TryGetValue(species, out biomass_value);
                //species_biomass += string.Format("{0},", biomass_value);
                species_biomass[species.Index] = biomass_value;
                totalSpeciesBiomass[standPrescriptionNumber, species.Index] += biomass_value;
            }

            //Trim trailing comma so we don't add an extra column
            //species_biomass = species_biomass.TrimEnd(',');

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
            if (biomassRemoved > 0.0)
                biomassRemovedPerHa = biomassRemoved / (double) damagedSites / modelCore.CellArea;

            //log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9:0.000},{10:0.000},{11},{12},{13}{14}",
            //              modelCore.CurrentTime,
            //              mgmtArea.MapCode,
            //              stand.PrescriptionName,
            //              stand.MapCode,
            //              stand.EventId,
            //              stand.Age,*
            //              stand.HarvestedRank,*
            //              stand.SiteCount,*
            //              damagedSites,*
            //              biomassRemoved,  // Mg *
            //              biomassRemovedPerHa, // Mg/ha *
//.........这里部分代码省略.........
开发者ID:LANDIS-II-Foundation,项目名称:Extension-Biomass-Harvest,代码行数:101,代码来源:PlugIn.cs

示例12: WriteLogEntry

        //---------------------------------------------------------------------
        public void WriteLogEntry(ManagementArea mgmtArea, Stand stand)
        {
            int damagedSites = 0;
            int cohortsDamaged = 0;
            int standPrescriptionNumber = 0;

            foreach (ActiveSite site in stand) {
                //set the prescription name for this site
                if (SiteVars.Prescription[site] != null)
                {
                    standPrescriptionNumber = SiteVars.Prescription[site].Number;
                    SiteVars.PrescriptionName[site] = SiteVars.Prescription[site].Name;
                    SiteVars.TimeOfLastEvent[site] = PlugIn.ModelCore.CurrentTime;
                }
                int cohortsDamagedAtSite = SiteVars.CohortsDamaged[site];
                cohortsDamaged += cohortsDamagedAtSite;
                if (cohortsDamagedAtSite > 0) {
                    damagedSites++;
                }
            }

            totalSites[standPrescriptionNumber] += stand.SiteCount;
            totalDamagedSites[standPrescriptionNumber] += damagedSites;

            //csv string for log file, contains species kill count
            //string species_count = "";
            double[] species_count = new double[modelCore.Species.Count];

            foreach (ISpecies species in PlugIn.ModelCore.Species)
            {
                int cohortCount = stand.DamageTable[species];
                species_count[species.Index] += cohortCount;
                totalSpeciesCohorts[standPrescriptionNumber, species.Index] += cohortCount;
            }
            //Trim trailing comma so we don't add an extra column
            //species_count = species_count.TrimEnd(',');

            //now that the damage table for this stand has been recorded, clear it!!
            stand.ClearDamageTable();

            //write to log file:
                //current time
                //management area's map code
                //the prescription that caused this harvest
                //stand's map code
                //stand's age
                //stand's current rank
                //total sites in the stand
                //damaged sites from this stand
                //cohorts killed in this stand, by this harvest
            //and only record stands where a site has been damaged
            //log.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
            //              PlugIn.ModelCore.CurrentTime, mgmtArea.MapCode, stand.PrescriptionName, stand.MapCode, stand.EventId,
            //              stand.Age, stand.HarvestedRank, stand.SiteCount, damagedSites, cohortsDamaged, species_count);

            eventLog.Clear();
            EventsLog el = new EventsLog();
            el.Time = modelCore.CurrentTime;
            el.ManagementArea = mgmtArea.MapCode;
            el.Prescription = stand.PrescriptionName;
            el.Stand = stand.MapCode;
            el.EventID = stand.EventId;
            el.StandAge = stand.Age;
            el.StandRank = Convert.ToInt32(stand.HarvestedRank);
            el.NumberOfSites = stand.SiteCount;
            el.HarvestedSites = damagedSites;
            el.TotalCohortsHarvested = cohortsDamaged;
            el.CohortsHarvested_ = species_count;

            eventLog.AddObject(el);
            eventLog.WriteToFile();
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extension-Base-Harvest,代码行数:73,代码来源:PlugIn.cs


注:本文中的Stand.ClearDamageTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。