//---------------------------------------------------------------------
///<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++;
}
}
}
}