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

        public override void LoadParameters(string dataFile, ICore mCore)
        {
            modelCore = mCore;
            SiteVars.Initialize();
            InputParameterParser parser = new InputParameterParser();

            parameters = Landis.Data.Load <IInputParameters>(dataFile, parser);
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Runs the component for a particular timestep.
        /// </summary>
        /// <param name="currentTime">
        /// The current model timestep.
        /// </param>
        public override void Run()
        {
            if (SiteVars.TimeOfLastFire == null)
            {
                SiteVars.ReInitialize();
            }

            SiteVars.FuelType.ActiveSiteValues      = 0;
            SiteVars.DecidFuelType.ActiveSiteValues = 0;

            modelCore.UI.WriteLine("  Calculating the Dynamic Fuel Type for all active cells...");
            foreach (ActiveSite site in modelCore.Landscape)
            {
                CalcFuelType(site, fuelTypes, disturbanceTypes);
                SiteVars.PercentDeadFir[site] = CalcPercentDeadFir(site);
            }

            string path = MapNames.ReplaceTemplateVars(mapNameTemplate, modelCore.CurrentTime);

            modelCore.UI.WriteLine("   Writing Fuel map to {0} ...", 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 = (byte)((int)SiteVars.FuelType[site] + 1);
                    }
                    else
                    {
                        pixel.MapCode.Value = 0;
                    }
                    outputRaster.WriteBufferPixel();
                }
            }

            string conpath = MapNames.ReplaceTemplateVars(pctConiferMapNameTemplate, modelCore.CurrentTime);

            modelCore.UI.WriteLine("   Writing % Conifer map to {0} ...", conpath);
            using (IOutputRaster <BytePixel> outputRaster = modelCore.CreateRaster <BytePixel>(conpath, modelCore.Landscape.Dimensions))
            {
                BytePixel pixel = outputRaster.BufferPixel;
                foreach (Site site in modelCore.Landscape.AllSites)
                {
                    if (site.IsActive)
                    {
                        pixel.MapCode.Value = (byte)((int)SiteVars.PercentConifer[site]);
                    }
                    else
                    {
                        pixel.MapCode.Value = 0;
                    }
                    outputRaster.WriteBufferPixel();
                }
            }
            string firpath = MapNames.ReplaceTemplateVars(pctDeadFirMapNameTemplate, modelCore.CurrentTime);

            modelCore.UI.WriteLine("   Writing % Dead Fir map to {0} ...", firpath);
            using (IOutputRaster <BytePixel> outputRaster = modelCore.CreateRaster <BytePixel>(firpath, modelCore.Landscape.Dimensions))
            {
                BytePixel pixel = outputRaster.BufferPixel;
                foreach (Site site in modelCore.Landscape.AllSites)
                {
                    if (site.IsActive)
                    {
                        pixel.MapCode.Value = (byte)((int)SiteVars.PercentDeadFir[site]);
                    }
                    else
                    {
                        pixel.MapCode.Value = 0;
                    }
                    outputRaster.WriteBufferPixel();
                }
            }
        }