Event Detectors¶
Core event detector classes for detecting specific conditions during numerical propagation.
TimeEvent ¶
Time-based event detector.
Triggers when simulation time reaches a target epoch. Useful for scheduled maneuvers or discrete events at known times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_epoch | Epoch | Target time for event detection | required |
name | str | Event name for identification | required |
Example
Initialize instance.
set_terminal method descriptor ¶
set_terminal() -> TimeEvent
Mark this event as terminal (stops propagation).
Returns:
| Name | Type | Description |
|---|---|---|
TimeEvent | TimeEvent | Self for method chaining |
with_callback method descriptor ¶
Set event callback.
The callback is called when the event is detected and can modify the state and override the terminal action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback | callable | Function (epoch, state) -> (Optional[state], EventAction) | required |
Returns:
| Name | Type | Description |
|---|---|---|
TimeEvent | TimeEvent | Self for method chaining |
Example
with_instance method descriptor ¶
with_time_tolerance method descriptor ¶
Set custom time tolerance for event detection.
Controls the precision of the bisection search algorithm. Smaller values result in more precise event time detection at the cost of more iterations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_tol | float | Time tolerance in seconds (default: 1e-6) | required |
Returns:
| Name | Type | Description |
|---|---|---|
TimeEvent | TimeEvent | Self for method chaining |
Example
ValueEvent ¶
ValueEvent(name: str, value_fn: callable, target_value: float, direction: EventDirection)
Value event detector with custom value function.
Monitors a custom value computed by a Python function and detects when it crosses a specified target value. The value function receives the current epoch and state, and returns a float value to monitor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Event name for identification | required |
value_fn | callable | Function (epoch, state) -> float that computes monitored value | required |
target_value | float | Target value for crossing detection | required |
direction | EventDirection | Detection direction (INCREASING, DECREASING, or ANY) | required |
Example
Initialize instance.
set_terminal method descriptor ¶
set_terminal() -> ValueEvent
Mark this event as terminal (stops propagation).
Returns:
| Name | Type | Description |
|---|---|---|
ValueEvent | ValueEvent | Self for method chaining |
with_callback method descriptor ¶
with_callback(callback: callable) -> ValueEvent
Set event callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback | callable | Function (epoch, state) -> (Optional[state], EventAction) | required |
Returns:
| Name | Type | Description |
|---|---|---|
ValueEvent | ValueEvent | Self for method chaining |
with_instance method descriptor ¶
with_instance(instance: int) -> ValueEvent
Set instance number for display name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance | int | Instance number to append | required |
Returns:
| Name | Type | Description |
|---|---|---|
ValueEvent | ValueEvent | Self for method chaining |
with_tolerances method descriptor ¶
with_tolerances(time_tol: float, value_tol: float) -> ValueEvent
Set custom tolerances for event detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_tol | float | Time tolerance in seconds (default: 1e-6) | required |
value_tol | float | Value tolerance (default: 1e-9) | required |
Returns:
| Name | Type | Description |
|---|---|---|
ValueEvent | ValueEvent | Self for method chaining |
BinaryEvent ¶
Binary event detector with custom condition function.
Detects boolean condition transitions (edges). The condition function receives the current epoch and state, and returns a boolean. The event fires when the condition transitions according to the specified edge type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Event name for identification | required |
condition_fn | callable | Function (epoch, state) -> bool that returns the condition | required |
edge | EdgeType | Which edge to detect (RISING_EDGE, FALLING_EDGE, or ANY_EDGE) | required |
Example
Initialize instance.
set_terminal method descriptor ¶
set_terminal() -> BinaryEvent
Mark this event as terminal (stops propagation).
Returns:
| Name | Type | Description |
|---|---|---|
BinaryEvent | BinaryEvent | Self for method chaining |
with_callback method descriptor ¶
with_callback(callback: callable) -> BinaryEvent
Set event callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback | callable | Function (epoch, state) -> (Optional[state], EventAction) | required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryEvent | BinaryEvent | Self for method chaining |
with_instance method descriptor ¶
with_instance(instance: int) -> BinaryEvent
Set instance number for display name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance | int | Instance number to append | required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryEvent | BinaryEvent | Self for method chaining |
with_tolerances method descriptor ¶
with_tolerances(time_tol: float, value_tol: float) -> BinaryEvent
Set custom tolerances for event detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_tol | float | Time tolerance in seconds (default: 1e-6) | required |
value_tol | float | Value tolerance (default: 1e-9) | required |
Returns:
| Name | Type | Description |
|---|---|---|
BinaryEvent | BinaryEvent | Self for method chaining |
See Also¶
- Pre-made Events - Convenience event detectors
- Event Results - DetectedEvent and EventQuery
- Enumerations - EventDirection, EdgeType, etc.