fastoad.base.flight_point module¶
Structure for managing flight point data.
-
class
fastoad.base.flight_point.
FlightPoint
(*args, **kwargs)[source]¶ Bases:
fastoad.base.dict.DynamicAttributeDict
Class for storing data for one flight point.
An instance is a simple dict, but for convenience, each item can be accessed as an attribute (inspired by pandas DataFrames). Hence, one can write:
>>> fp = FlightPoint(speed=250., altitude=10000.) >>> fp["speed"] 250.0 >>> fp2 = FlightPoint({"speed":150., "altitude":5000.}) >>> fp2.speed 250.0 >>> fp["mass"] = 70000. >>> fp.mass 70000.0 >>> fp.mass = 50000. >>> fp["mass"] 50000.0
Note: constructor will forbid usage of unknown keys as keyword argument, but other methods will allow them, while not making the matching between dict keys and attributes, hence:
>>> fp["foo"] = 42 # Ok >>> bar = fp.foo # raises exception !!!! >>> fp.foo = 50 # allowed by Python >>> # But inner dict is not affected: >>> fp.foo 50 >>> fp["foo"] 42
This class is especially useful for generating pandas DataFrame: a pandas DataFrame can be generated from a list of dict… or a list of FlightPoint instances.
The set of dictionary keys that are mapped to instance attributes is given by the
get_attribute_keys()
.A dictionary class where keys can also be used as attributes.
The keys that can be used as attributes are defined using decorators
AddKeyAttribute
orSetKeyAttributes
.They can also be used as keyword arguments when instantiating this class.
Note
Using this class as a dict is useful when instantiating another dict or a pandas DataFrame, or instantiating from them. Direct interaction with DynamicAttributeDict instance should be done through attributes.
Example:
>>> @AddKeyAttributes({"foo": 0.0, "bar": None, "baz": 42.0}) ... class MyDict(DynamicAttributeDict): ... pass ... >>> d = MyDict(foo=5, bar="aa") >>> d.foo 5 >>> d.bar 'aa' >>> d.baz # returns the default value 42.0 >>> d["foo"] = 10.0 # can still be used as a dict >>> d.foo # but change are propagated to/from the matching attribute 10.0 >>> d.foo = np.nan # setting None or numpy.nan returns to default value >>> d["foo"] 0.0 >>> d.foo # But the attribute will now return the default value 0.0 >>> d.bar = None # If default value is None, setting None or numpy.nan deletes the key. >>> # d["bar"] #would trigger a key error >>> d.bar # But the attribute will return None
- Parameters
args – a dict-like object where all keys are contained in
attribute_keys
kwargs – argument keywords must be names contained in
attribute_keys
-
property
CD
¶ Drag coeffient.
-
property
CL
¶ Lift coeffient.
-
property
acceleration
¶ Acceleration value in m/s**2.
-
property
altitude
¶ Altitude in meters.
-
property
drag
¶ Aircraft drag in Newtons.
-
property
engine_setting
¶ Engine setting (see
EngineSetting
).
-
property
equivalent_airspeed
¶ Equivalent airspeed (EAS) in m/s.
-
classmethod
get_attribute_keys
()¶ - Returns
list of attributes paired to dict key.
-
property
ground_distance
¶ Covered ground distance in meters.
-
property
mach
¶ Mach number.
-
property
mass
¶ Mass in kg.
-
property
name
¶ Name of current phase.
-
property
sfc
¶ Specific Fuel Consumption in kg/N/s.
-
property
slope_angle
¶ Slope angle in radians.
-
property
thrust
¶ Thrust in Newtons.
-
property
thrust_is_regulated
¶ Boolean. If True, propulsion should match the thrust value. If False, propulsion should match thrust rate.
-
property
thrust_rate
¶ Thrust rate (between 0. and 1.)
-
property
time
¶ Time in seconds.
-
property
true_airspeed
¶ True airspeed (TAS) in m/s.