public OutputHistogramCohort(string filenametemplate, string label, int NrOfCohorts)
        {
            FileContent      = new List <string>();
            this.NrOfCohorts = NrOfCohorts;
            FileName         = FileNames.ReplaceTemplateVars(filenametemplate, "", PlugIn.ModelCore.CurrentTime).Replace(".img", "Histogram.csv").Replace("timestep", "AllYears");

            this.label = label;
        }
        public void PrintLabels(string MapNameTemplate, ISpecies Species)
        {
            string FileName = System.IO.Path.ChangeExtension(FileNames.ReplaceTemplateVars(MapNameTemplate.Replace("{timestep}", "Label"), Species.Name), "txt");

            List <string> Content = new List <string>();

            foreach (var value in Enum.GetValues(typeof(values)))
            {
                Content.Add((int)value + "\t" + value.ToString() + "\n");
            }
            System.IO.File.WriteAllLines(FileName, Content.ToArray());
        }
示例#3
0
        public OutputTableEcoregions(string MapNameTemplate)
        {
            FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", "eco.txt").Replace(".gis", "eco.txt");
            FileNames.MakeFolders(FileName);

            string hdr = "Time\t";

            foreach (IEcoregion e in PlugIn.ModelCore.Ecoregions)
            {
                hdr += e.Name + "\t";
            }

            FileContent.Add(hdr);
        }
        public OutputTableEcoregions(string MapNameTemplate)
        {
            FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", "-eco.csv").Replace(".gis", "-eco.csv").Replace("{timestep}", "AllYears");
            FileNames.MakeFolders(FileName);

            string hdr = "Time";

            foreach (IEcoregion e in PlugIn.ModelCore.Ecoregions)
            {
                hdr += ", " + e.Name;
            }

            FileContent.Add(hdr);
        }
示例#5
0
        public static void Write <T>(string MapNameTemplate, string units, int TStep, ISiteVar <Landis.Library.Parameters.Species.AuxParm <T> > Values)
        {
            string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".txt");

            if (PlugIn.ModelCore.CurrentTime == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[] { Header(units) });
            }

            AuxParm <ulong> Values_spc = new AuxParm <ulong>(PlugIn.ModelCore.Species);
            AuxParm <ulong> Values_cnt = new AuxParm <ulong>(PlugIn.ModelCore.Species);

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    if (typeof(T) == typeof(bool))
                    {
                        if (Values[site][spc].ToString() == bool.TrueString)
                        {
                            Values_spc[spc]++;
                        }
                    }
                    else
                    {
                        ulong numeric = ulong.Parse(Values[site][spc].ToString());
                        Values_spc[spc] += numeric;
                    }

                    Values_cnt[spc]++;
                }
            }

            string line = TStep + "\t";

            foreach (ISpecies spc in PlugIn.ModelCore.Species)
            {
                line += Values_spc[spc] / (float)Values_cnt[spc] + "\t";
            }

            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, true);
            sw.WriteLine(line);
            sw.Close();
        }
        public static void WriteUpdate(string MapNameTemplate, int year, AuxParm <int> values)
        {
            string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".csv").Replace(".gis", ".csv");

            if (year == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[] { Header });
            }

            string line = year.ToString();

            foreach (ISpecies species in PlugIn.SelectedSpecies)
            {
                line += ", " + values[species];
            }
            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, true);
            sw.WriteLine(line);
            sw.Close();
        }
示例#7
0
        private static void WriteMonthlyOutput(ISiteVar <int[]> montly, string MapNameTemplate)
        {
            string[] months = new string[] { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "okt", "nov", "dec" };

            for (int mo = 0; mo < months.Count(); mo++)
            {
                ISiteVar <int> monthlyValue = PlugIn.ModelCore.Landscape.NewSiteVar <int>();

                foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                {
                    monthlyValue[site] = montly[site][mo];
                }

                string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                FileName = System.IO.Path.ChangeExtension(FileName, null) + months[mo] + System.IO.Path.GetExtension(FileName);

                new OutputMapSiteVar <int, int>(FileName, monthlyValue, o => o);
            }
        }
示例#8
0
        public static void Write <T>(string MapNameTemplate, string units, int TStep, Landis.Library.Parameters.Species.AuxParm <T> Values)
        {
            string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".txt");

            if (PlugIn.ModelCore.CurrentTime == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[] { Header(units) });
            }

            string line = TStep + "\t";

            foreach (ISpecies spc in PlugIn.ModelCore.Species)
            {
                line += Values[spc] + "\t";
            }

            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, true);
            sw.WriteLine(line);
            sw.Close();
        }
        public OutputMapSpecies(ISiteVar <int> values, ISpecies species, string MapNameTemplate)
        {
            FileName = FileNames.ReplaceTemplateVars(MapNameTemplate, species.Name, PlugIn.ModelCore.CurrentTime);

            Console.WriteLine("   Writing {0} map to {1} ...", species.Name, FileName);

            using (IOutputRaster <IntPixel> outputRaster = PlugIn.ModelCore.CreateRaster <IntPixel>(FileName, PlugIn.ModelCore.Landscape.Dimensions))
            {
                IntPixel pixel = outputRaster.BufferPixel;
                foreach (Site site in PlugIn.ModelCore.Landscape.AllSites)
                {
                    if (site.IsActive)
                    {
                        pixel.MapCode.Value = (int)values[site];
                    }
                    else
                    {
                        pixel.MapCode.Value = 0;
                    }

                    outputRaster.WriteBufferPixel();
                }
            }
        }
        public static void InitializeMetadata(int Timestep, OutputVariable LAI, OutputVariable Biomass, OutputVariable AbovegroundBiomass, OutputVariable EstablishmentProbability, ISiteVar <Landis.Library.Parameters.Species.AuxParm <bool> > SpeciesWasThere, OutputVariable AnnualPsn, OutputVariable BelowGround, OutputVariable CohortsPerSpc, OutputVariable Water, OutputVariable SubCanopyPAR, OutputVariable NonWoodyDebris, OutputVariable WoodyDebris, OutputVariable AgeDistribution, OutputVariable MonthlyFolResp, OutputVariable MonthlyGrossPsn, OutputVariable MonthlyNetPsn, OutputVariable MonthlyMaintResp, OutputVariable SpeciesEstablishment, ISiteVar <Library.Parameters.Species.AuxParm <int> > LastBiom, OutputAggregatedTable overalloutputs, string OutputTableMap)
        {
            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 = Timestep,
                ScenarioReplicationMetadata = scenRep
            };
            //---------------------------------------
            //          table outputs:
            //---------------------------------------
            if (overalloutputs != null)
            {
                PlugIn.ModelCore.UI.WriteLine("   Generating summary table...");
                CreateDirectory(OutputTableMap);

                OutputMetadata tblOut_OverallOutputs = new OutputMetadata()
                {
                    Type         = OutputType.Table,
                    Name         = Path.GetFileName(OutputTableMap),
                    FilePath     = OutputTableMap,
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                };
                tblOut_OverallOutputs.RetriveFields(typeof(OutputAggregatedTable));
                Extension.OutputMetadatas.Add(tblOut_OverallOutputs);
            }


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

            if (LAI != null)
            {
                OutputMetadata mapOut_LAI = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(LAI.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(LAI.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_LAI);
            }

            if (Biomass != null)
            {
                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    OutputMetadata mapOut_Biomass = new OutputMetadata()
                    {
                        Type         = OutputType.Map,
                        Name         = FileNames.ReplaceTemplateVars(Biomass.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        FilePath     = FileNames.ReplaceTemplateVars(Biomass.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        Map_DataType = MapDataType.Continuous,
                        Visualize    = true,
                        //Map_Unit = "categorical",
                    };
                    Extension.OutputMetadatas.Add(mapOut_Biomass);
                }
            }
            if (AbovegroundBiomass != null)
            {
                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    OutputMetadata mapOut_AbvBiomass = new OutputMetadata()
                    {
                        Type         = OutputType.Map,
                        Name         = FileNames.ReplaceTemplateVars(AbovegroundBiomass.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        FilePath     = FileNames.ReplaceTemplateVars(AbovegroundBiomass.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        Map_DataType = MapDataType.Continuous,
                        Visualize    = true,
                        //Map_Unit = "categorical",
                    };
                    Extension.OutputMetadatas.Add(mapOut_AbvBiomass);
                }
            }
            if (MonthlyFolResp != null)
            {
                OutputMetadata mapOut_Monthly = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(MonthlyFolResp.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(MonthlyFolResp.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Monthly);
            }
            if (MonthlyGrossPsn != null)
            {
                OutputMetadata mapOut_Monthly = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(MonthlyGrossPsn.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(MonthlyGrossPsn.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Monthly);
            }
            if (MonthlyNetPsn != null)
            {
                OutputMetadata mapOut_Monthly = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(MonthlyNetPsn.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(MonthlyNetPsn.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Monthly);
            }
            if (MonthlyMaintResp != null)
            {
                OutputMetadata mapOut_Monthly = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(MonthlyMaintResp.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(MonthlyMaintResp.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Monthly);
            }
            if (BelowGround != null)
            {
                OutputMetadata mapOut_BelowGround = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(BelowGround.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(BelowGround.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_BelowGround);
            }
            if (CohortsPerSpc != null)
            {
                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    OutputMetadata mapOut_LAI = new OutputMetadata()
                    {
                        Type         = OutputType.Map,
                        Name         = FileNames.ReplaceTemplateVars(CohortsPerSpc.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                        FilePath     = FileNames.ReplaceTemplateVars(CohortsPerSpc.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                        Map_DataType = MapDataType.Continuous,
                        Visualize    = true,
                        //Map_Unit = "categorical",
                    };
                    Extension.OutputMetadatas.Add(mapOut_LAI);
                }
            }
            if (EstablishmentProbability != null)
            {
                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    OutputMetadata mapOut_EProb = new OutputMetadata()
                    {
                        Type         = OutputType.Map,
                        Name         = FileNames.ReplaceTemplateVars(EstablishmentProbability.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        FilePath     = FileNames.ReplaceTemplateVars(EstablishmentProbability.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                        Map_DataType = MapDataType.Continuous,
                        Visualize    = true,
                        //Map_Unit = "categorical",
                    };
                    Extension.OutputMetadatas.Add(mapOut_EProb);
                }
            }
            if (SpeciesEstablishment != null)
            {
                if (SpeciesWasThere != null)
                {
                    foreach (ISpecies spc in PlugIn.ModelCore.Species)
                    {
                        OutputMetadata mapOut_SpeciesE = new OutputMetadata()
                        {
                            Type         = OutputType.Map,
                            Name         = FileNames.ReplaceTemplateVars(SpeciesEstablishment.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                            FilePath     = FileNames.ReplaceTemplateVars(SpeciesEstablishment.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                            Map_DataType = MapDataType.Continuous,
                            Visualize    = true,
                            //Map_Unit = "categorical",
                        };
                        Extension.OutputMetadatas.Add(mapOut_SpeciesE);
                    }
                }

                OutputMetadata mapOut_SpeciesE2 = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(SpeciesEstablishment.MapNameTemplate).Replace(".img", ".txt"),
                    FilePath     = FileNames.ReplaceTemplateVars(SpeciesEstablishment.MapNameTemplate).Replace(".img", ".txt"),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_SpeciesE2);
            }
            if (AnnualPsn != null)
            {
                if (LastBiom != null)
                {
                    foreach (ISpecies spc in PlugIn.ModelCore.Species)
                    {
                        OutputMetadata mapOut_AnnualPsn = new OutputMetadata()
                        {
                            Type         = OutputType.Map,
                            Name         = FileNames.ReplaceTemplateVars(AnnualPsn.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                            FilePath     = FileNames.ReplaceTemplateVars(AnnualPsn.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime),
                            Map_DataType = MapDataType.Continuous,
                            Visualize    = true,
                            //Map_Unit = "categorical",
                        };
                        Extension.OutputMetadatas.Add(mapOut_AnnualPsn);
                    }
                }
            }
            if (Water != null)
            {
                OutputMetadata mapOut_Water = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(Water.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(Water.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Water);
            }
            if (SubCanopyPAR != null)
            {
                OutputMetadata mapOut_SubCanopyPAR = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(SubCanopyPAR.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(SubCanopyPAR.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_SubCanopyPAR);
            }
            if (NonWoodyDebris != null)
            {
                OutputMetadata mapOut_NonWoodyDebris = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(NonWoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(NonWoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_NonWoodyDebris);
            }
            if (WoodyDebris != null)
            {
                OutputMetadata mapOut_WoodyDebris = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(WoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(WoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_WoodyDebris);
            }
            if (AgeDistribution != null)
            {
                OutputMetadata mapOut_AgeDistribution = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = FileNames.ReplaceTemplateVars(AgeDistribution.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    FilePath     = FileNames.ReplaceTemplateVars(AgeDistribution.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_AgeDistribution);
            }

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

            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);
        }
 public OutputAggregatedTable(string Template)
 {
     FileName    = FileNames.ReplaceTemplateVars(Template, "Overall", PlugIn.ModelCore.CurrentTime).Replace(".img", ".csv");
     FileContent = new List <string>();
     FileContent.Add("Time" + ", " + "#Cohorts" + ", " + "AverageAge" + ", " + "AverageB(g/m2)" + ", " + "AverageLAI(m2)" + ", " + "AverageWater(mm)" + ", " + "SubCanopyPAR(W/m2)" + ", " + "Litter(kgDW/m2)" + ", " + "WoodyDebris(kgDW/m2)" + ", " + "AverageBelowGround(g/m2)" + ", " + "AverageFoliage(g/m2)" + ", " + "AverageNSC(gC/m2)" + ", " + "AverageAET(mm)");
 }
示例#12
0
        public override void Run()
        {
            if (LAI != null)
            {
                System.Console.WriteLine("Updating output variable: LAI");
                // Total LAI per site

                ISiteVar <byte> values = cohorts.GetIsiteVar(o => o.CanopyLAImax);

                string FileName = FileNames.ReplaceTemplateVars(LAI.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <byte, byte>(FileName, values, o => o);

                // Values per species each time step
                LAI.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, values);
            }
            if (Biomass != null)
            {
                System.Console.WriteLine("Updating output variable: Biomass");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> Biom_spc = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        Biom_spc[site] = Biom[site][spc];
                    }

                    new OutputMapSpecies(Biom_spc, spc, Biomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write <int>(Biomass.MapNameTemplate, Biomass.units, PlugIn.ModelCore.CurrentTime, Biom);

                ISiteVar <float> Biomass_site = cohorts.GetIsiteVar(x => x.BiomassSum);

                Biomass.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Biomass_site);
            }
            if (AbovegroundBiomass != null)
            {
                System.Console.WriteLine("Updating output variable: Aboveground Biomass");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > AGBiom = cohorts.GetIsiteVar(o => o.AbovegroundBiomassPerSpecies);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> AGBiom_spc = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        AGBiom_spc[site] = AGBiom[site][spc];
                    }

                    new OutputMapSpecies(AGBiom_spc, spc, AbovegroundBiomass.MapNameTemplate);
                }

                OutputFilePerTStepPerSpecies.Write <int>(AbovegroundBiomass.MapNameTemplate, AbovegroundBiomass.units, PlugIn.ModelCore.CurrentTime, AGBiom);

                ISiteVar <float> AGBiomass_site = cohorts.GetIsiteVar(x => x.AbovegroundBiomassSum);

                AbovegroundBiomass.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, AGBiomass_site);
            }
            if (WoodySenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Woody Senescence");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Senes = cohorts.GetIsiteVar(o => o.WoodySenescencePerSpecies);

                /*
                 * foreach (ISpecies spc in PlugIn.SelectedSpecies)
                 * {
                 *  ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();
                 *
                 *  foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                 *  {
                 *      Senes_spc[site] = Senes[site][spc];
                 *
                 *  }
                 *
                 *  new OutputMapSpecies(Senes_spc, spc, WoodySenescence.MapNameTemplate);
                 * }
                 */
                OutputFilePerTStepPerSpecies.Write <int>(WoodySenescence.MapNameTemplate, WoodySenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar <float> Senescence_site = cohorts.GetIsiteVar(x => x.WoodySenescenceSum);

                WoodySenescence.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (FoliageSenescence != null)
            {
                System.Console.WriteLine("Updating output variable: Foliage Senescence");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Senes = cohorts.GetIsiteVar(o => o.FoliageSenescencePerSpecies);

                /*foreach (ISpecies spc in PlugIn.SelectedSpecies)
                 * {
                 *  ISiteVar<int> Senes_spc = modelCore.Landscape.NewSiteVar<int>();
                 *
                 *  foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                 *  {
                 *      Senes_spc[site] = Senes[site][spc];
                 *  }
                 *
                 *  new OutputMapSpecies(Senes_spc, spc, FoliageSenescence.MapNameTemplate);
                 * }
                 */
                OutputFilePerTStepPerSpecies.Write <int>(FoliageSenescence.MapNameTemplate, FoliageSenescence.units, PlugIn.ModelCore.CurrentTime, Senes);

                ISiteVar <float> Senescence_site = cohorts.GetIsiteVar(x => x.FoliageSenescenceSum);

                FoliageSenescence.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, Senescence_site);
            }
            if (AETAvg != null)
            {
                ISiteVar <float> AET_site = cohorts.GetIsiteVar(x => x.AETSum);

                AETAvg.output_table_ecoregions.WriteUpdate <float>(PlugIn.ModelCore.CurrentTime, AET_site);
            }
            if (MonthlyFolResp != null)
            {
                ISiteVar <int[]> monthlyFolResp = cohorts.GetIsiteVar(site => site.FolResp);

                WriteMonthlyOutput(monthlyFolResp, MonthlyFolResp.MapNameTemplate);
            }
            if (MonthlyGrossPsn != null)
            {
                ISiteVar <int[]> monthlyGrossPsn = cohorts.GetIsiteVar(site => site.GrossPsn);

                WriteMonthlyOutput(monthlyGrossPsn, MonthlyGrossPsn.MapNameTemplate);
            }
            if (MonthlyNetPsn != null)
            {
                ISiteVar <int[]> monthlyNetPsn = cohorts.GetIsiteVar(site => site.NetPsn);

                WriteMonthlyOutput(monthlyNetPsn, MonthlyNetPsn.MapNameTemplate);
            }
            if (MonthlyMaintResp != null)
            {
                ISiteVar <int[]> monthlyMaintResp = cohorts.GetIsiteVar(site => site.MaintResp);

                WriteMonthlyOutput(monthlyMaintResp, MonthlyMaintResp.MapNameTemplate);
            }
            if (BelowGround != null)
            {
                System.Console.WriteLine("Updating output variable: BelowGround");

                ISiteVar <uint> values = cohorts.GetIsiteVar(o => o.BelowGroundBiomass);

                string FileName = FileNames.ReplaceTemplateVars(BelowGround.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <uint, uint>(FileName, values, o => o);
            }
            if (CohortsPerSpc != null)
            {
                System.Console.WriteLine("Updating output variable: CohortsPerSpc");
                // Nr of Cohorts per site and per species

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > cps = cohorts.GetIsiteVar(x => x.CohortCountPerSpecies);

                new OutputHistogramCohort <int>(CohortsPerSpc.MapNameTemplate, "CohortsPerSpcPerSite", 10).WriteOutputHist(cps);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    string FileName = FileNames.ReplaceTemplateVars(CohortsPerSpc.MapNameTemplate, spc.Name, PlugIn.ModelCore.CurrentTime);

                    new OutputMapSiteVar <Landis.Library.Parameters.Species.AuxParm <int>, int>(FileName, cps, o => o[spc]);
                }

                OutputFilePerTStepPerSpecies.Write <int>(CohortsPerSpc.MapNameTemplate, CohortsPerSpc.units, PlugIn.ModelCore.CurrentTime, cps);
            }
            if (EstablishmentProbability != null)
            {
                System.Console.WriteLine("Updating output variable: EstablishmentProbability");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <byte> > pest = (ISiteVar <Landis.Library.Parameters.Species.AuxParm <byte> >)cohorts.GetIsiteVar(o => o.EstablishmentProbability.Probability);

                foreach (ISpecies spc in PlugIn.SelectedSpecies)
                {
                    ISiteVar <int> _pest = modelCore.Landscape.NewSiteVar <int>();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        _pest[site] = pest[site][spc];
                    }

                    new OutputMapSpecies(_pest, spc, EstablishmentProbability.MapNameTemplate);
                }
            }
            if (SpeciesEstablishment != null)
            {
                System.Console.WriteLine("Updating output variable: SpeciesEstablishment");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <bool> > SpeciesIsThere = cohorts.GetIsiteVar(o => o.SpeciesPresent);

                if (SpeciesWasThere != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar <int> comp = PlugIn.modelCore.Landscape.NewSiteVar <int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (SpeciesWasThere[site] == null)
                            {
                                SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm <bool>(PlugIn.modelCore.Species);
                            }

                            comp[site] = m[SpeciesWasThere[site][spc], SpeciesIsThere[site][spc]];

                            SpeciesWasThere[site][spc] = SpeciesIsThere[site][spc];
                        }


                        OutputMapSpecies output_map = new OutputMapSpecies(comp, spc, SpeciesEstablishment.MapNameTemplate);

                        // map label text
                        m.PrintLabels(SpeciesEstablishment.MapNameTemplate, spc);
                    }
                }
                else
                {
                    SpeciesWasThere = modelCore.Landscape.NewSiteVar <Landis.Library.Parameters.Species.AuxParm <bool> >();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        SpeciesWasThere[site] = new Library.Parameters.Species.AuxParm <bool>(PlugIn.modelCore.Species);
                    }
                }

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <bool> > Established_spc = cohorts.GetIsiteVar(x => x.SpeciesPresent);

                Landis.Library.Parameters.Species.AuxParm <int> Est_Sum = new Landis.Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);

                foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        if (Established_spc[site][spc] == true)
                        {
                            Est_Sum[spc]++;
                        }
                    }
                }

                OutputFilePerTStepPerSpecies.Write <int>(SpeciesEstablishment.MapNameTemplate, SpeciesEstablishment.units, PlugIn.ModelCore.CurrentTime, Est_Sum);
            }
            if (AnnualPsn != null)
            {
                System.Console.WriteLine("Updating output variable: AnnualPsn");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <int> > Biom = cohorts.GetIsiteVar(o => o.BiomassPerSpecies);

                if (LastBiom != null)
                {
                    foreach (ISpecies spc in PlugIn.modelCore.Species)
                    {
                        ISiteVar <int> comp = PlugIn.modelCore.Landscape.NewSiteVar <int>();

                        MapComparison m = new MapComparison();
                        foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                        {
                            if (LastBiom[site] == null)
                            {
                                LastBiom[site] = new Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);
                            }

                            comp[site] = Biom[site][spc] - LastBiom[site][spc];

                            LastBiom[site][spc] = Biom[site][spc];
                        }

                        OutputMapSpecies output_map = new OutputMapSpecies(comp, spc, AnnualPsn.MapNameTemplate);
                    }
                }
                else
                {
                    LastBiom = modelCore.Landscape.NewSiteVar <Landis.Library.Parameters.Species.AuxParm <int> >();

                    foreach (ActiveSite site in PlugIn.modelCore.Landscape)
                    {
                        LastBiom[site] = new Library.Parameters.Species.AuxParm <int>(PlugIn.modelCore.Species);
                    }
                }
            }

            if (Water != null)
            {
                System.Console.WriteLine("Updating output variable: Water");

                ISiteVar <ushort> Water_site = cohorts.GetIsiteVar(x => x.WaterMax);

                string FileName = FileNames.ReplaceTemplateVars(Water.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <ushort, ushort>(FileName, Water_site, o => o);

                Water.output_table_ecoregions.WriteUpdate(PlugIn.ModelCore.CurrentTime, Water_site);
            }

            if (SubCanopyPAR != null)
            {
                System.Console.WriteLine("Updating output variable: SubCanopyPAR");

                ISiteVar <float> SubCanopyRadiation = cohorts.GetIsiteVar(x => x.SubCanopyParMAX);

                string FileName = FileNames.ReplaceTemplateVars(SubCanopyPAR.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <float, float>(FileName, SubCanopyRadiation, o => o);
            }
            if (NonWoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: NonWoodyDebris");

                ISiteVar <double> Litter = cohorts.GetIsiteVar(x => x.Litter);

                string FileName = FileNames.ReplaceTemplateVars(NonWoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <double, double>(FileName, Litter, o => o);
            }

            if (WoodyDebris != null)
            {
                System.Console.WriteLine("Updating output variable: WoodyDebris");

                ISiteVar <double> woody_debris = cohorts.GetIsiteVar(x => x.WoodyDebris);

                string FileName = FileNames.ReplaceTemplateVars(WoodyDebris.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <double, double>(FileName, woody_debris, o => o);
            }

            if (AgeDistribution != null)
            {
                System.Console.WriteLine("Updating output variable: AgeDistribution");

                ISiteVar <Landis.Library.Parameters.Species.AuxParm <List <ushort> > > values = cohorts.GetIsiteVar(o => o.CohortAges);

                new OutputHistogramCohort <ushort>(AgeDistribution.MapNameTemplate, "NrOfCohortsAtAge", 10).WriteOutputHist(values);


                System.Console.WriteLine("Updating output variable: MaxAges");

                ISiteVar <int> maxage = cohorts.GetIsiteVar(x => x.AgeMax);

                string FileName = FileNames.ReplaceTemplateVars(AgeDistribution.MapNameTemplate, "", PlugIn.ModelCore.CurrentTime);

                new OutputMapSiteVar <int, int>(FileName, maxage, o => o);
            }
            if (overalloutputs != null)
            {
                System.Console.WriteLine("Updating output variable: overalloutputs");
                OutputAggregatedTable.WriteNrOfCohortsBalance();
            }
        }