//--------------------------------------------------------------------- /// <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) { IForestType[] forestTypes = map.ForestTypes; IOutputRaster <ClassPixel> newmap = CreateMap(map.Name); string path = newmap.Path; using (newmap) { ClassPixel pixel = new ClassPixel(); foreach (Site site in modelCore.Landscape.AllSites) { if (site.IsActive) { pixel.Band0 = CalcForestType(site, forestTypes); } else { pixel.Band0 = 0; } newmap.WritePixel(pixel); } } //Erdas74TrailerFile.Write(path, map.ForestTypes); } }
//--------------------------------------------------------------------- /// <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; }
//--------------------------------------------------------------------- public override void Run() { //if keyword == maxage 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(); }
//--------------------------------------------------------------------- /// <summary> /// Runs the component for a particular timestep. /// </summary> /// <param name="currentTime"> /// The current model timestep. /// </param> public void Run(int currentTime) { foreach (IMapDefinition map in mapDefs) { IForestType[] forestTypes = map.ForestTypes; IOutputRaster <ClassPixel> newmap = CreateMap(map.Name, currentTime); string path = newmap.Path; using (newmap) { ClassPixel pixel = new ClassPixel(); foreach (Site site in Model.Landscape.AllSites) { if (site.IsActive) { pixel.Band0 = CalcForestType(cohorts[site], forestTypes); } else { pixel.Band0 = 0; } newmap.WritePixel(pixel); } } //Erdas74TrailerFile.Write(path, map.ForestTypes); } nextTimeToRun += timestep; }
//--------------------------------------------------------------------- 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); } } }
//--------------------------------------------------------------------- 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); } } }
//--------------------------------------------------------------------- ///<summary> /// Run the BDA extension at a particular timestep. ///</summary> public override void Run() { UI.WriteLine("Processing landscape for BDA events ..."); //SiteVars.Epidemic.SiteValues = null; int eventCount = 0; foreach (IAgent activeAgent in manyAgentParameters) { activeAgent.TimeSinceLastEpidemic += Timestep; //UI.WriteLine("TimeSince={0}, TimeToNext={1}", activeAgent.TimeSinceLastEpidemic, activeAgent.TimeToNextEpidemic); //(activeAgent.TimeSinceLastEpidemic+ activeAgent.TimeToNextEpidemic)); int ROS = RegionalOutbreakStatus(activeAgent, Timestep); if (ROS > 0) { Epidemic.Initialize(activeAgent); Epidemic currentEpic = Epidemic.Simulate(activeAgent, Model.Core.CurrentTime, Timestep, ROS); //activeAgent.TimeSinceLastEpidemic = activeAgent.TimeSinceLastEpidemic + Timestep; if (currentEpic != null) { LogEvent(Model.Core.CurrentTime, currentEpic, ROS); //----- Write BDA severity maps -------- IOutputRaster <SeverityPixel> map = CreateMap(Model.Core.CurrentTime, activeAgent.AgentName); using (map) { SeverityPixel pixel = new SeverityPixel(); foreach (Site site in Model.Core.Landscape.AllSites) { if (site.IsActive) { if (SiteVars.Disturbed[site]) { pixel.Band0 = (byte)(activeAgent.Severity[site] + 1); } else { pixel.Band0 = 1; } } else { // Inactive site pixel.Band0 = 0; } map.WritePixel(pixel); } } if (!(srdMapNames == "")) { //----- Write BDA SRD maps -------- IOutputRaster <UShortPixel> srdmap = CreateSRDMap(Model.Core.CurrentTime, activeAgent.AgentName); using (srdmap) { UShortPixel pixel = new UShortPixel(); foreach (Site site in Model.Core.Landscape.AllSites) { if (site.IsActive) { pixel.Band0 = (ushort)System.Math.Round(SiteVars.SiteResourceDom[site] * 100.00); } else { // Inactive site pixel.Band0 = 0; } srdmap.WritePixel(pixel); } } } if (!(nrdMapNames == "")) { //----- Write BDA NRD maps -------- IOutputRaster <UShortPixel> nrdmap = CreateNRDMap(Model.Core.CurrentTime, activeAgent.AgentName); using (nrdmap) { UShortPixel pixel = new UShortPixel(); foreach (Site site in Model.Core.Landscape.AllSites) { if (site.IsActive) { pixel.Band0 = (ushort)System.Math.Round(SiteVars.NeighborResourceDom[site] * 100.00); } else { // Inactive site pixel.Band0 = 0; } nrdmap.WritePixel(pixel); } } } //----- Write Site Vulnerability or OutbreakZone maps -------- //----- USED FOR LANDSCAPE TESTING ----------- /*IOutputRaster<UShortPixel> dmap = CreateUShortMap(Model.Core.CurrentTimestep, activeAgent.AgentName); * using (dmap) { * UShortPixel pixel = new UShortPixel(); * foreach (Site site in Model.Core.Landscape.AllSites) { * if (site.IsActive) { * //pixel.Band0 = (ushort) (activeAgent.OutbreakZone[site]); * pixel.Band0 = (ushort) (SiteVars.Vulnerability[site] * 100); * } * else { * // Inactive site * pixel.Band0 = 0; * } * dmap.WritePixel(pixel); * } * }*/ /*IOutputRaster<UShortPixel> nmap = CreateUShortMap2(Model.Core.CurrentTimestep, activeAgent.AgentName); * using (nmap) { * UShortPixel pixel = new UShortPixel(); * foreach (Site site in Model.Landscape.AllSites) { * if (site.IsActive) { * //pixel.Band0 = (ushort) (activeAgent.OutbreakZone[site]); * pixel.Band0 = (ushort) System.Math.Round(SiteVars.NeighborResourceDom[site] * 100.00); * } * else { * // Inactive site * pixel.Band0 = 0; * } * nmap.WritePixel(pixel); * } * }*/ eventCount++; } } } }