Beispiel #1
0
        public void singularLandisIteration(int itr, Landis.Extension.Succession.Landispro.pdp ppdp)
        {
            DateTime ltime, time1, time2, time3, time4, ltimeTemp;
            TimeSpan ltimeDiff;

            string fptimeBU = Landis.Extension.Succession.Landispro.PlugIn.fpforTimeBU_name;

            using (StreamWriter fpforTimeBU = File.AppendText(Landis.Extension.Succession.Landispro.PlugIn.fpforTimeBU_name))
            {
                fpforTimeBU.WriteLine("\nProcessing succession at Year: {0}:", itr);

                if (itr % Succession.Landispro.PlugIn.gl_sites.TimeStepFire == 0)
                {
                    itr /= Succession.Landispro.PlugIn.gl_sites.TimeStepFire;

                    ltime = DateTime.Now;
                    Console.WriteLine("\nStart simulating fire disturbance ... at {0}.", ltime);

                    Succession.Landispro.system1.fseed(Succession.Landispro.PlugIn.gl_param.RandSeed + itr / Succession.Landispro.PlugIn.gl_sites.SuccessionTimeStep * 1);

                    time1 = DateTime.Now;
                    pFire.Activate(itr, Succession.Landispro.PlugIn.freq, Succession.Landispro.PlugIn.wAdfGeoTransform);

                    time2 = DateTime.Now;
                    pFire.Activate(itr, Succession.Landispro.PlugIn.freq, Succession.Landispro.PlugIn.wAdfGeoTransform);

                    time3 = DateTime.Now;
                    pFire.Activate(itr, Succession.Landispro.PlugIn.freq, Succession.Landispro.PlugIn.wAdfGeoTransform);

                    time4 = DateTime.Now;
                    pFire.Activate(itr / Succession.Landispro.PlugIn.gl_sites.TimeStepFire, Succession.Landispro.PlugIn.freq, Succession.Landispro.PlugIn.wAdfGeoTransform);


                    ltimeTemp = DateTime.Now;
                    ltimeDiff = ltimeTemp - ltime;
                    Console.WriteLine("Finish simulating fire disturbance at {0} took {1} seconds", DateTime.Now, ltimeDiff);
                    fpforTimeBU.WriteLine("Processing fire: " + ltimeDiff + " seconds");
                }
            }
        }
        public void singularLandisIteration(int itr, Landis.Extension.Succession.Landispro.pdp ppdp)
        {
            DateTime ltime, ltimeTemp;
            TimeSpan ltimeDiff;

            string fptimeBU = Landis.Extension.Succession.Landispro.PlugIn.fpforTimeBU_name;

            using (StreamWriter fpforTimeBU = File.AppendText(Landis.Extension.Succession.Landispro.PlugIn.fpforTimeBU_name))
            {
                fpforTimeBU.WriteLine("\nProcessing succession at Year: {0}:", itr);

                if (itr % Landis.Extension.Succession.Landispro.PlugIn.gl_sites.TimeStepHarvest == 0)
                {
                    Console.WriteLine("\nProcessing harvest events.\n");
                    ltime = DateTime.Now;
                    Harvest.GlobalFunctions.HarvestprocessEvents(itr / Landis.Extension.Succession.Landispro.PlugIn.gl_sites.SuccessionTimeStep);                                 //Global Function
                    putHarvestOutput(itr / Landis.Extension.Succession.Landispro.PlugIn.gl_sites.TimeStepHarvest, Landis.Extension.Succession.Landispro.PlugIn.wAdfGeoTransform); //output img files
                    ltimeTemp = DateTime.Now;
                    ltimeDiff = ltimeTemp - ltime;
                    fpforTimeBU.WriteLine("Processing harvest: " + ltimeDiff + " seconds");
                }
            }
        }
Beispiel #3
0
        public static void HarvestPassInit(Landis.Extension.Succession.Landispro.sites psi, uint isp, string stroutputdir, string strHarvestInitFile, Landis.Extension.Succession.Landispro.pdp pdp)
        {
            string harvestFile           = "";
            string strstandImgMapFile    = "";
            string strmgtAreaImgMapFile  = "";
            string strharvestOutputFile1 = "";
            string strharvestOutputFile2 = "";
            string outputdir;

            outputdir = string.Format("{0}/{1}", stroutputdir, "Harvest");
            Directory.CreateDirectory(outputdir);
            if (!Directory.Exists(outputdir))
            {
                throw new Exception("Harvest: Can't create the direcory");
            }

            int timber;
            int harvest;


            BoundedPocketStandHarvester.pCoresites = psi;
            BoundedPocketStandHarvester.giRow      = (int)BoundedPocketStandHarvester.pCoresites.numRows;
            BoundedPocketStandHarvester.giCol      = (int)BoundedPocketStandHarvester.pCoresites.numColumns;
            //Console.WriteLine(BoundedPocketStandHarvester.giRow);
            //Console.WriteLine(BoundedPocketStandHarvester.giCol);
            //Console.Read();


            BoundedPocketStandHarvester.m_pPDP          = pdp;
            BoundedPocketStandHarvester.numberOfSpecies = (int)isp;

            StreamReader pfHarvest = new StreamReader(strHarvestInitFile);

            string instring;

            string[] sarray;
            instring = pfHarvest.ReadLine();
            timber   = int.Parse(instring);
            instring = pfHarvest.ReadLine();
            harvest  = int.Parse(instring);
            if (harvest != 0)
            {
                instring = pfHarvest.ReadLine();
                sarray   = instring.Split('#');
                BoundedPocketStandHarvester.iParamstandAdjacencyFlag = int.Parse(sarray[0]);
                instring = pfHarvest.ReadLine();
                sarray   = instring.Split('#');
                BoundedPocketStandHarvester.iParamharvestDecadeSpan = int.Parse(sarray[0]);
                instring = pfHarvest.ReadLine();
                sarray   = instring.Split('#');
                BoundedPocketStandHarvester.fParamharvestThreshold = double.Parse(sarray[0]);

                instring    = pfHarvest.ReadLine();
                sarray      = instring.Split('#');
                harvestFile = sarray[0].Substring(0, sarray[0].Length - 1);

                instring           = pfHarvest.ReadLine();
                sarray             = instring.Split('#');
                strstandImgMapFile = sarray[0].Substring(0, sarray[0].Length - 1);

                instring             = pfHarvest.ReadLine();
                sarray               = instring.Split('#');
                strmgtAreaImgMapFile = sarray[0].Substring(0, sarray[0].Length - 1);

                instring = pfHarvest.ReadLine();
                sarray   = instring.Split('#');
                strharvestOutputFile1 = sarray[0].Substring(0, sarray[0].Length - 1);

                instring = pfHarvest.ReadLine();
                sarray   = instring.Split('#');
                strharvestOutputFile2 = sarray[0].Substring(0, sarray[0].Length - 1);
            }

            pfHarvest.Close();

            StreamReader haFile = new StreamReader(harvestFile);

            Console.WriteLine("Build visitation Map");
            BoundedPocketStandHarvester.visitationMap.dim((uint)BoundedPocketStandHarvester.giRow, (uint)BoundedPocketStandHarvester.giCol);
            BoundedPocketStandHarvester.visitationMap.fill(0);

            BoundedPocketStandHarvester.standMap.readImg(strstandImgMapFile, BoundedPocketStandHarvester.giRow, BoundedPocketStandHarvester.giCol);
            BoundedPocketStandHarvester.managementAreaMap.readImg(strmgtAreaImgMapFile, BoundedPocketStandHarvester.giRow, BoundedPocketStandHarvester.giCol);

            BoundedPocketStandHarvester.pstands = new Stands();

            BoundedPocketStandHarvester.pstands.construct();

            BoundedPocketStandHarvester.managementAreas.construct();

            HEventsmode = BoundedPocketStandHarvester.harvestEvents.Read(haFile);

            BoundedPocketStandHarvester.managementAreaMap.freeMAPdata();

            BoundedPocketStandHarvester.pHarvestsites = new HARVESTSites(BoundedPocketStandHarvester.giRow, BoundedPocketStandHarvester.giCol);

            string str;

            str = string.Format("{0}/{1}", outputdir, strharvestOutputFile1);
            BoundedPocketStandHarvester.harvestOutputFile1_name = str;
            using (BoundedPocketStandHarvester.harvestOutputFile1 = new StreamWriter(str))
            {
            }

            str = string.Format("{0}/{1}", outputdir, strharvestOutputFile2);
            BoundedPocketStandHarvester.harvestOutputFile2_name = str;
            using (BoundedPocketStandHarvester.harvestOutputFile2 = new StreamWriter(str))
            {
            }

            haFile.Close();
        }