Beispiel #1
0
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            //initialize event id
            event_id = 1;

            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.EventLog, parameters.SummaryLog);
            Timestep        = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            PlugIn.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
            PlugIn.ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);

            //finish initializing SiteVars
            SiteVars.GetExternalVars();

            //finish each managementArea's initialization
            //after reading the stand map, finish the initializations
            foreach (ManagementArea mgmtArea in managementAreas)
            {
                mgmtArea.FinishInitialization();
            }

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);
        }
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        PlugIns.ICore modelCore)
        {
            Model.Core = modelCore;
            SiteVars.Initialize();

            ParametersParser parser = new ParametersParser(Model.Core.StartTime,
                                                           Model.Core.EndTime);
            IParameters parameters = Landis.Data.Load<IParameters>(dataFile, parser);

            Timestep = parameters.Timestep;

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

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

            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);

            UI.WriteLine("Opening harvest log file \"{0}\" ...", parameters.EventLog);
            log = Data.CreateTextFile(parameters.EventLog);
            log.AutoFlush = true;
            log.WriteLine("Time,Stand,Total Sites,Damaged Sites,Cohorts Killed");
        }
        //---------------------------------------------------------------------

        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);
            }
        }
        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string                 path,
                                   IManagementAreaDataset managementAreas)
        {
            List<ushort> inactiveMgmtAreas = new List<ushort>();

            IInputRaster<MapCodePixel> map = Model.Core.OpenRaster<MapCodePixel>(path);
            using (map) {
                // TODO: make sure its dimensions match landscape's dimensions
                foreach (Site site in Model.Core.Landscape.AllSites) {
                    MapCodePixel pixel = map.ReadPixel();
                    if (site.IsActive) {
                        ushort mapCode = pixel.Band0;
                        ManagementArea mgmtArea = managementAreas.Find(mapCode);
                        if (mgmtArea == null) {
                            inactiveMgmtAreas.Add(mapCode);
                        }
                        else {
                            mgmtArea.OnMap = true;
                            SiteVars.ManagementArea[site] = mgmtArea;
                        }
                    }
                }
            }

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0) {
                UI.WriteLine("Inactive management areas: {0}",
                             MapCodesToString(inactiveMgmtAreas));
            }
        }
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        PlugIns.ICore modelCore)
        {
            //initialize event id
            event_id = 1;

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

            IParameters parameters = Landis.Data.Load<IParameters>(dataFile, parser);
            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);

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

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

        public override void Initialize()
        {
            //initialize event id
            event_id = 1;
            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            PlugIn.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
            PlugIn.ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);

            //finish each managementArea's initialization
            //after reading the stand map, finish the initializations
            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);

            //open log file and write header
            PlugIn.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 < PlugIn.ModelCore.Species.Count; i++) {
                species_header_names += PlugIn.ModelCore.Species[i].Name + ",";
            }

            log.WriteLine("Time,ManagementArea,Prescription,Stand,EventId,StandAge,StandRank,NumberOfSites,HarvestedSites,CohortsKilled,{0}", species_header_names);

            PlugIn.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,HarvestedSites,{0}", species_header_names);

            Landis.Library.LandUses.LandUse.Initialize(modelCore);
        }
        //---------------------------------------------------------------------

        public Parameters(int                    timestep,
                          string                 managementAreaMap,
                          IManagementAreaDataset managementAreas,
                          string                 standMap)
        {
            this.timestep = timestep;
            this.managementAreaMap = managementAreaMap;
            this.managementAreas = managementAreas;
            this.standMap = standMap;
        }
Beispiel #8
0
        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string path,
                                   IManagementAreaDataset managementAreas)
        {
            IInputRaster <UIntPixel> map;

            try {
                map = Model.Core.OpenRaster <UIntPixel>(path);
            }
            catch (FileNotFoundException) {
                string mesg = string.Format("Error: The file {0} does not exist", path);
                throw new System.ApplicationException(mesg);
            }

            if (map.Dimensions != Model.Core.Landscape.Dimensions)
            {
                string mesg = string.Format("Error: The input map {0} does not have the same dimension (row, column) as the ecoregions map", path);
                throw new System.ApplicationException(mesg);
            }

            List <uint> inactiveMgmtAreas = new List <uint>();

            using (map) {
                UIntPixel pixel = map.BufferPixel;
                foreach (Site site in Model.Core.Landscape.AllSites)
                {
                    map.ReadBufferPixel();
                    if (site.IsActive)
                    {
                        uint           mapCode  = pixel.MapCode.Value;
                        ManagementArea mgmtArea = managementAreas.Find(mapCode);
                        if (mgmtArea == null)
                        {
                            if (!inactiveMgmtAreas.Contains(mapCode))
                            {
                                inactiveMgmtAreas.Add(mapCode);
                            }
                        }
                        else
                        {
                            mgmtArea.OnMap = true;
                            SiteVars.ManagementArea[site] = mgmtArea;
                        }
                    }
                }
            }

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0)
            {
                Model.Core.UI.WriteLine("   Inactive management areas: {0}",
                                        MapCodesToString(inactiveMgmtAreas));
            }
        }
        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string                 path,
                                   IManagementAreaDataset managementAreas)
        {

            IInputRaster<UIntPixel> map;

            try {
                map = PlugIn.ModelCore.OpenRaster<UIntPixel>(path);
            }
            catch (FileNotFoundException) {
                string mesg = string.Format("Error: The file {0} does not exist", path);
                throw new System.ApplicationException(mesg);
            }

            if (map.Dimensions != PlugIn.ModelCore.Landscape.Dimensions)
            {
                string mesg = string.Format("Error: The input map {0} does not have the same dimension (row, column) as the ecoregions map", path);
                throw new System.ApplicationException(mesg);
            }

            List<uint> inactiveMgmtAreas = new List<uint>();

            using (map) {
                UIntPixel pixel = map.BufferPixel;
                foreach (Site site in PlugIn.ModelCore.Landscape.AllSites)
                {
                    map.ReadBufferPixel();
                    if (site.IsActive)
                    {
                        uint mapCode = pixel.MapCode.Value;
                        ManagementArea mgmtArea = managementAreas.Find(mapCode);
                        if (mgmtArea == null) {
                            if (! inactiveMgmtAreas.Contains(mapCode))
                                inactiveMgmtAreas.Add(mapCode);
                        }
                        else {
                            mgmtArea.OnMap = true;
                            SiteVars.ManagementArea[site] = mgmtArea;
                        }
                    }
                }
            }

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0) {
                PlugIn.ModelCore.Log.WriteLine("   Inactive management areas: {0}",
                             MapCodesToString(inactiveMgmtAreas));
            }
        }
        //---------------------------------------------------------------------

        public Parameters(int                    timestep,
                          string                 managementAreaMap,
                          IManagementAreaDataset managementAreas,
                          string                 standMap,
                          string                 prescriptionMapNamesTemplate,
                          string                 eventLog)
        {
            this.timestep = timestep;
            this.managementAreaMap = managementAreaMap;
            this.managementAreas = managementAreas;
            this.standMap = standMap;
            this.prescriptionMapNamesTemplate = prescriptionMapNamesTemplate;
            this.eventLog = eventLog;
        }
        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string                 path,
                                   IManagementAreaDataset managementAreas)
        {

            IInputRaster<MapCodePixel> map;// = Model.Core.OpenRaster<MapCodePixel>(path);

            try {
                map = Model.Core.OpenRaster<MapCodePixel>(path);
            }
            catch (FileNotFoundException) {
                string mesg = string.Format("Error: The file {0} does not exist", path);
                throw new System.ApplicationException(mesg);
            }
            
            if (map.Dimensions != Model.Core.Landscape.Dimensions)
            {
                string mesg = string.Format("Error: The input map {0} does not have the same dimension (row, column) as the ecoregions map", path);
                throw new System.ApplicationException(mesg);
            }

            //UI.WriteLine("reading ma map!!\n\n");
            List<ushort> inactiveMgmtAreas = new List<ushort>();

            using (map) {
                // TODO: make sure its dimensions match landscape's dimensions
                foreach (Site site in Model.Core.Landscape.AllSites) {
                    MapCodePixel pixel = map.ReadPixel();
                    if (site.IsActive) {
                        ushort mapCode = pixel.Band0;
                        ManagementArea mgmtArea = managementAreas.Find(mapCode);
                        if (mgmtArea == null) {
                            if (! inactiveMgmtAreas.Contains(mapCode))
                                inactiveMgmtAreas.Add(mapCode);
                        }
                        else {
                            mgmtArea.OnMap = true;
                            SiteVars.ManagementArea[site] = mgmtArea;
                        }
                    }
                }
            }

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0) {
                UI.WriteLine("Inactive management areas: {0}",
                             MapCodesToString(inactiveMgmtAreas));
            }
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string                 path,
                                   IManagementAreaDataset managementAreas)
        {
            mgmtAreas = managementAreas;

            IInputRaster<MapCodePixel> map = Model.Core.OpenRaster<MapCodePixel>(path);
            InputMap.ReadWithMajorityRule(map, Model.Core.Landscape, AssignSiteToMgmtArea);

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0) {
                UI.WriteLine("Inactive management areas: {0}",
                             MapCodesToString(inactiveMgmtAreas));
            }
        }
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        PlugIns.ICore modelCore)
        {
            Model.Core = modelCore;
            SiteVars.Initialize();

            ParametersParser parser = new ParametersParser(Model.Core.Species,
                                                           Model.Core.StartTime,
                                                           Model.Core.EndTime);
            IParameters parameters = Landis.Data.Load<IParameters>(dataFile, parser);

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

            Timestep = parameters.Timestep;

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

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

            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);

            UI.WriteLine("Opening harvest log file \"{0}\" ...", parameters.EventLog);
            log = Data.CreateTextFile(parameters.EventLog);
            log.AutoFlush = true;
            log.WriteLine("Time,Stand,Total Sites,Damaged Sites,Cohorts Killed");
        }
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        PlugIns.ICore modelCore)
        {
            Model.Core = modelCore;
            SiteVars.Initialize();

            ParametersParser parser = new ParametersParser(Model.Core.StartTime,
                                                           Model.Core.EndTime);
            IParameters parameters = Landis.Data.Load<IParameters>(dataFile, parser);

            Timestep = parameters.Timestep;

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

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

            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();
        }
        //---------------------------------------------------------------------
        public override void Initialize()
        {
            //initialize event id
            event_id = 1;

            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.EventLog, parameters.SummaryLog);
            Timestep = parameters.Timestep;
            managementAreas = parameters.ManagementAreas;
            PlugIn.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
            PlugIn.ModelCore.UI.WriteLine("   Reading stand map {0} ...", parameters.StandMap);
            Stands.ReadMap(parameters.StandMap);

            //finish initializing SiteVars
            SiteVars.GetExternalVars();

            //finish each managementArea's initialization
            //after reading the stand map, finish the initializations
            foreach (ManagementArea mgmtArea in managementAreas)
                mgmtArea.FinishInitialization();

            prescriptionMaps = new PrescriptionMaps(parameters.PrescriptionMapNames);

            //open log file and write header
            //PlugIn.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 < PlugIn.ModelCore.Species.Count; i++) {
            //    species_header_names += PlugIn.ModelCore.Species[i].Name + ",";
            //}
            ////Trim trailing comma so we don't add an extra column
            //species_header_names = species_header_names.TrimEnd(',');

            //log.WriteLine("Time,ManagementArea,Prescription,Stand,EventId,StandAge,StandRank,NumberOfSites,HarvestedSites,CohortsKilled,{0}", species_header_names);

            //PlugIn.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,HarvestedSites,{0}", species_header_names);
        }
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            modelCore.UI.WriteLine("   Creating metadata ...");
            MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.PrescriptionMapNames, parameters.BiomassMapNames, modelCore);
            SiteVars.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);

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

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


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

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

        }