コード例 #1
0
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            modelCore.UI.WriteLine("   Creating metadata ...");
            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.BiomassMapNames, modelCore);
            SiteVars.Initialize();
            PartialHarvestDisturbance.Initialize();

            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            
            //read management area map
            modelCore.UI.WriteLine("   Reading management-area map {0} ...", parameters.ManagementAreaMap);
            ManagementAreas.ReadMap(parameters.ManagementAreaMap, managementAreas);

            
            //  readMap reads the stand map and adds all the stands to a management area
            modelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);
            
            //finish each managementArea's initialization
            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);
            nameTemplate = parameters.PrescriptionMapNames;
            if (parameters.BiomassMapNames != null)
                biomassMaps = new BiomassMaps(parameters.BiomassMapNames);


        }
コード例 #2
0
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            SiteVars.Initialize();
            PartialHarvestDisturbance.Initialize();

            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            
            //read management area map
            modelCore.UI.WriteLine("   Reading management-area map {0} ...", parameters.ManagementAreaMap);
            ManagementAreas.ReadMap(parameters.ManagementAreaMap, managementAreas);

            
            //  readMap reads the stand map and adds all the stands to a management area
            modelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);
            
            //finish each managementArea's initialization
            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);
            nameTemplate = parameters.PrescriptionMapNames;
            if (parameters.BiomassMapNames != null)
                biomassMaps = new BiomassMaps(parameters.BiomassMapNames);

            //open log file and write header
            modelCore.UI.WriteLine("   Opening harvest log file \"{0}\" ...", parameters.EventLog);
            try
            {
                log = Landis.Data.CreateTextFile(parameters.EventLog);
            }
            catch (Exception err)
            {
                string mesg = string.Format("{0}", err.Message);
                throw new System.ApplicationException(mesg);
            }
            log.AutoFlush = true;
            
            //include a column for each species in the species dictionary
            string species_header_names = "";
            int i = 0;
            for (i = 0; i < modelCore.Species.Count; i++) {
                species_header_names += "," + modelCore.Species[i].Name;
            }

            modelCore.UI.WriteLine("   Opening summary harvest log file \"{0}\" ...", parameters.SummaryLog);
            log.WriteLine("Time,ManagementArea,Prescription,StandMapCode,EventId,StandAge,StandRank,StandSiteCount,DamagedSites,MgBiomassRemoved,MgBioRemovedPerDamagedHa,CohortsDamaged,CohortsKilled{0}", species_header_names);

            try
            {
                summaryLog = Landis.Data.CreateTextFile(parameters.SummaryLog);
            }
            catch (Exception err)
            {
                string mesg = string.Format("{0}", err.Message);
                throw new System.ApplicationException(mesg);
            }
            summaryLog.AutoFlush = true;
            summaryLog.WriteLine("Time,ManagementArea,Prescription,TotalDamagedSites,TotalCohortsDamaged,TotalCohortsKilled{0}", species_header_names);

        }
コード例 #3
0
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        PlugIns.ICore modelCore)
        {
            // Initialize the Base Harvest's Model.Core property.
            // HACK: Because that property is internal, we must
            // call the Initialize method on an instance of Base
            // Harvest's PlugIn class.  But don't want that
            // Initialize method parsing the data file.  So we
            // pass in a null string to force an exception to
            // be raised; hence aborting the initialization at
            // a point that's acceptable.
            PlugIns.PlugIn baseHarvest = new BaseHarvest.PlugIn();
            try {
                baseHarvest.Initialize(null, modelCore);
            }
            catch (System.ArgumentNullException) {
                // ignore
            }

            Model.Core = modelCore;
            PartialHarvestDisturbance.Initialize();
            SiteVars.Initialize();

            // Add local event handler for cohorts death due to age-only
            // disturbances.
            Biomass.Cohort.AgeOnlyDeathEvent += CohortKilledByAgeOnlyDisturbance;
            
            InputParametersParser parser = new InputParametersParser(Model.Core.Species,
                                                           Model.Core.StartTime,
                                                           Model.Core.EndTime);
            
            BaseHarvest.IParameters baseParameters = Landis.Data.Load<BaseHarvest.IParameters>(dataFile, parser);
            IInputParameters parameters = baseParameters as IInputParameters;
            if (parser.RoundedRepeatIntervals.Count > 0) {
                UI.WriteLine("NOTE: The following repeat intervals were rounded up to");
                UI.WriteLine("      ensure they were multiples of the harvest timestep:");
                UI.WriteLine("      File: {0}", dataFile);
                foreach (RoundedInterval interval in parser.RoundedRepeatIntervals)
                    UI.WriteLine("      At line {0}, the interval {1} rounded up to {2}",
                                 interval.LineNumber,
                                 interval.Original,
                                 interval.Adjusted);
            }
            //set timestep
            Timestep = parameters.Timestep;
            //set management areas
            managementAreas = parameters.ManagementAreas;
            UI.WriteLine("Reading management-area map {0} ...", parameters.ManagementAreaMap);
            //read management area map
            ManagementAreas.ReadMap(parameters.ManagementAreaMap,
                                    managementAreas);

            UI.WriteLine("Reading stand map {0} ...", parameters.StandMap);
            //readMap reads the stand map and adds all the stands to a management area
            Stands.ReadMap(parameters.StandMap);
            //finish each managementArea's initialization
            foreach (ManagementArea mgmtArea in managementAreas)
                //after reading the stand map, finish the initializations
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);
            if (parameters.BiomassMapNames != null)
                biomassMaps = new BiomassMaps(parameters.BiomassMapNames);

            //open log file and write header
            UI.WriteLine("Opening harvest log file \"{0}\" ...", parameters.EventLog);
            log = Data.CreateTextFile(parameters.EventLog);
            log.AutoFlush = true;
            //include a column for each species in the species dictionary
            string species_header_names = "";
            int i = 0;
            for (i = 0; i < Model.Core.Species.Count; i++) {
                species_header_names += Model.Core.Species[i].Name + ",";
            }
            
            log.WriteLine("Time,Management Area,Prescription,Stand,Event Id,Stand Age,Stand Rank,Total Sites,Damaged Sites,Cohorts Killed,{0}", species_header_names);
            
        }