private HurricaneEvent(ContinentalGrid continentalGrid) { //this.landfallLatitude = 34.3; /// For unit testing only. //this.stormTrackHeading = 310.0; /// For unit testing only. //this.hurricaneNumber = hurricaneNumber; this.ContinentalGrid = continentalGrid; this.landfallMaxWindSpeed = HurricaneEvent.WindSpeedGenerator.GetWindSpeed(); if (HurricaneRandomNumber) { this.landfallLatitude = 7.75 * PlugIn.HurricaneGeneratorStandard.NextDouble() + 30.7; this.stormTrackHeading = 80.0 * PlugIn.HurricaneGeneratorStandard.NextDouble() + 280.0; } else { this.landfallLatitude = 7.75 * PlugIn.ModelCore.GenerateUniform() + 30.7; // Specific to the southeastern US this.stormTrackHeading = 80.0 * PlugIn.ModelCore.GenerateUniform() + 280.0; // Specific to the southeastern US } var modHeading = (this.stormTrackHeading - 315) * Math.PI / 180.0; this.stormTrackSlope = 1 / Math.Tan(this.stormTrackHeading * Math.PI / 180.0); this.stormTrackPerpandicularSlope = -1.0 / this.stormTrackSlope; double landfallY = this.ContinentalGrid.ConvertLatitudeToGridUnits(this.landfallLatitude); this.LandfallPoint = this.ContinentalGrid.CoastLine.GivenYGetPoint(landfallY); this.StormTrackLine = new Line(this.LandfallPoint, this.stormTrackSlope); var stormTrackInterceptPt = this.StormTrackLine.GivenXGetPoint(0.0); this.stormTrackLengthTo_b = (this.LandfallPoint - stormTrackInterceptPt).Length; }
//--------------------------------------------------------------------- /// <summary> /// Initializes the plug-in with a data file. /// </summary> /// <param name="dataFile"> /// Path to the file with initialization data. /// </param> /// <param name="startTime"> /// Initial timestep (year): the timestep that will be passed to the /// first call to the component's Run method. /// </param> public override void Initialize() { HurricaneEvent.WindMortalityTable = new HurricaneWindMortalityTable(parameters.WindSpeedMortalityProbabilities); if (parameters.InputUnitsEnglish) { parameters.LowBoundLandfallWindSpeed *= 1.60934; parameters.ModeLandfallWindSpeed *= 1.60934; parameters.HighBoundLandfallWindspeed *= 1.60934; parameters.CenterPointDistanceInland *= 1.60934; //HurricaneEvent.WindMortalityTable.ChangeSpeedsFromEnglishToMetric(); } HurricaneEvent.WindSpeedGenerator = new WindSpeedGenerator(this.parameters.LowBoundLandfallWindSpeed, this.parameters.ModeLandfallWindSpeed, this.parameters.HighBoundLandfallWindspeed); //parameters.AdjustValuesFromEnglishToMetric(); List <string> colnames = new List <string>(); foreach (IEcoregion ecoregion in modelCore.Ecoregions) { colnames.Add(ecoregion.Name); } ExtensionMetadata.ColumnNames = colnames; MetadataHandler.InitializeMetadata(parameters.Timestep, parameters.MapNamesTemplate); Timestep = parameters.Timestep; mapNameTemplate = parameters.MapNamesTemplate; SiteVars.Initialize(); this.ContinentalGrid = new ContinentalGrid( this.parameters.CenterPointLatitude, PlugIn.ModelCore.CellLength, PlugIn.ModelCore.Landscape.Columns, PlugIn.ModelCore.Landscape.Rows, this.parameters.CenterPointDistanceInland ); if (parameters.HurricaneRandomNumberSeed > 0) { HurricaneEvent.HurricaneRandomNumber = true; HurricaneGeneratorStandard = new Troschuetz.Random.Generators.MT19937Generator((uint)parameters.HurricaneRandomNumberSeed); HurricaneGeneratorLogNormal = new Troschuetz.Random.Distributions.Continuous.LognormalDistribution((uint)parameters.HurricaneRandomNumberSeed); } //double testDouble = hurricaneGenerator.NextDouble(); }
public static HurricaneEvent Initiate(ContinentalGrid continentalGrid) { HurricaneEvent hurrEvent = new HurricaneEvent(continentalGrid); return(hurrEvent); }
internal bool GenerateWindFieldRaster( string mapNameTemplate, ICore modelCore, ContinentalGrid continentalGrid) { this.ContinentalGrid = continentalGrid; Dimensions dimensions = new Dimensions(modelCore.Landscape.Rows, modelCore.Landscape.Columns); int columns = modelCore.Landscape.Columns; int rows = modelCore.Landscape.Rows; double lowerLeftWindspeed = this.GetWindSpeed(0, 0); double lowerRightWindSpeed = this.GetWindSpeed(columns, 0); double upperRightWindSpeed = this.GetWindSpeed(columns, rows); double upperLeftWindSpeed = this.GetWindSpeed(0, rows); double maxWS = (new[] { lowerLeftWindspeed, lowerRightWindSpeed, upperRightWindSpeed, upperLeftWindSpeed }).Max(); //double minWS = (new[] { lowerLeftWindspeed, lowerRightWindSpeed, upperRightWindSpeed, upperLeftWindSpeed }).Min(); this.studyAreaImpacts = true; if (maxWS < HurricaneEvent.MinimumWSforDamage) { //PlugIn.ModelCore.UI.WriteLine(" Hurricane Not Sufficient to Cause Damage: MaxWS={0}, HurricaneMinWS={1}", maxWS, MinimumWSforDamage); this.studyAreaImpacts = false; //return false; } SiteVars.WindSpeed.ActiveSiteValues = 0.0; foreach (ActiveSite site in PlugIn.ModelCore.Landscape.ActiveSites) { currentSite = site; SiteVars.WindSpeed[currentSite] = this.GetWindSpeed(site.Location.Column, site.Location.Row); KillSiteCohorts(currentSite); } double activeAreaMinWS = 999.0; double activeAreaMaxWS = 0.0; string path = MapNames.ReplaceTemplateVars(mapNameTemplate, modelCore.CurrentTime); IOutputRaster <BytePixel> outputRaster = null; using (outputRaster = modelCore.CreateRaster <BytePixel>(path, dimensions)) { BytePixel pixel = outputRaster.BufferPixel; foreach (Site site in PlugIn.ModelCore.Landscape.AllSites) { if (site.IsActive) { double windspeed = SiteVars.WindSpeed[site]; pixel.MapCode.Value = (byte)windspeed; if (windspeed < activeAreaMinWS) { activeAreaMinWS = windspeed; } if (windspeed > activeAreaMaxWS) { activeAreaMaxWS = windspeed; } } else { // Inactive site pixel.MapCode.Value = (byte)0; } outputRaster.WriteBufferPixel(); } } this.StudyAreaMinWindspeed = activeAreaMinWS; this.StudyAreaMaxWindspeed = activeAreaMaxWS; //PlugIn.ModelCore.UI.WriteLine(" Hurricane Caused Damage: AreaMaxWS={0}, AreaMinWS={1}", activeAreaMaxWS, activeAreaMinWS); return(true); }