Esempio n. 1
0
        //---------------------------------------------------------------------

        private void WritePoolMap(string poolName,
                                  ISiteVar <Pool> poolSiteVar)
        {
            string path = PoolMapNames.ReplaceTemplateVars(poolMapNameTemplate,
                                                           poolName,
                                                           PlugIn.ModelCore.CurrentTime);

            if (poolSiteVar != null)
            {
                PlugIn.ModelCore.UI.WriteLine("   Writing {0} biomass map to {1} ...", poolName, path);
                using (IOutputRaster <IntPixel> outputRaster = modelCore.CreateRaster <IntPixel>(path, modelCore.Landscape.Dimensions))
                {
                    IntPixel pixel = outputRaster.BufferPixel;
                    foreach (Site site in PlugIn.ModelCore.Landscape.AllSites)
                    {
                        if (site.IsActive)
                        {
                            pixel.MapCode.Value = (int)((float)poolSiteVar[site].Mass);
                        }
                        else
                        {
                            pixel.MapCode.Value = 0;
                        }

                        outputRaster.WriteBufferPixel();
                    }
                }
            }
        }
Esempio n. 2
0
        public static void InitializeMetadata(int Timestep, string summaryLogName, bool makeTable)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata()
            {
                RasterOutCellArea = PlugIn.ModelCore.CellArea,
                TimeMin           = PlugIn.ModelCore.StartTime,
                TimeMax           = PlugIn.ModelCore.EndTime,
            };

            Extension = new ExtensionMetadata(PlugIn.ModelCore)
            {
                Name         = PlugIn.ExtensionName,
                TimeInterval = Timestep,
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          table outputs:
            //---------------------------------------

            if (makeTable)
            {
                CreateDirectory(summaryLogName);
                PlugIn.summaryLog = new MetadataTable <SummaryLog>(summaryLogName);

                PlugIn.ModelCore.UI.WriteLine("   Generating summary table...");
                OutputMetadata tblOut_summary = new OutputMetadata()
                {
                    Type      = OutputType.Table,
                    Name      = "SummaryLog",
                    FilePath  = PlugIn.summaryLog.FilePath,
                    Visualize = true,
                };
                tblOut_summary.RetriveFields(typeof(SummaryLog));
                Extension.OutputMetadatas.Add(tblOut_summary);
            }

            //2 kinds of maps: species and pool maps, maybe multiples of each?
            //---------------------------------------
            //          map outputs:
            //---------------------------------------


            foreach (ISpecies species in PlugIn.speciesToMap)
            {
                OutputMetadata mapOut_Species = new OutputMetadata()
                {
                    Type     = OutputType.Map,
                    Name     = species.Name,
                    FilePath = SpeciesMapNames.ReplaceTemplateVars(PlugIn.speciesTemplateToMap,
                                                                   species.Name,
                                                                   PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_Species);
            }

            OutputMetadata mapOut_TotalBiomass = new OutputMetadata()
            {
                Type     = OutputType.Map,
                Name     = "TotalBiomass",
                FilePath = SpeciesMapNames.ReplaceTemplateVars(PlugIn.speciesTemplateToMap,
                                                               "TotalBiomass",
                                                               PlugIn.ModelCore.CurrentTime),
                Map_DataType = MapDataType.Continuous,
                Visualize    = true,
                //Map_Unit = "categorical",
            };

            Extension.OutputMetadatas.Add(mapOut_TotalBiomass);

            if (PlugIn.poolsToMap == "both" || PlugIn.poolsToMap == "woody")
            {
                OutputMetadata mapOut_WoodyDebris = new OutputMetadata()
                {
                    Type     = OutputType.Map,
                    Name     = "WoodyDebrisMap",
                    FilePath = PoolMapNames.ReplaceTemplateVars(PlugIn.poolsTemplateToMap,
                                                                "woody",
                                                                PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_WoodyDebris);
            }
            if (PlugIn.poolsToMap == "non-woody" || PlugIn.poolsToMap == "both")
            {
                OutputMetadata mapOut_NonWoodyDebris = new OutputMetadata()
                {
                    Type     = OutputType.Map,
                    Name     = "NonWoodyDebrisMap",
                    FilePath = PoolMapNames.ReplaceTemplateVars(PlugIn.poolsTemplateToMap,
                                                                "non-woody",
                                                                PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_NonWoodyDebris);
            }

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

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