//---------------------------------------------------------------------

        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public override void Run()
        {
            foreach (IMapDefinition map in mapDefs)
            {
                List <IForestType> forestTypes = map.ForestTypes;

                string path = MapFileNames.ReplaceTemplateVars(mapNameTemplate, map.Name, modelCore.CurrentTime);
                modelCore.UI.WriteLine("   Writing Biomass Reclass map to {0} ...", path);
                using (IOutputRaster <BytePixel> outputRaster = modelCore.CreateRaster <BytePixel>(path, modelCore.Landscape.Dimensions))
                {
                    BytePixel pixel = outputRaster.BufferPixel;
                    foreach (Site site in modelCore.Landscape.AllSites)
                    {
                        if (site.IsActive)
                        {
                            pixel.MapCode.Value = CalcForestType(forestTypes, site);
                        }
                        else
                        {
                            pixel.MapCode.Value = 0;
                        }

                        outputRaster.WriteBufferPixel();
                    }
                }
            }
        }
        public static void InitializeMetadata(string MapFileTemplate, IEnumerable <IMapDefinition> maps)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata()
            {
                RasterOutCellArea = PlugIn.ModelCore.CellArea,
                TimeMin           = PlugIn.ModelCore.StartTime,
                TimeMax           = PlugIn.ModelCore.EndTime,
            };

            Extension = new ExtensionMetadata(PlugIn.ModelCore)
                        //Extension = new ExtensionMetadata()
            {
                Name         = PlugIn.ExtensionName,
                TimeInterval = PlugIn.ModelCore.CurrentTime, //change this to PlugIn.TimeStep for other extensions
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          map outputs:
            //---------------------------------------

            //OutputMetadata mapOut_BiomassRemoved = new OutputMetadata()
            //{
            //    Type = OutputType.Map,
            //    Name = "biomass removed",
            //    FilePath = @HarvestMapName,
            //    Map_DataType = MapDataType.Continuous,
            //    Map_Unit = FieldUnits.Mg_ha,
            //    Visualize = true,
            //};
            //Extension.OutputMetadatas.Add(mapOut_BiomassRemoved);

            foreach (IMapDefinition map in maps)
            {
                OutputMetadata mapOut_bioReclass = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = map.Name,
                    FilePath     = MapFileNames.ReplaceTemplateVars(MapFileTemplate, map.Name, PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_bioReclass);
            }

            //---------------------------------------
            MetadataProvider mp = new MetadataProvider(Extension);

            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);
        }