The FlightPoint class

The FlightPoint class is designed to store flight parameters for one flight point of any computed mission.

FlightPoint class is meant for:

  • storing all needed parameters that are needed for performance modelling, including propulsion parameters.

  • easily exchanging data with pandas DataFrame.

  • being extensible for new parameters.

Note

All parameters in FlightPoint instances are expected to be in SI units.

Available flight parameters

The documentation of FlightPoint provides the list of available flight parameters, available as attributes. As FlightPoint is a dataclass, this list is available through Python using:

>>> import fastoad.api as oad
>>> from dataclasses import fields

>>> [f.name for f in fields(oad.FlightPoint)]

Exchanges with pandas DataFrame

A pandas DataFrame can be generated from a list of FlightPoint instances:

>>> import pandas as pd
>>> import fastoad.api as oad

>>> fp1 = oad.FlightPoint(mass=70000., altitude=0.)
>>> fp2 = oad.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 = oad.FlightPoint.create(df.iloc[0])

# Get a list of FlightPoint instances from the whole DataFrame
>>> flight_points = oad.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")