mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Spell turbulence correctly.
This commit is contained in:
@@ -17,7 +17,7 @@ class EnvironmentGenerator:
|
||||
def set_atmospheric(self, atmospheric: AtmosphericConditions) -> None:
|
||||
self.mission.weather.qnh = atmospheric.qnh.mm_hg
|
||||
self.mission.weather.season_temperature = atmospheric.temperature_celsius
|
||||
self.mission.weather.turbulence_at_ground = int(atmospheric.turbulance_per_10cm)
|
||||
self.mission.weather.turbulence_at_ground = int(atmospheric.turbulence_per_10cm)
|
||||
|
||||
def set_clouds(self, clouds: Optional[Clouds]) -> None:
|
||||
if clouds is None:
|
||||
|
||||
@@ -401,7 +401,7 @@ class BriefingPage(KneeboardPage):
|
||||
)
|
||||
writer.text(f"QNH: {qnh_in_hg} inHg / {qnh_mm_hg} mmHg / {qnh_hpa} hPa")
|
||||
writer.text(
|
||||
f"Turbulance: {round(self.weather.atmospheric.turbulance_per_10cm)} per 10cm at ground level."
|
||||
f"Turbulence: {round(self.weather.atmospheric.turbulence_per_10cm)} per 10cm at ground level."
|
||||
)
|
||||
|
||||
fl = self.flight
|
||||
|
||||
@@ -45,9 +45,9 @@ class SeasonalConditions:
|
||||
winter_avg_temperature: float
|
||||
temperature_day_night_difference: float
|
||||
|
||||
high_avg_yearly_turbulance_per_10cm: float
|
||||
low_avg_yearly_turbulance_per_10cm: float
|
||||
solar_noon_turbulance_per_10cm: float
|
||||
midnight_turbulance_per_10cm: float
|
||||
high_avg_yearly_turbulence_per_10cm: float
|
||||
low_avg_yearly_turbulence_per_10cm: float
|
||||
solar_noon_turbulence_per_10cm: float
|
||||
midnight_turbulence_per_10cm: float
|
||||
|
||||
weather_type_chances: dict[Season, WeatherTypeChances]
|
||||
|
||||
@@ -58,19 +58,19 @@ class SeasonData:
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TurbulanceData:
|
||||
high_avg_yearly_turbulance_per_10cm: float | None
|
||||
low_avg_yearly_turbulance_per_10cm: float | None
|
||||
solar_noon_turbulance_per_10cm: float | None
|
||||
midnight_turbulance_per_10cm: float | None
|
||||
class TurbulenceData:
|
||||
high_avg_yearly_turbulence_per_10cm: float | None
|
||||
low_avg_yearly_turbulence_per_10cm: float | None
|
||||
solar_noon_turbulence_per_10cm: float | None
|
||||
midnight_turbulence_per_10cm: float | None
|
||||
|
||||
@staticmethod
|
||||
def from_yaml(data: dict[str, Any]) -> TurbulanceData:
|
||||
return TurbulanceData(
|
||||
data.get("high_avg_yearly_turbulance_per_10cm"),
|
||||
data.get("low_avg_yearly_turbulance_per_10cm"),
|
||||
data.get("solar_noon_turbulance_per_10cm"),
|
||||
data.get("midnight_turbulance_per_10cm"),
|
||||
def from_yaml(data: dict[str, Any]) -> TurbulenceData:
|
||||
return TurbulenceData(
|
||||
data.get("high_avg_yearly_turbulence_per_10cm"),
|
||||
data.get("low_avg_yearly_turbulence_per_10cm"),
|
||||
data.get("solar_noon_turbulence_per_10cm"),
|
||||
data.get("midnight_turbulence_per_10cm"),
|
||||
)
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class TheaterLoader:
|
||||
spring = SeasonData.from_yaml(climate_data["seasons"]["spring"])
|
||||
summer = SeasonData.from_yaml(climate_data["seasons"]["summer"])
|
||||
fall = SeasonData.from_yaml(climate_data["seasons"]["fall"])
|
||||
turbulance = TurbulanceData.from_yaml(climate_data["turbulance"])
|
||||
turbulence = TurbulenceData.from_yaml(climate_data["turbulence"])
|
||||
if summer.average_pressure is None:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a summer average pressure"
|
||||
@@ -147,21 +147,21 @@ class TheaterLoader:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a winter average temperature"
|
||||
)
|
||||
if turbulance.high_avg_yearly_turbulance_per_10cm is None:
|
||||
if turbulence.high_avg_yearly_turbulence_per_10cm is None:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a yearly average high turbulance"
|
||||
f"{self.descriptor_path} does not define a yearly average high turbulence"
|
||||
)
|
||||
if turbulance.low_avg_yearly_turbulance_per_10cm is None:
|
||||
if turbulence.low_avg_yearly_turbulence_per_10cm is None:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a yearly average low turbulance"
|
||||
f"{self.descriptor_path} does not define a yearly average low turbulence"
|
||||
)
|
||||
if turbulance.solar_noon_turbulance_per_10cm is None:
|
||||
if turbulence.solar_noon_turbulence_per_10cm is None:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a solar noon turbulance"
|
||||
f"{self.descriptor_path} does not define a solar noon turbulence"
|
||||
)
|
||||
if turbulance.midnight_turbulance_per_10cm is None:
|
||||
if turbulence.midnight_turbulence_per_10cm is None:
|
||||
raise RuntimeError(
|
||||
f"{self.descriptor_path} does not define a midnight turbulance"
|
||||
f"{self.descriptor_path} does not define a midnight turbulence"
|
||||
)
|
||||
return SeasonalConditions(
|
||||
summer.average_pressure,
|
||||
@@ -169,10 +169,10 @@ class TheaterLoader:
|
||||
summer.average_temperature,
|
||||
winter.average_temperature,
|
||||
climate_data["day_night_temperature_difference"],
|
||||
turbulance.high_avg_yearly_turbulance_per_10cm,
|
||||
turbulance.low_avg_yearly_turbulance_per_10cm,
|
||||
turbulance.solar_noon_turbulance_per_10cm,
|
||||
turbulance.midnight_turbulance_per_10cm,
|
||||
turbulence.high_avg_yearly_turbulence_per_10cm,
|
||||
turbulence.low_avg_yearly_turbulence_per_10cm,
|
||||
turbulence.solar_noon_turbulence_per_10cm,
|
||||
turbulence.midnight_turbulence_per_10cm,
|
||||
{
|
||||
Season.Winter: winter.weather,
|
||||
Season.Spring: spring.weather,
|
||||
|
||||
@@ -37,8 +37,8 @@ class AtmosphericConditions:
|
||||
#: Temperature at sea level in Celcius.
|
||||
temperature_celsius: float
|
||||
|
||||
#: Turbulance per 10 cm.
|
||||
turbulance_per_10cm: float
|
||||
#: Turbulence per 10 cm.
|
||||
turbulence_per_10cm: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -112,22 +112,22 @@ class Weather:
|
||||
day,
|
||||
)
|
||||
|
||||
seasonal_turbulance = self.interpolate_seasonal_turbulance(
|
||||
seasonal_conditions.high_avg_yearly_turbulance_per_10cm,
|
||||
seasonal_conditions.low_avg_yearly_turbulance_per_10cm,
|
||||
seasonal_turbulence = self.interpolate_seasonal_turbulence(
|
||||
seasonal_conditions.high_avg_yearly_turbulence_per_10cm,
|
||||
seasonal_conditions.low_avg_yearly_turbulence_per_10cm,
|
||||
day,
|
||||
)
|
||||
|
||||
day_turbulance = seasonal_conditions.solar_noon_turbulance_per_10cm
|
||||
night_turbulance = seasonal_conditions.midnight_turbulance_per_10cm
|
||||
time_of_day_turbulance = self.interpolate_solar_activity(
|
||||
time_of_day, day_turbulance, night_turbulance
|
||||
day_turbulence = seasonal_conditions.solar_noon_turbulence_per_10cm
|
||||
night_turbulence = seasonal_conditions.midnight_turbulence_per_10cm
|
||||
time_of_day_turbulence = self.interpolate_solar_activity(
|
||||
time_of_day, day_turbulence, night_turbulence
|
||||
)
|
||||
|
||||
random_turbulance = random.normalvariate(mu=0, sigma=0.5)
|
||||
random_turbulence = random.normalvariate(mu=0, sigma=0.5)
|
||||
|
||||
turbulance = abs(
|
||||
seasonal_turbulance + time_of_day_turbulance + random_turbulance
|
||||
turbulence = abs(
|
||||
seasonal_turbulence + time_of_day_turbulence + random_turbulence
|
||||
)
|
||||
|
||||
if time_of_day == TimeOfDay.Day:
|
||||
@@ -136,14 +136,14 @@ class Weather:
|
||||
temperature -= seasonal_conditions.temperature_day_night_difference / 2
|
||||
pressure += self.pressure_adjustment
|
||||
temperature += self.temperature_adjustment
|
||||
turbulance += self.turbulance_adjustment
|
||||
turbulence += self.turbulence_adjustment
|
||||
logging.debug(
|
||||
"Weather: Before random: temp {} press {}".format(temperature, pressure)
|
||||
)
|
||||
conditions = AtmosphericConditions(
|
||||
qnh=self.random_pressure(pressure),
|
||||
temperature_celsius=self.random_temperature(temperature),
|
||||
turbulance_per_10cm=turbulance,
|
||||
turbulence_per_10cm=turbulence,
|
||||
)
|
||||
logging.debug(
|
||||
"Weather: After random: temp {} press {}".format(
|
||||
@@ -161,7 +161,7 @@ class Weather:
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def turbulance_adjustment(self) -> float:
|
||||
def turbulence_adjustment(self) -> float:
|
||||
raise NotImplementedError
|
||||
|
||||
def generate_clouds(self) -> Optional[Clouds]:
|
||||
@@ -272,7 +272,7 @@ class Weather:
|
||||
return interpolate(summer_value, winter_value, winter_factor, clamp=True)
|
||||
|
||||
@staticmethod
|
||||
def interpolate_seasonal_turbulance(
|
||||
def interpolate_seasonal_turbulence(
|
||||
high_value: float, low_value: float, day: datetime.date
|
||||
) -> float:
|
||||
day_of_year = day.timetuple().tm_yday
|
||||
@@ -318,7 +318,7 @@ class ClearSkies(Weather):
|
||||
return 3.0
|
||||
|
||||
@property
|
||||
def turbulance_adjustment(self) -> float:
|
||||
def turbulence_adjustment(self) -> float:
|
||||
return 0.3
|
||||
|
||||
def generate_clouds(self) -> Optional[Clouds]:
|
||||
@@ -341,7 +341,7 @@ class Cloudy(Weather):
|
||||
return 0.0
|
||||
|
||||
@property
|
||||
def turbulance_adjustment(self) -> float:
|
||||
def turbulence_adjustment(self) -> float:
|
||||
return 0.6
|
||||
|
||||
def generate_clouds(self) -> Optional[Clouds]:
|
||||
@@ -365,7 +365,7 @@ class Raining(Weather):
|
||||
return -3.0
|
||||
|
||||
@property
|
||||
def turbulance_adjustment(self) -> float:
|
||||
def turbulence_adjustment(self) -> float:
|
||||
return 0.9
|
||||
|
||||
def generate_clouds(self) -> Optional[Clouds]:
|
||||
@@ -389,7 +389,7 @@ class Thunderstorm(Weather):
|
||||
return -3.0
|
||||
|
||||
@property
|
||||
def turbulance_adjustment(self) -> float:
|
||||
def turbulence_adjustment(self) -> float:
|
||||
return 1.2
|
||||
|
||||
def generate_clouds(self) -> Optional[Clouds]:
|
||||
|
||||
Reference in New Issue
Block a user