public void UpdateEstData(DateTime date, SiteConditions sc)
        {
            //System.Console.WriteLine("UpdateEstData");

            string s = date.Year.ToString() + delim +
                     date.Month + delim +
                     date.ToString("MM/yyyy") + delim +
                     sc.hydrology.Water + delim +
                     sc.SubCanopyPAR + delim;

            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                s += sc.Establishment.Pest[spc] + delim ;
            }
            /*
            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                s +=   sc.Establishment.PotEstablishments[spc] + delim;
            }
            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                s += sc.Establishment.Establishments[spc] + delim;
            }
             */
            FileContent.Add(s);

            System.IO.File.WriteAllLines(OutputSiteFileName(site), FileContent.ToArray());
        }
Ejemplo n.º 2
0
        public void UpdateSiteData(DateTime date, SiteConditions sc)
        {
            IEcoregion ecoregion = PlugIn.modelCore.Ecoregion[sc.Site];

            string s = date.Year.ToString() + delim +
                       date.Month + delim +
                       date.ToString("MM/yyyy") + delim +
                       sc.NrOfCohorts + delim +
                       StaticVariables.Tday[ecoregion, date] + delim +
                       StaticVariables.Prec[ecoregion, date] + delim +
                       sc.hydrology.RunOff + delim +
                       sc.hydrology.Transpiration + delim +
                       sc.hydrology.PrecipLoss + delim +
                       sc.hydrology.Water + delim +
                       sc.hydrology.SnowPack + delim +
                       sc.CanopyLAImax + delim +
                       StaticVariables.VPD[ecoregion, date] + delim +
                       sc.GrossPsn + delim +
                       sc.NetPsn + delim +
                       sc.AutotrophicRespiration + delim +
                       sc.forestfloor.HeterotrophicRespiration + delim +
                       sc.TotalBiomass + delim +
                       sc.TotalRoot + delim +
                       sc.TotalFoliage + delim +
                       sc.TotalNSC + delim +
                       sc.Litter.Mass + delim +
                       sc.WoodyDebris.Mass;

            FileContent.Add(s);
        }
        public void UpdateSiteData(DateTime date, SiteConditions sc)
        {
            IEcoregion ecoregion = PlugIn.modelCore.Ecoregion[sc.Site];

            string s = date.Year.ToString() + delim +
                     date.Month + delim +
                     date.ToString("MM/yyyy") + delim +
                     sc.NrOfCohorts + delim +
                     StaticVariables.Tday[ecoregion, date] + delim +
                     StaticVariables.Prec[ecoregion, date] + delim +
                     sc.hydrology.RunOff + delim +
                     sc.hydrology.Transpiration + delim +
                     sc.hydrology.PrecipLoss + delim +
                     sc.hydrology.Water + delim +
                     sc.hydrology.SnowPack + delim +
                     sc.CanopyLAImax + delim +
                     StaticVariables.VPD[ecoregion, date] + delim +
                     sc.GrossPsn + delim +
                     sc.NetPsn + delim +
                     sc.AutotrophicRespiration + delim +
                     sc.forestfloor.HeterotrophicRespiration + delim +
                     sc.TotalBiomass + delim +
                     sc.TotalRoot + delim +
                     sc.TotalFoliage + delim +
                     sc.TotalNSC + delim +
                     sc.Litter.Mass + delim +
                     sc.WoodyDebris.Mass;

            FileContent.Add(s);
        }
Ejemplo n.º 4
0
        public void UpdateEstData(DateTime date, SiteConditions sc)
        {
            //System.Console.WriteLine("UpdateEstData");

            string s = date.Year.ToString() + delim +
                       date.Month + delim +
                       date.ToString("MM/yyyy") + delim +
                       sc.hydrology.Water + delim +
                       sc.SubCanopyPAR + delim;

            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                s += sc.Establishment.Pest[spc] + delim;
            }

            /*
             * foreach (ISpecies spc in PlugIn.modelCore.Species)
             * {
             *  s +=   sc.Establishment.PotEstablishments[spc] + delim;
             * }
             * foreach (ISpecies spc in PlugIn.modelCore.Species)
             * {
             *  s += sc.Establishment.Establishments[spc] + delim;
             * }
             */
            FileContent.Add(s);

            System.IO.File.WriteAllLines(OutputSiteFileName(site), FileContent.ToArray());
        }
Ejemplo n.º 5
0
        public SiteConditions(ActiveSite site, ICommunity initialCommunity)
        {
            cohorts = new SiteCohorts();

            canopy = new Canopy();
            if (PlugIn.HasSiteOutput[site] == true)
            {
                siteoutput = new SiteOutput(site);
                estoutput  = new EstablishmentOutput(site);
            }

            this.site = site;


            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                deadcohortages[spc] = new List <int>();
            }

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

            SiteConditions s = GetFromKey(key);

            if (s != null)
            {
                return;
            }

            //  If we don't have a sorted list of age cohorts for the initial
            //  community, make the list

            List <Landis.Library.AgeOnlyCohorts.ICohort> sortedAgeCohorts;

            if (!sortedCohorts.TryGetValue(initialCommunity.MapCode, out sortedAgeCohorts))
            {
                sortedAgeCohorts = PlugIn.RankCohortAgesOldToYoung(initialCommunity.Cohorts);
                sortedCohorts[initialCommunity.MapCode] = sortedAgeCohorts;
            }
            hydrology     = new Hydrology(PlugIn.modelCore.Ecoregion[site]);
            forestfloor   = new ForestFloor();
            cohorts       = new SiteCohorts();
            establishment = new EstablishmentProbability(site);


            if (sortedAgeCohorts.Count == 0)
            {
                return;
            }

            //PlugIn.ModelCore.UI.WriteLine("Making Biomass Cohorts "+ site);
            BiomassSpinUp(sortedAgeCohorts, site);

            initialSites[key] = this;
            return;
        }
Ejemplo n.º 6
0
        public SiteConditions GetFromKey(uint key)
        {
            SiteConditions s = null;

            if (initialSites.TryGetValue(key, out s) && siteoutput == null)
            {
                hydrology     = s.hydrology;
                establishment = s.Establishment;

                cohorts = new SiteCohorts();
                foreach (ISpeciesCohorts speciesCohorts in s.cohorts)
                {
                    foreach (Cohort cohort in speciesCohorts)
                    {
                        Cohort newcohort = new Cohort(cohort);
                        cohorts.AddNewCohort(newcohort, PlugIn.TStep);
                    }
                }
                forestfloor  = s.forestfloor;
                canopylaimax = s.CanopyLAImax;
            }
            return(s);
        }
        public void ComputeEstablishment(DateTime date, SiteConditions sc)
        {
            double frad;
            double fwater;
            double w = sc.hydrology.Water / Porosity[PlugIn.modelCore.Ecoregion[site]];

            // number of months that est is possible for stat purposes
            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                if (StaticVariables.PossibleEstmonth[PlugIn.modelCore.Ecoregion[sc.Site], spc, date] == false)
                {
                    Pest[spc] = 0;
                    continue;
                }

                double v = Math.Min(1, sc.SubCanopyPAR / (2 * HalfSat[spc]));

                if (v > 1 || v < 0)
                {
                    throw new System.Exception("Error, subcanopy radiation cannot be " + sc.SubCanopyPAR);
                }
                if (w > 1 || w < 0)
                {
                    throw new System.Exception("Error, bulk water cannot be " + sc.hydrology.Water);
                }

                frad   = Math.Pow(v, EstRad[spc]);
                fwater = Math.Pow(w, EstMoist[spc]);

                Pest[spc] = 1 - (float)Math.Pow((1 - (float)Math.Min(1.0, frad * fwater)), (1 / (PlugIn.TStep * (float)PossibleEstmonthCount(date, spc, ecoregion))));

                if (Pest[spc] > (float)R.NextDouble())
                {
                    PotEstablishments[spc] = 1;
                }
            }
        }
Ejemplo n.º 8
0
        //---------------------------------------------------------------------
        public override void Initialize()
        {
            PlugIn.ModelCore.UI.WriteLine("Initializing " + ExtensionName + " version " + typeof(PlugIn).Assembly.GetName().Version);

            /*Testing
             * Landis.Library.BiomassCohorts.Cohort C;
             * Cohort D;
             *
             * C = (Landis.Library.BiomassCohorts.Cohort)D;
             */


            hassiteoutput  = parameters.HasSiteOutput;
            siteconditions = PlugIn.ModelCore.Landscape.NewSiteVar <SiteConditions>();
            Edu.Wisc.Forest.Flel.Util.Directory.EnsureExists("output");

            //CohortOutput.Initialize(parameters);
            Hydrology.Initialize(parameters);
            StaticVariables.InitializeStatic(parameters);
            ForestFloor.Initialize(parameters);
            SiteConditions.Initialize(parameters);
            CohortBiomass.Initialize(parameters);

            Timestep = parameters.Timestep;
            tstep    = parameters.Timestep;

            // Initialize Reproduction routines:
            Reproduction.SufficientResources = SufficientResources;
            Reproduction.Establish           = Establish;
            Reproduction.AddNewCohort        = AddNewCohort;
            Reproduction.MaturePresent       = MaturePresent;
            Reproduction.PlantingEstablish   = PlantingEstablish;
            base.Initialize(modelCore, parameters.SeedAlgorithm);
            Cohort.DeathEvent += CohortDied;

            StartDate = new System.DateTime(parameters.StartYear, 1, 15);

            year  = StartDate.Year;
            month = StartDate.Month;

            InitializeSites(parameters.InitialCommunities, parameters.InitialCommunitiesMap, modelCore);

            EstablishmentProbability.Initialize(parameters);

            ISiteVar <ISiteCohorts> cohorts = PlugIn.ModelCore.Landscape.NewSiteVar <ISiteCohorts>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                cohorts[site] = siteconditions[site].Cohorts;
            }

            BiomassCohorts = new BiomassCohortsSiteVar(cohorts);
            baseCohorts    = new Landis.Library.Biomass.BaseCohortsSiteVar(BiomassCohorts);

            PlugIn.ModelCore.RegisterSiteVar(BiomassCohorts, "Succession.BiomassCohorts");

            PlugIn.ModelCore.RegisterSiteVar(siteconditions, "Succession.SiteConditionsPnET");
            PlugIn.ModelCore.RegisterSiteVar(baseCohorts, "Succession.AgeCohorts");


            ISiteVar <Pool> WoodyDebris = PlugIn.ModelCore.Landscape.NewSiteVar <Pool>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                WoodyDebris[site] = siteconditions[site].WoodyDebris;
            }
            PlugIn.ModelCore.RegisterSiteVar(WoodyDebris, "Succession.WoodyDebris");

            ISiteVar <Pool> Litter = PlugIn.ModelCore.Landscape.NewSiteVar <Pool>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                Litter[site] = siteconditions[site].WoodyDebris;
            }
            PlugIn.ModelCore.RegisterSiteVar(Litter, "Succession.Litter");
        }
Ejemplo n.º 9
0
 //---------------------------------------------------------------------
 protected override void InitializeSite(ActiveSite site,
                                        ICommunity initialCommunity)
 {
     siteconditions[site] = new SiteConditions(site, initialCommunity);
 }
 //---------------------------------------------------------------------
 protected override void InitializeSite(ActiveSite site,
                                        ICommunity initialCommunity)
 {
     siteconditions[site] = new SiteConditions(site, initialCommunity);
 }
        public void ComputeEstablishment( DateTime date, SiteConditions sc)
        {
            double frad;
            double fwater;
            double w = sc.hydrology.Water / Porosity[PlugIn.modelCore.Ecoregion[site]];

            // number of months that est is possible for stat purposes
            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                if (StaticVariables.PossibleEstmonth[PlugIn.modelCore.Ecoregion[sc.Site], spc, date] == false)
                {
                    Pest[spc] = 0;
                    continue;
                }

                double v= Math.Min(1, sc.SubCanopyPAR / (2 * HalfSat[spc]));

                if (v > 1 || v < 0) throw new System.Exception("Error, subcanopy radiation cannot be " + sc.SubCanopyPAR);
                if (w > 1 || w < 0) throw new System.Exception("Error, bulk water cannot be " + sc.hydrology.Water);

                frad = Math.Pow(v, EstRad[spc]);
                fwater = Math.Pow(w, EstMoist[spc]);

                Pest[spc] = 1 - (float)Math.Pow((1 - (float)Math.Min(1.0, frad * fwater)), (1 / (PlugIn.TStep * (float)PossibleEstmonthCount(date, spc, ecoregion))));

                if (Pest[spc] > (float)R.NextDouble())
                {
                    PotEstablishments[spc] = 1;
                }
            }
        }