Esempio n. 1
0
        public void copy(site s)
        {
            if (s == null)
            {
                return;
            }

            rd                    = s.rd;
            maxAge                = s.maxAge;
            numofsites            = s.numofsites;
            highestShadeTolerance = s.highestShadeTolerance;

            base.copy(s.all_species, site.numSpec);
        }
Esempio n. 2
0
        //start killing trees gradually at the 80 % longevity until they reach their longevity
        // modified version of function : void SUCCESSION::kill(SPECIE *s, SPECIESATTR *sa)
        public static void KillTrees(uint local_r, uint local_c)
        {
            site local_site = gl_sites[local_r, local_c];

            for (int k = 1; k <= specAtNum; ++k)//sites.specNum
            {
                int longev = gl_spe_Attrs[k].Longevity;

                int numYears = longev / 5;

                float chanceMod = 0.8f / (numYears + 0.00000001f);

                float chanceDeath = 0.2f;

                int m_beg = (longev - numYears) / gl_sites.SuccessionTimeStep;
                int m_end = longev / gl_sites.SuccessionTimeStep;

                specie local_specie = local_site.SpecieIndex(k);

                for (int m = m_beg; m <= m_end; m++)
                {
                    int tmpTreeNum = (int)local_specie.getTreeNum(m, k);

                    int tmpMortality = 0;

                    if (tmpTreeNum > 0)
                    {
                        float local_threshold = chanceDeath * gl_sites.SuccessionTimeStep / 10;

                        for (int x = 1; x <= tmpTreeNum; x++)
                        {
                            if (system1.frand() < local_threshold)
                            {
                                tmpMortality++;
                            }
                        }
                        local_specie.setTreeNum(m, k, Math.Max(0, tmpTreeNum - tmpMortality));
                    }

                    chanceDeath += chanceMod;
                }
            }
        }
Esempio n. 3
0
        public static void succession_Landis70(pdp ppdp, int itr)
        {
            gl_sites.GetMatureTree();

            //increase ages
            for (uint i = 1; i <= snr; ++i)
            {
                for (uint j = 1; j <= snc; ++j)
                {
                    ppdp.addedto_sTSLMortality(i, j, (short)gl_sites.SuccessionTimeStep);

                    //define land unit
                    landunit l = gl_sites.locateLanduPt(i, j);

                    if (l != null && l.active())
                    {
                        site local_site = gl_sites[i, j];

                        for (int k = 1; k <= specAtNum; ++k)
                        {
                            local_site.SpecieIndex(k).GrowTree();
                        }
                    }
                }
                //Console.ReadLine();
            }

            //seed dispersal
            initiateRDofSite_Landis70();
            Console.WriteLine("Seed Dispersal:");


            for (uint i = 1; i <= snr; ++i)
            {
                //Console.WriteLine("\n{0}%\n", 100 * i / snr);

                for (uint j = 1; j <= snc; ++j)
                {
                    //Console.WriteLine("i = {0}, j = {1}", i, j);
                    landunit l = gl_sites.locateLanduPt(i, j);

                    KillTrees(i, j);
                    if (itr == 90 && i == 193 && j == 156)
                    {
                        Console.WriteLine("watch: {0}:{1}", "kill trees", gl_sites[193, 156].SpecieIndex(2).getAgeVector(1));
                    }
                    if (l != null && l.active())
                    {
                        float local_RD = gl_sites[i, j].RD;

                        if (local_RD < l.MaxRDArray(0))
                        {
                            gl_sites.SiteDynamics(0, i, j);
                        }

                        else if (local_RD >= l.MaxRDArray(0) && local_RD < l.MaxRDArray(1))
                        {
                            gl_sites.SiteDynamics(1, i, j);
                        }

                        else if (local_RD >= l.MaxRDArray(1) && local_RD <= l.MaxRDArray(2))
                        {
                            gl_sites.SiteDynamics(2, i, j);
                        }

                        else if (local_RD > l.MaxRDArray(2) && local_RD <= l.MaxRDArray(3))
                        {
                            gl_sites.SiteDynamics(3, i, j);
                        }

                        else
                        {
                            Debug.Assert(local_RD > l.MaxRDArray(3));
                            gl_sites.SiteDynamics(4, i, j);
                        }
                    }
                }
            }
            Console.WriteLine("end succession_Landis70 once");
        }
Esempio n. 4
0
        //This will perform a reclassification based upon the oldest cohort upon a landis stand.
        //The cohorts will be scaled into 16 age classes.
        public static void ageReclass(map8 m)
        {
            m.dim(snr, snc);

            m.rename("Age class representation");

            for (uint j = 1; j < map8.MapmaxValue; j++)
            {
                m.assignLeg(j, "");
            }


            string str;

            //J.Yang hard coding changing itr*sites.TimeStep to itr
            //J.Yang maxLeg is defined as 256 in map8.h, therefore, maximum age cohorts it can output is 254
            for (uint i = 1; i < map8.MaxValueforLegend - 4; i++)
            {
                str = string.Format("{0:   } - {1:   } yr", (i - 1) * time_step + 1, i * time_step);

                m.assignLeg(i, str);
            }


            m.assignLeg(0, "NoSpecies");

            m.assignLeg(map8.MaxValueforLegend - 1, "N/A");
            m.assignLeg(map8.MaxValueforLegend - 2, "Water");
            m.assignLeg(map8.MaxValueforLegend - 3, "NonForest");

            str = string.Format("	  >{0:   } yr", (map8.MaxValueforLegend - 4 - 1) * time_step);
            m.assignLeg(map8.MaxValueforLegend - 4, str);

            for (uint i = snr; i >= 1; i--)
            {
                for (uint j = 1; j <= snc; j++)
                {
                    if (PlugIn.gl_sites.locateLanduPt(i, j).active())
                    {
                        m[i, j] = 0;

                        uint myage = 0;

                        site local_site = PlugIn.gl_sites[i, j];

                        specie s = local_site.first();

                        while (s != null)
                        {
                            uint temp = s.oldest();

                            if (temp > myage)
                            {
                                myage = temp;
                            }

                            s = local_site.next();
                        }

                        m[i, j] = (ushort)(myage / time_step);
                    }

                    else if (PlugIn.gl_sites.locateLanduPt(i, j).lowland())
                    {
                        m[i, j] = (ushort)(map8.MaxValueforLegend - 3);
                    }

                    else if (PlugIn.gl_sites.locateLanduPt(i, j).water())
                    {
                        m[i, j] = (ushort)(map8.MaxValueforLegend - 2);
                    }

                    else
                    {
                        m[i, j] = (ushort)(map8.MaxValueforLegend - 1);
                    }
                }
            }
        }
Esempio n. 5
0
        //This will reclassify a singular site.  M is the number of possible output classes.
        private int reclassifySite(site site_in, int m)
        {
            float[] sval = new float[MAX_RECLASS];

            specie local_specie = site_in.first();

            int j = 1;

            while (local_specie != null)
            {
                float c = (float)local_specie.oldest() / maximum[j - 1];

                if (c > 1.0)
                {
                    c = 1.0f;
                }

                for (int i = 1; i <= m; i++)
                {
                    if (BOOL[i, j] != 0)
                    {
                        if (BOOL[i, j] > 0)
                        {
                            sval[i] += c;
                        }
                        else
                        {
                            sval[i] -= c;
                        }


                        if (sval[i] != 0)
                        {
                            if (sval[i] > 1.0)
                            {
                                sval[i] = 1.0f;
                            }

                            if (sval[i] < 0.0)
                            {
                                sval[i] = 0.0f;
                            }
                        }
                    }
                }

                j++;

                local_specie = site_in.next();
            }



            int mx = 0;

            float mxVal = 0.0f;

            for (int i = 1; i <= m; i++)
            {
                if (sval[i] > mxVal)
                {
                    mxVal = sval[i];

                    mx = i;
                }
            }


            if (mxVal > 0.0)
            {
                return(mx);
            }
            else
            {
                return(m + 1);
            }
        }