Migrate pressure to a typed unit.

This commit is contained in:
Dan Albert
2021-07-16 22:38:41 -07:00
parent d11174da21
commit 28f98aed88
5 changed files with 44 additions and 33 deletions

View File

@@ -3,7 +3,6 @@ from typing import Optional
from dcs.mission import Mission
from game.weather import Clouds, Fog, Conditions, WindConditions, AtmosphericConditions
from .units import inches_hg_to_mm_hg
class EnvironmentGenerator:
@@ -12,7 +11,7 @@ class EnvironmentGenerator:
self.conditions = conditions
def set_atmospheric(self, atmospheric: AtmosphericConditions) -> None:
self.mission.weather.qnh = inches_hg_to_mm_hg(atmospheric.qnh_inches_mercury)
self.mission.weather.qnh = atmospheric.qnh.mm_hg
self.mission.weather.season_temperature = atmospheric.temperature_celsius
def set_clouds(self, clouds: Optional[Clouds]) -> None:

View File

@@ -47,7 +47,6 @@ from .briefinggen import CommInfo, JtacInfo, MissionInfoGenerator
from .flights.flight import FlightWaypoint, FlightWaypointType, FlightType
from .radios import RadioFrequency
from .runways import RunwayData
from .units import inches_hg_to_mm_hg, inches_hg_to_hpa
if TYPE_CHECKING:
from game import Game
@@ -308,13 +307,9 @@ class BriefingPage(KneeboardPage):
writer.text(f"Bullseye: {self.bullseye.to_lat_lon(self.theater).format_dms()}")
qnh_in_hg = "{:.2f}".format(self.weather.atmospheric.qnh_inches_mercury)
qnh_mm_hg = "{:.1f}".format(
inches_hg_to_mm_hg(self.weather.atmospheric.qnh_inches_mercury)
)
qnh_hpa = "{:.1f}".format(
inches_hg_to_hpa(self.weather.atmospheric.qnh_inches_mercury)
)
qnh_in_hg = f"{self.weather.atmospheric.qnh.inches_hg:.2f}"
qnh_mm_hg = f"{self.weather.atmospheric.qnh.mm_hg:.1f}"
qnh_hpa = f"{self.weather.atmospheric.qnh.hecto_pascals:.1f}"
writer.text(
f"Temperature: {round(self.weather.atmospheric.temperature_celsius)} °C at sea level"
)

View File

@@ -1,16 +0,0 @@
"""Unit conversions."""
def meters_to_feet(meters: float) -> float:
"""Converts meters to feet."""
return meters * 3.28084
def inches_hg_to_mm_hg(inches_hg: float) -> float:
"""Converts inches mercury to millimeters mercury."""
return inches_hg * 25.400002776728
def inches_hg_to_hpa(inches_hg: float) -> float:
"""Converts inches mercury to hectopascal."""
return inches_hg * 33.86389