CADETProcess.dynamicEvents.TimeLine#

class CADETProcess.dynamicEvents.TimeLine[source]#

Bases: object

Class representing a timeline of time-varying data.

The timeline is made up of Sections, which are continuous time intervals. Each Section represents a piecewise polynomial function that defines the variation of a given parameter over time.

Attributes:
sectionsList[Section]

list: Sections of the TimeLine.

add_section(section: Section) None[source]#

Add a Section to the timeline.

Parameters:
sectionSection

The Section to be added to the timeline.

Raises:
TypeError

If section is not an instance of the Section class.

CADETProcessError

If the polynomial degree of the Section does not match the degree of the other Sections in the timeline.

CADETProcessError

If the Section introduces a gap in the timeline.

coefficients(time: float) ndarray[source]#

Return coefficient of polynomial at given time.

Parameters:
timefloat

Time at which polynomial coefficients are queried.

Returns:
coefficientsnp.ndarray

!!! Array of coefficients in ORDER !!!

property degree: int#

int: Degree of the polynomial functions used to represent each Section.

property end: float#

float: The end time of the timeline.

classmethod from_constant(start: float, end: float, value: float) TimeLine[source]#

Create a timeline with a constant value for a given time range.

Parameters:
startfloat

The start time of the time range.

endfloat

The end time of the time range.

valuefloat

The value of the timeline during the time range.

Returns:
TimeLine

A TimeLine instance with a single section with the specified constant value.

classmethod from_profile(time: ArrayLike, profile: ArrayLike, s: float = 1e-06) TimeLine[source]#

Create a timeline from a profile.

Parameters:
timearray_like

The time values of the profile.

profilearray_like

The profile values.

smoothingfloat, optional

The smoothing factor for the spline interpolation. The default is 1e-6.

Returns:
TimeLine

A TimeLine instance with polynomial sections created from the profile.

integral(start: float | None = None, end: float | None = None) ndarray[source]#

Calculate integral of sections in interval [start, end].

Parameters:
startfloat, optional

Lower integration bound.

endfloat, optional

Upper integration bound.

Returns:
Ynp.ndarray

Value of definite integral between start and end.

Raises:
ValueError

If integration bounds exceed section times.

property n_entries: int#

int: Number of entries in the parameter vector for each Section.

offset(offset: float) TimeLine[source]#

Shift the timeline by an offset.

Parameters:
offset: flaot

The offset.

Returns:
TimeLine

A new TimeLine instance with offset sections.

property piecewise_poly: list#

list: scipy.interpolate.PPoly for each dimension.

plot(x_axis_in_minutes: bool = True, ax: Axes | None = None, setup_figure_kwargs: dict | None = None) tuple[Figure, Axes][source]#

Plot the state of the timeline over time.

Parameters:
x_axis_in_minutes: bool, optional

If True, the x-axis will be plotted using minutes. The default is True.

axOptional[plt.Axes], default=None

Optional Matplotlib Axes. If not provided, a new figure is created.

setup_figure_kwargsOptional[dict], default=None

Additional options to setup the figure.

Returns:
tuple[plt.Figure, plt.Axes]

The Matplotlib Figure and Axes.

section_index(time: float) int[source]#

Return the index of the section that contains the specified time.

Parameters:
timefloat

The time to check.

Returns:
int

The index of the section that contains the specified time.

property section_times: list[float]#

List of float: The start and end times of all sections in the timeline.

property sections: list#

list: Sections of the TimeLine.

slice(start: float | None = None, end: float | None = None, offset: float | None = None) TimeLine[source]#

Slice the timeline from a profile.

Parameters:
startOptional[float]

Start time of the slice. If None, the first time point is used. The default is None.

end: Optional[float]

End time of the slice. If None, the last time point is used. The default is None.

offset: Optional[float]

Optional time offset. The default is None.

Returns:
TimeLine

A new TimeLine instance between start and end.

property start: float#

float: The start time of the timeline.

update_piecewise_poly() None[source]#

Update the piecewise polynomial representation of the timeline.

value(time: float) ndarray[source]#

np.ndarray: Value of parameter at given time.

Parameters:
timenp.float or array_like

time points at which to evaluate.