def random_wind(minimum: int, maximum) -> WindConditions: wind_direction = random.randint(0, 360) at_0m_factor = 1 at_2000m_factor = 2 at_8000m_factor = 3 base_wind = random.randint(minimum, maximum) return WindConditions( # Always some wind to make the smoke move a bit. at_0m=Wind(wind_direction, max(1, base_wind * at_0m_factor)), at_2000m=Wind(wind_direction, base_wind * at_2000m_factor), at_8000m=Wind(wind_direction, base_wind * at_8000m_factor))
def random_wind(minimum: int, maximum: int) -> WindConditions: wind_direction = Heading.random() wind_direction_2000m = wind_direction + Heading.random(-90, 90) wind_direction_8000m = wind_direction + Heading.random(-90, 90) at_0m_factor = 1 at_2000m_factor = 2 at_8000m_factor = 3 base_wind = random.randint(minimum, maximum) return WindConditions( # Always some wind to make the smoke move a bit. at_0m=Wind(wind_direction.degrees, max(1, base_wind * at_0m_factor)), at_2000m=Wind(wind_direction_2000m.degrees, base_wind * at_2000m_factor), at_8000m=Wind(wind_direction_8000m.degrees, base_wind * at_8000m_factor), )
def set_weather(self, weather: WeatherResponse): speed = weather.wind.speed direction = weather.wind.direction self.mission.weather.wind_at_8000 = Wind( round((direction * numpy.random.normal(1, 0.1) + 180) % 360), round(speed * numpy.random.normal(1.2, 0.1)), ) self.mission.weather.wind_at_2000 = Wind( round((direction * numpy.random.normal(1, 0.1) + 180) % 360), round(speed * numpy.random.normal(1.1, 0.1)), ) self.mission.weather.wind_at_ground = Wind( round((direction * numpy.random.normal(1, 0.1) + 180) % 360), round(speed * numpy.random.normal(1, 0.1)), ) self.mission.weather.fog_visibility = weather.visibility (cloud_preset, cloud_base) = self.get_cloud_preset(weather) pressure: Torr = weather.main.pressure.to_torr() self.mission.weather.clouds_preset = cloud_preset self.mission.weather.clouds_base = cloud_base self.mission.weather.qnh = round(pressure.value) self.mission.weather.season_temperature = round( weather.main.temperature) self.mission.start_time = weather.time return WeatherResult( self.mission.start_time, cloud_preset.ui_name, self.mission.weather.season_temperature, cloud_base, pressure.to_inch_of_mercury(), self.mission.weather.wind_at_ground, self.mission.weather.wind_at_2000, self.mission.weather.wind_at_8000, )