Module environment

Contains the elements for the Environment class and Environment types

Classes

class Environment (type: EnvironmentType, gravity: float, air_density: float)

Dataclass to hold the Environment information.

Attributes

type : EnvironmentType
The type of the environment.
gravity : float
The gravity of the environment (m/s^2).
air_density : float
The air density of the environment (kg/m^3).
display_name : str
Formatted name of the environment.
Expand source code
@dataclass
class Environment:
    """
    Dataclass to hold the Environment information.

    Attributes:
        type (EnvironmentType): The type of the environment.
        gravity (float): The gravity of the environment (m/s^2).
        air_density (float): The air density of the environment (kg/m^3).
        display_name (str): Formatted name of the environment.
    """
    type: EnvironmentType
    gravity: float   # m/s^2
    air_density: float  # kg/m^3
    display_name: str = field(init=False)

    def __post_init__(self) -> None:
        self.display_name = f'{str(self.type):<15}'

    @classmethod
    def create_dict(cls) -> Dict[EnvironmentType, 'Environment']:
        """
        Creates a Dict of the "canned" environments available.
        """
        environments: List[Environment] = [
            cls(type=EnvironmentType.EARTH, gravity=9.81, air_density=1.225),
            cls(type=EnvironmentType.EARTH_NO_AIR, gravity=9.81, air_density=0),
            cls(type=EnvironmentType.MARS, gravity=3.72, air_density=0.02),
            cls(type=EnvironmentType.MOON, gravity=1.62, air_density=0),
            cls(type=EnvironmentType.VENUS, gravity=8.87, air_density=65),
            cls(type=EnvironmentType.JUPITER, gravity=24.79, air_density=0.16),
        ]
        return {env.type: env for env in environments}

Class variables

var air_density : float
var display_name : str
var gravity : float
var typeEnvironmentType

Static methods

def create_dict() ‑> Dict[EnvironmentTypeEnvironment]

Creates a Dict of the "canned" environments available.

class EnvironmentType (*args, **kwds)

Enum to hold Environment types

Expand source code
class EnvironmentType(Enum):
    """
    Enum to hold Environment types
    """
    EARTH = auto()
    EARTH_NO_AIR = auto()
    MARS = auto()
    MOON = auto()
    VENUS = auto()
    JUPITER = auto()
    CUSTOM = auto()

    def __str__(self) -> str:
        return self.name.replace('_', ' ').title()

Ancestors

  • enum.Enum

Class variables

var CUSTOM
var EARTH
var EARTH_NO_AIR
var JUPITER
var MARS
var MOON
var VENUS