Utility class for writing biomass-removed maps.
예제 #1
0
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            //event_id = 1;
            HarvestMgmtLib.SiteVars.GetExternalVars();
            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.EventLog, parameters.SummaryLog);
            SiteVars.Initialize();
            Timestep        = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            ModelCore.UI.WriteLine("   Reading management-area map {0} ...", parameters.ManagementAreaMap);
            ManagementAreas.ReadMap(parameters.ManagementAreaMap, managementAreas);

            ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);

            //finish initializing SiteVars
            HarvestMgmtLib.SiteVars.GetExternalVars();

            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()
        {
            //event_id = 1;
            SiteVars.Initialize();
            PartialHarvestDisturbance.Initialize();
            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            ModelCore.UI.WriteLine("   Reading management-area map {0} ...", parameters.ManagementAreaMap);
            ManagementAreas.ReadMap(parameters.ManagementAreaMap, managementAreas);

            ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);
            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;
            }

            log.WriteLine("Time,ManagementArea,Prescription,StandMapCode,EventId,StandAge,StandRank,StandSiteCount,DamagedSites,MgBiomassRemoved,MgBioRemovedPerDamagedHa,CohortsDamaged,CohortsKilled{0}", species_header_names);

            ModelCore.UI.WriteLine("   Opening summary harvest log file \"{0}\" ...", parameters.SummaryLog);

            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);

        }
        //---------------------------------------------------------------------

        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.
            Cohort.AgeOnlyDeathEvent += CohortKilledByAgeOnlyDisturbance;

            ParametersParser parser = new ParametersParser(Model.Core.Species,
                                                           Model.Core.StartTime,
                                                           Model.Core.EndTime);

            BaseHarvest.IParameters baseParameters = Landis.Data.Load<BaseHarvest.IParameters>(dataFile, parser);
            IParameters parameters = baseParameters as IParameters;
            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);
            nameTemplate = 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,ManagementArea,Prescription,StandMapCode,EventId,StandAge,StandRank,StandSiteCount,DamagedSites,MgBiomassRemoved,MgBioRemovedPerDamagedHa,CohortsDamaged,CohortsKilled{0}", species_header_names);

            UI.WriteLine("Opening summary harvest log file \"{0}\" ...", parameters.SummaryLog);

            summaryLog = Data.CreateTextFile(parameters.SummaryLog);
            summaryLog.AutoFlush = true;
            summaryLog.WriteLine("Time,ManagementArea,Prescription,TotalDamagedSites,TotalCohortsDamaged,TotalCohortsKilled{0}", species_header_names);

        }
        //---------------------------------------------------------------------
        public override void Initialize()
        {
            //event_id = 1;
            HarvestMgmtLib.SiteVars.GetExternalVars();
            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.EventLog, parameters.SummaryLog);
            SiteVars.Initialize();
            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            ModelCore.UI.WriteLine("   Reading management-area map {0} ...", parameters.ManagementAreaMap);
            ManagementAreas.ReadMap(parameters.ManagementAreaMap, managementAreas);

            ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);

            //finish initializing SiteVars
            HarvestMgmtLib.SiteVars.GetExternalVars();

            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 = "";
            //    string species_header_names_biomass = "";
            //    int i = 0;
            //    for (i = 0; i < modelCore.Species.Count; i++) {
            //        species_header_names += "," + modelCore.Species[i].Name+"Cohorts";
            //        species_header_names_biomass += "," + modelCore.Species[i].Name + "Mg";
            //    }

            //    log.WriteLine("Time,ManagementArea,Prescription,StandMapCode,EventId,StandAge,StandRank,StandSiteCount,DamagedSites,MgBiomassRemoved,MgBioRemovedPerDamagedHa,CohortsDamaged,CohortsKilled{0}{1}", species_header_names, species_header_names_biomass);

            //    ModelCore.UI.WriteLine("   Opening summary harvest log file \"{0}\" ...", parameters.SummaryLog);

            //    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,TotalBiomassRemovedMg,TotalCohortsDamaged,TotalCohortsKilled{0}{1}", species_header_names, species_header_names_biomass);
        }