//---------------------------------------------------------------------
        public override void Run()
        {
            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);
         }
     }
 }
        //---------------------------------------------------------------------
        /// <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;
        }
 //---------------------------------------------------------------------
 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);
         }
     }
 }
        //---------------------------------------------------------------------
        public override void Run()
        {
            IOutputRaster<AgePixel> map;
            AgePixel pixel;

            //1) Create the output species age stats maps
            foreach (KeyValuePair<string, IEnumerable<ISpecies>> sppAgeStatIter in ageStatSpecies)
            {
                //statIter.Key = statistic name
                //set a function pointer here for the statistic, so we don't have to do the switch operation for every single pixel every single time??
                CohortUtils.SpeciesCohortStatDelegate species_stat_func;

                switch (sppAgeStatIter.Key)
                {
                    case "MAX":
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetMaxAge);
                        break;
                    case "MIN":
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetMinAge);
                        break;
                    case "MED":
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetMedianAge);
                        break;
                    case "AVG":
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetAvgAge);
                        break;
                    case "SD":
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetStdDevAge);
                        break;

                    default:
                        //this shouldn't ever occur
                        System.Console.WriteLine("Unhandled statistic: {0}, using MaxAge Instead",sppAgeStatIter.Key);
                        species_stat_func = new CohortUtils.SpeciesCohortStatDelegate(CohortUtils.GetMaxAge);
                        break;
                }

                foreach (ISpecies species in sppAgeStatIter.Value)
                {
                    map = CreateSppMap(species.Name, sppAgeStatIter.Key);
                    using (map)
                    {
                        foreach (Site site in modelCore.Landscape.AllSites)
                        {
                            pixel = new AgePixel();
                            if (!site.IsActive) // and has the spp we want
                                pixel.Band0 = 0;
                            else
                            {
                                //need to do a switch on statistic
                                pixel.Band0 = species_stat_func(cohorts[site][species]);
                            }
                            map.WritePixel(pixel);
                        }
                    }
                }
            }

            //2) Create the output site age stats maps
            foreach(string ageStatIter in siteAgeStats)
            {
                CohortUtils.SiteCohortStatDelegate site_stat_func;
                switch (ageStatIter)
                {
                    case "MAX":
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetMaxAge);
                        break;
                    case "MIN":
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetMinAge);
                        break;
                    case "MED":
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetMedianAge);
                        break;
                    case "AVG":
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetAvgAge);
                        break;
                    case "SD":
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetStdDevAge);
                        break;
                    case "RICH":
                        //FIXME
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetAgeRichness);
                        break;
                    case "EVEN":

                        //FIXME!
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetAgeEvenness);
                        break;

                    default:
                        System.Console.WriteLine("Unhandled statistic: {0}, using MaxAge Instead", ageStatIter);
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetMaxAge);
                        break;
                }

                map = CreateSiteMap(siteagestats_mapNames, ageStatIter);
                using (map)
                {
                    pixel = new AgePixel();
                    foreach (Site site in modelCore.Landscape.AllSites)
                    {
                        if (!site.IsActive)
                            pixel.Band0 = 0;
                        else
                            pixel.Band0 = site_stat_func(cohorts[site]);

                        map.WritePixel(pixel);
                    }
                }
            }

            //3) Create the output site species stats maps
            foreach (string sppStatIter in siteSppStats)
            {
                CohortUtils.SiteCohortStatDelegate site_stat_func;
                switch (sppStatIter)
                {
                    case "RICH":
                        //FIXME
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetSppRichness);
                        break;
                    //add in richness
                    default:
                        System.Console.WriteLine("Unhandled statistic: {0}, using Species Richness Instead", sppStatIter);
                        site_stat_func = new CohortUtils.SiteCohortStatDelegate(CohortUtils.GetSppRichness);
                        break;
                }

                map = CreateSiteMap(sitesppstats_mapNames, sppStatIter);
                using (map)
                {
                    pixel = new AgePixel();
                    foreach (Site site in modelCore.Landscape.AllSites)
                    {
                        if (!site.IsActive)
                            pixel.Band0 = 0;
                        else
                            pixel.Band0 = site_stat_func(cohorts[site]);

                        map.WritePixel(pixel);
                    }
                }
            }
        }