fastoad.model_base.flight_point module¶
Structure for managing flight point data.
- class fastoad.model_base.flight_point.FlightPoint(time: float = 0.0, altitude: Optional[float] = None, ground_distance: float = 0.0, mass: Optional[float] = None, true_airspeed: Optional[float] = None, equivalent_airspeed: Optional[float] = None, mach: Optional[float] = None, engine_setting: Optional[fastoad.constants.EngineSetting] = None, CL: Optional[float] = None, CD: Optional[float] = None, drag: Optional[float] = None, thrust: Optional[float] = None, thrust_rate: Optional[float] = None, thrust_is_regulated: Optional[bool] = None, sfc: Optional[float] = None, slope_angle: Optional[float] = None, acceleration: Optional[float] = None, name: Optional[str] = None)[source]¶
Bases:
object
Dataclass for storing data for one flight point.
This class is meant for:
pandas friendliness: data exchange with pandas DataFrames is simple
extensibility: any user might add fields to the class using
add_field()
Exchanges with pandas DataFrame
A pandas DataFrame can be generated from a list of FlightPoint instances:
>>> import pandas as pd >>> from fastoad.model_base import FlightPoint >>> fp1 = FlightPoint(mass=70000., altitude=0.) >>> fp2 = FlightPoint(mass=60000., altitude=10000.) >>> df = pd.DataFrame([fp1, fp2])
And FlightPoint instances can be created from DataFrame rows:
# Get one FlightPoint instance from a DataFrame row >>> fp1bis = FlightPoint.create(df.iloc[0]) # Get a list of FlightPoint instances from the whole DataFrame >>> flight_points = FlightPoint.create_list(df)
Extensibility
FlightPoint class is bundled with several fields that are commonly used in trajectory assessment, but one might need additional fields.
Python allows to add attributes to any instance at runtime, but for FlightPoint to run smoothly, especially when exchanging data with pandas, you have to work at class level. This can be done using
add_field()
, preferably outside of any class or function:# Adds a float field with None as default value >>> FlightPoint.add_field("ion_drive_power") # Adds a field and define its type and default value >>> FlightPoint.add_field("warp", annotation_type=int, default_value=9) # Now these fields can be used at instantiation >>> fp = FlightPoint(ion_drive_power=110.0, warp=12) # Removes a field, even an original one (useful only to avoid having it in outputs) >>> FlightPoint.remove_field("sfc")
Note
All parameters in FlightPoint instances are expected to be in SI units.
- engine_setting: fastoad.constants.EngineSetting = None¶
Engine setting.
- thrust_is_regulated: bool = None¶
If True, propulsion should match the thrust value. If False, propulsion should match thrust rate.
- classmethod get_units() → dict[source]¶
Returns (field name, unit) dict for any field that has a defined unit.
A dimensionless physical quantity will have “-” as unit.
- classmethod create(data: Mapping) → fastoad.model_base.flight_point.FlightPoint[source]¶
Instantiate FlightPoint from provided data.
data can typically be a dict or a pandas DataFrame row.
- Parameters
data – a dict-like instance where keys are FlightPoint attribute names
- Returns
the created FlightPoint instance
- classmethod create_list(data: pandas.core.frame.DataFrame) → List[fastoad.model_base.flight_point.FlightPoint][source]¶
Creates a list of FlightPoint instances from provided DataFrame.
- Parameters
data – a dict-like instance where keys are FlightPoint attribute names
- Returns
the created FlightPoint instance
- classmethod add_field(name: str, annotation_type=<class 'float'>, default_value: Optional[Any] = None, unit=None)[source]¶
Adds the named field to FlightPoint class.
If the field name already exists, the field is redefined.
- Parameters
name – field name
annotation_type – field type
default_value – field default value
unit – expected unit for the added field (“-” should be provided for a dimensionless physical quantity)