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[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.

time: float = 0.0

Time in seconds.

altitude: float = None

Altitude in meters.

ground_distance: float = 0.0

Covered ground distance in meters.

mass: float = None

Mass in kg.

true_airspeed: float = None

True airspeed (TAS) in m/s.

equivalent_airspeed: float = None

Equivalent airspeed (EAS) in m/s.

mach: float = None

Mach number.

engine_setting: EngineSetting = None

Engine setting.

CL: float = None

Lift coefficient.

CD: float = None

Drag coefficient.

drag: float = None

Aircraft drag in Newtons.

thrust: float = None

Thrust in Newtons.

thrust_rate: float = None

Thrust rate (between 0. and 1.)

thrust_is_regulated: bool = None

If True, propulsion should match the thrust value. If False, propulsion should match thrust rate.

sfc: float = None

Specific Fuel Consumption in kg/N/s.

slope_angle: float = None

Slope angle in radians.

acceleration: float = None

Acceleration value in m/s**2.

name: str = None

Name of current phase.

set_as_relative(field_names: Union[Sequence[str], str])[source]

Makes that values for given field_names will be considered as relative when calling make_absolute().

Parameters

field_names

set_as_absolute(field_names: Union[Sequence[str], str])[source]

Makes that values for given field_names will be considered as absolute when calling make_absolute().

Parameters

field_names

is_relative(field_name) bool[source]

Tells if given field is considered as relative or absolut

Parameters

field_name

Returns

True if it is relative

make_absolute(reference_point: FlightPoint) FlightPoint[source]

Computes a copy flight point where no field is relative.

Parameters

reference_point – relative fields will be made absolute using this point.

Returns

the copied flight point with no relative field.

classmethod get_field_names()[source]
Returns

names of all fields of the flight point.

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) 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: DataFrame) List[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: ~typing.Optional[~typing.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)

classmethod remove_field(name)[source]

Removes the named field from FlightPoint class.

Parameters

name – field name

scalarize()[source]

Convenience method for converting to scalars all fields that have a one-item array-like value.