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

        /// <summary>
        /// Initializes a new instance for a set of species cohorts.
        /// </summary>
        public OldToYoungIterator(SpeciesCohorts cohorts)
        {
            this.cohorts           = cohorts;
            this.nextIndex         = 0;
            this.currentCohortDied = false;
            MoveNext();
        }
예제 #2
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Creates a copy of a species' cohorts.
        /// </summary>
        public SpeciesCohorts Clone()
        {
            SpeciesCohorts clone = new SpeciesCohorts(this.species);

            clone.cohortData      = new List <CohortData>(this.cohortData);
            clone.isMaturePresent = this.isMaturePresent;
            return(clone);
        }
예제 #3
0
        public static void SpeciesSiteRD(Landis.Library.DensityCohorts.SpeciesCohorts speciesCohorts, ActiveSite site)
        {
            float siteRD = 0;

            ISpeciesDensity speciesDensity = SpeciesParameters.SpeciesDensity.AllSpecies[speciesCohorts.Species.Index];

            //foreach (Landis.Library.DensityCohorts.ICohort cohort in speciesCohorts)
            for (int s = 0; s < speciesCohorts.Count; s++)
            {
                Landis.Library.DensityCohorts.ICohort cohort = speciesCohorts[s];
                double tmp_term1 = Math.Pow((cohort.Diameter / 25.4), 1.605);
                float  tmp_term2 = 10000 / speciesDensity.MaxSDI;
                int    tmp_term3 = cohort.Treenumber;
                double tmp       = tmp_term1 * tmp_term2 * tmp_term3 / Math.Pow(EcoregionData.ModelCore.CellLength, 2);
                siteRD += (float)tmp;
            }

            SiteVars.SiteRD[site] = siteRD;
            //return siteRD;
        }
        public SiteCohorts(DateTime StartDate, ActiveSite site, Landis.Library.DensityCohorts.InitialCommunities.ICommunity initialCommunity, bool usingClimateLibrary, string SiteOutputName = null)
        {
            //Cohort.SetSiteAccessFunctions(this);
            this.Ecoregion = EcoregionData.ModelCore.Ecoregion[site];
            this.Site      = site;

            cohorts = new Dictionary <ISpecies, List <Cohort> >();
            SpeciesEstablishedByPlant    = new List <ISpecies>();
            SpeciesEstablishedBySerotiny = new List <ISpecies>();
            SpeciesEstablishedByResprout = new List <ISpecies>();
            SpeciesEstablishedBySeed     = new List <ISpecies>();
            CohortsKilledBySuccession    = new List <int>(new int[EcoregionData.ModelCore.Species.Count()]);
            CohortsKilledByHarvest       = new List <int>(new int[EcoregionData.ModelCore.Species.Count()]);
            CohortsKilledByFire          = new List <int>(new int[EcoregionData.ModelCore.Species.Count()]);
            CohortsKilledByWind          = new List <int>(new int[EcoregionData.ModelCore.Species.Count()]);
            CohortsKilledByOther         = new List <int>(new int[EcoregionData.ModelCore.Species.Count()]);

            uint key = ComputeKey((ushort)initialCommunity.MapCode, EcoregionData.ModelCore.Ecoregion[site].MapCode);

            if (initialSites.ContainsKey(key) && SiteOutputName == null)
            {
                foreach (ISpecies spc in initialSites[key].cohorts.Keys)
                {
                    foreach (Cohort cohort in initialSites[key].cohorts[spc])
                    {
                        AddNewCohort(new Cohort(cohort));
                    }
                }
            }
            else
            {
                if (initialSites.ContainsKey(key) == false)
                {
                    initialSites.Add(key, this);
                }


                bool densityProvided = false;
                foreach (Landis.Library.DensityCohorts.ISpeciesCohorts speciesCohorts in initialCommunity.Cohorts)
                {
                    foreach (Landis.Library.DensityCohorts.ICohort cohort in speciesCohorts)
                    {
                        //FIXME
                        if (cohort.Treenumber > 0)  // 0 Biomass indicates treenumber value was not read in
                        {
                            densityProvided = true;
                            break;
                        }
                    }
                }

                if (densityProvided)
                {
                    foreach (Landis.Library.DensityCohorts.ISpeciesCohorts speciesCohorts in initialCommunity.Cohorts)
                    {
                        //foreach (Landis.Library.DensityCohorts.ICohort cohort in speciesCohorts)
                        int cohortIndex = 0;
                        foreach (Landis.Library.DensityCohorts.ICohort cohort in speciesCohorts)
                        {
                            AddNewCohort(new Cohort(cohort.Species, cohort.Age, cohort.Treenumber, SiteOutputName, (ushort)(StartDate.Year - cohort.Age), Ecoregion));
                            //AddNewCohort(new Cohort(SpeciesParameters.SpeciesDensity[cohort.Species], cohort.Age, cohort.Treenumber, SiteOutputName, (ushort)(StartDate.Year - cohort.Age), Ecoregion));
                            //ISpeciesDensity speciespnet = PlugIn.SpeciesDensity[cohort.Species];

                            //SpeciesCohorts spCo = (SpeciesCohorts)speciesCohorts;
                            //CohortData coData = spCo.cohortData[0];

                            //coData.Biomass = cohort.Biomass;
                            cohortIndex++;
                        }
                        // BRM - Add function to update biomass values ??
                        SpeciesCohorts spCo = (SpeciesCohorts)speciesCohorts;
                        spCo.UpdateDiameterAndBiomass(Ecoregion);
                    }
                }
                else
                {
                    throw new System.Exception("Error in initial community data - cohort tree numbers must be provided");
                }
            }
        }