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

        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public void Run(int currentTime)
        {
            foreach (ISpecies species in selectedSpecies)
            {
                IOutputRaster <AgePixel> map = CreateMap(species.Name, currentTime);
                using (map) {
                    AgePixel pixel = new AgePixel();
                    foreach (Site site in Model.Landscape.AllSites)
                    {
                        if (site.IsActive)
                        {
                            pixel.Band0 = AgeCohort.Util.GetMaxAge(cohorts[site][species]);
                        }
                        else
                        {
                            pixel.Band0 = 0;
                        }
                        map.WritePixel(pixel);
                    }
                }
            }

            WriteMapWithMaxAgeAmongAll(currentTime);
            nextTimeToRun += timestep;
        }
        //---------------------------------------------------------------------

        public override void Run()
        {
            //if keyword == maxage
            foreach (ISpecies species in selectedSpecies)
            {
                IOutputRaster <AgePixel> map = CreateMap(species.Name);
                using (map) {
                    AgePixel pixel = new AgePixel();
                    foreach (Site site in modelCore.Landscape.AllSites)
                    {
                        if (site.IsActive)
                        {
                            pixel.Band0 = AgeCohort.Util.GetMaxAge(cohorts[site][species]);
                        }
                        else
                        {
                            pixel.Band0 = 0;
                        }
                        map.WritePixel(pixel);
                    }
                }
            }

            WriteMapWithMaxAgeAmongAll();
        }
        //---------------------------------------------------------------------

        private void WriteMap(string speciesName,
                              MaxAgeCalculator maxAgeCalculator)
        {
            IOutputRaster <AgePixel> map = CreateMap(speciesName);

            using (map) {
                AgePixel pixel        = new AgePixel();
                Location location_1_1 = new Location(1, 1);
                foreach (Site site in modelCore.Landscape.AllSites)
                {
                    ushort age;
                    if (site.IsActive)
                    {
                        ActiveSite activeSite = (ActiveSite)site;
                        if (activeSite.SharesData)
                        {
                            Location blockLocation = activeSite.BroadScaleLocation;
                            if (activeSite.LocationInBlock == location_1_1)
                            {
                                age = maxAgeCalculator.ComputeMaxAge(activeSite);
                                ageBuffer[blockLocation.Column] = age;
                            }
                            else
                            {
                                // already computed age for the block
                                age = ageBuffer[blockLocation.Column];
                            }
                        }
                        else
                        {
                            age = maxAgeCalculator.ComputeMaxAge(activeSite);
                        }
                    }
                    else
                    {
                        // inactive site
                        age = 0;
                    }
                    pixel.Band0 = age;
                    map.WritePixel(pixel);
                }
            }
        }
        //---------------------------------------------------------------------

        private void WriteMapWithMaxAgeAmongAll(int currentTime)
        {
            //	Maximum age map for all species
            IOutputRaster <AgePixel> map = CreateMap("all", currentTime);

            using (map) {
                AgePixel pixel = new AgePixel();
                foreach (Site site in Model.Landscape.AllSites)
                {
                    if (site.IsActive)
                    {
                        pixel.Band0 = AgeCohort.Util.GetMaxAge(cohorts[site]);
                    }
                    else
                    {
                        pixel.Band0 = 0;
                    }
                    map.WritePixel(pixel);
                }
            }
        }