//--------------------------------------------------------------------- public override void Initialize() { Model.Core.UI.WriteLine("Initializing {0}...", Name); SiteVars.Initialize(Model.Core); Timestep = parameters.Timestep; inputMapTemplate = parameters.InputMaps; pauseFunction = new Pause(parameters.ExternalScript, parameters.ExternalExecutable, parameters.ExternalCommand); if (!pauseFunction.UsePause) { Model.Core.UI.WriteLine("No pause processes specified, continuing normally"); pauseFunction = null; } if (parameters.SiteLogPath != null) { SiteLog.Initialize(parameters.SiteLogPath); } // Load initial land uses from input map for timestep 0 ProcessInputMap( delegate(Site site, LandUse initialLandUse) { SiteVars.LandUse[site] = initialLandUse; return(initialLandUse.Name); }); }
//--------------------------------------------------------------------- public override void CleanUp() { if (SiteLog.Enabled) { SiteLog.Close(); } }
//--------------------------------------------------------------------- //Overriding base LandisExtension method allows logfile to close and preserves written data public override void CleanUp() { Model.Core.UI.WriteLine("Closing logfile"); if (SiteLog.Enabled) { SiteLog.Close(); } }
//--------------------------------------------------------------------- public override void Run() { if (SiteLog.Enabled) { SiteLog.TimestepSetUp(); } ProcessInputMap( delegate(Site site, LandUse newLandUse) { LandUse currentLandUse = SiteVars.LandUse[site]; if (newLandUse != currentLandUse) { SiteVars.LandUse[site] = newLandUse; string transition = string.Format("{0} --> {1}", currentLandUse.Name, newLandUse.Name); if (!currentLandUse.AllowEstablishment && newLandUse.AllowEstablishment) { string message = string.Format("Error: The land-use change ({0}) at pixel {1} requires re-enabling establishment, but that's not currently supported", transition, site.Location); throw new System.ApplicationException(message); } else if (currentLandUse.AllowEstablishment && !newLandUse.AllowEstablishment) { Reproduction.PreventEstablishment((ActiveSite)site); } if (isDebugEnabled) { log.DebugFormat(" LU at {0}: {1}", site.Location, transition); } newLandUse.LandCoverChange.ApplyTo((ActiveSite)site); if (SiteLog.Enabled) { SiteLog.WriteTotalsFor((ActiveSite)site); } return(transition); } else { return(null); } }); if (SiteLog.Enabled) { SiteLog.TimestepTearDown(); } }
//--------------------------------------------------------------------- public override void Initialize() { Model.Core.UI.WriteLine("Initializing {0}...", Name); SiteVars.Initialize(Model.Core); Timestep = parameters.Timestep; inputMapTemplate = parameters.InputMaps; if (parameters.SiteLogPath != null) { SiteLog.Initialize(parameters.SiteLogPath); } // Load initial land uses from input map for timestep 0 ProcessInputMap( delegate(Site site, LandUse initialLandUse) { SiteVars.LandUse[site] = initialLandUse; return(initialLandUse.Name); }); }
//--------------------------------------------------------------------- public override void Run() { if (SiteLog.Enabled) { SiteLog.TimestepSetUp(); } if (pauseFunction != null) { pauseFunction.PauseTimestep(); } ProcessInputMap( delegate(Site site, LandUse newLandUse) { LandUse currentLandUse = SiteVars.LandUse[site]; string siteKey = null; if (newLandUse != currentLandUse) { SiteVars.LandUse[site] = newLandUse; siteKey = string.Format("{0} --> {1}", currentLandUse.Name, newLandUse.Name); if (!currentLandUse.AllowEstablishment && newLandUse.AllowEstablishment) { Reproduction.EnableEstablishment((ActiveSite)site); } else if (currentLandUse.AllowEstablishment && !newLandUse.AllowEstablishment) { Reproduction.PreventEstablishment((ActiveSite)site); } if (isDebugEnabled) { log.DebugFormat(" LU at {0}: {1}", site.Location, siteKey); } for (int i = 0; i < newLandUse.LandCoverChanges.Length; i++) { LandCover.IChange LandCoverChange = newLandUse.LandCoverChanges[i]; LandCoverChange.ApplyTo((ActiveSite)site, true); } } else { /*if (!currentLandUse.AllowEstablishment) * { * Reproduction.PreventEstablishment((ActiveSite)site); * } * else * { * Reproduction.EnableEstablishment((ActiveSite)site); * }*/ for (int i = 0; i < currentLandUse.LandCoverChanges.Length; i++) { LandCover.IChange LandCoverChange = newLandUse.LandCoverChanges[i]; LandCoverChange.ApplyTo((ActiveSite)site, false); } } if (SiteLog.Enabled) { SiteLog.WriteTotalsFor((ActiveSite)site); } return(siteKey); }); if (SiteLog.Enabled) { SiteLog.TimestepTearDown(); } }