Exemplo n.º 1
0
        //---------------------------------------------------------------------

        /// <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 = MapFiles.ReplaceTemplateVars(mapNameTemplate, map.Name, modelCore.CurrentTime);
                modelCore.UI.WriteLine("   Writing age reclass map {0} to {1} ...", map.Name, 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(site, forestTypes);
                        }
                        else
                        {
                            pixel.MapCode.Value = 0;
                        }

                        outputRaster.WriteBufferPixel();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void InitializeMetadata(int Timestep, string MapFileName, IEnumerable <IMapDefinition> mapDefs)
        {
            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
            };

            //---------------------------------------
            //          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 mapDefs)
            {
                OutputMetadata mapOut_biomassRemoved = new OutputMetadata()
                {
                    Type         = OutputType.Map,
                    Name         = map.Name,
                    FilePath     = MapFiles.ReplaceTemplateVars(MapFileName, map.Name, PlugIn.ModelCore.CurrentTime),
                    Map_DataType = MapDataType.Continuous,
                    Visualize    = true,
                    //Map_Unit = "categorical",
                };
                Extension.OutputMetadatas.Add(mapOut_biomassRemoved);
            }

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

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