3. ScenarioSetup#
- class ScenarioSetup(mission_sequence: MissionSequence, map_STM_to_t0: bool = False)#
Bases:
objectManages the setup and propagation of a mission scenario.
This class is responsible for orchestrating the execution of a mission sequence, ensuring consistency in propagated states, epochs, and dynamical models. It interacts with the propagator to execute trajectory propagation while handling State Transition Matrices (STMs) and maneuver modeling.
- Parameters:
mission_sequence (
MissionSequence) – The mission sequence containing legs, burns, and associated state vectors.map_STM_to_t0 (
bool, optional) – Whether to map the STM (State Transition Matrix) to the initial state. Defaults toFalse.
See also
scarabaeus.Propagatorthe propagator that ScenarioSetup interacts with.
Notes
The
ScenarioSetupclass is designed to be compatible with thePropagatorclass. Any updates to propagation functionality should be reflected here.Enforces mission constraints such as maximum numbers of legs and impulsive burns.
Attributes
The total concatenated STM history.
The last computed State Transition Matrix (STM).
The absolute tolerance for numerical integration.
The last computed impulsive delta-v, if applicable.
The last computed epoch in the mission sequence.
Retrieve the full state vector array for the scenario.
The total number of elements (legs + burns) in the mission sequence.
Indicates whether the STM should be mapped to the initial time.
The mission sequence associated with this scenario.
The origin body for the scenario.
The primary body for the scenario.
State array corresponding to the propagated solution.
The propagator responsible for trajectory calculations.
The relative tolerance for numerical integration.
Maps segment names to STM arrays.
Maps segment names to epoch arrays.
Maps segment names to parameter arrays.
Maps segment names to position arrays.
Maps segment names to velocity arrays.
The size of the last computed state vector.
The last computed state vector.
Get the total components dictionary.
Returns the total number of epochs for the TDB (presumably "Trajectory Data Base" or similar) by retrieving the epoch value from the primary "position" data source.
The total set of propagated parameters.
Returns the primary position value by invoking the _pick_primary method with "position" as the argument.
Calculate and return the total velocity from the primary velocity attribute.
Methods
deviation_history_to_global_dx(...[, ...])Convert a deviation history list to a global state deviation vector.
merge_state_list_with_old(new_list)Merge a new state list with the previous state vector, inheriting values from old parameters. This method matches parameters in the new list with those from the previous state vector using a composite key of (parameter name, spice_id, size). For matched parameters, the previous quantity values are inherited; for new parameters, their initial condition values are used. All parameters are wrapped in new ArrayWFrame objects. :param new_list: A list of tuples, each containing: - cname (str): Parameter name - csize: Parameter size - cest: Parameter estimate - cdyn: Parameter dynamics - cbody: Body object (may have spice_id attribute) - cawf (ArrayWFrame): Parameter with quantity and frame information :type new_list:
list.Executes the propagation of the mission sequence through all defined legs and impulsive burns.
reinitialize_scenario_state_def(new_state_def, *)Reinitialize the scenario state definition and propagate changes throughout the mission sequence. This method performs a comprehensive state schema migration that: 1. Snapshots the current global state vector 2. Installs the new state definition and associated index mapping 3. Projects values from the old global state to the new one, preserving overlapping keys 4. Optionally refills new state variables from the first model that provides them 5. Updates all StateArray models with new values from the global state vector 6. Reinitializes ImpulsiveBurn models from their corresponding DV parameter blocks 7. Resets cached state tracking variables (STM, state vector, state size) :param new_state_def: The new state definition schema to install. Contains all state variable specifications. :type new_state_def:
StateDefinition:param refill_from_models: If True, fill new state variables (not present in the old state) from initial model state values. The first model in the mission sequence that contains a matching state variable will seed the value. Default is True. :type refill_from_models:bool, optional :param update_models: If True, propagate the updated global state values back into all StateArray model instances in the mission sequence. Default is True. :type update_models:bool, optional :param update_states_n: If True, update the states_n tracking array with the new state dimensions for each rebuilt model. Default is False. :type update_states_n:bool, optional.update_stm(new_list)Updates the State Transition Matrix (STM) to match a new state vector layout.
reinitialize_from_deviation_global
- deviation_history_to_global_dx(deviation_history: list, *, as_column: bool = True, strict: bool = True) ndarray#
Convert a deviation history list to a global state deviation vector.
This method maps per-segment (Leg/Finite Burn) deviation vectors from a deviation_history list to their corresponding positions in the global scenario state vector.
- Parameters:
deviation_history (
list) – A list of deviation vectors, one per active segment (Leg or Finite Burn). Each entry should be array-like and will be converted to a 1D numpy array. Length must equal the number of active segments in the mission sequence.as_column (
bool, optional) – If True (default), return the global deviation vector as a column vector with shape (N_global, 1). If False, return as a 1D array with shape (N_global,).strict (
bool, optional) – If True (default), enforce strict size matching. Raises ValueError if any deviation entry does not match its expected local dimension or is too short. If False, truncates or pads vectors as needed without raising errors.
- Returns:
Global state deviation vector of shape (N_global, 1) if as_column=True, or (N_global,) if as_column=False, where N_global is the total dimension of the global scenario state.
- Return type:
np.ndarray- Raises:
ValueError – If length of deviation_history does not match the number of active segments. If strict=True and any deviation entry has mismatched dimensions.
KeyError – If a leg component key is not found in the scenario-global index map, indicating the scenario union state_def is incomplete.
Notes
Only “Leg” and “Finite Burn” segments are considered active.
The scenario index map is built on-demand if not already present.
Leg-to-global mappings are cached in _leg_to_global_maps for reuse.
- merge_state_list_with_old(new_list: list) list#
Merge a new state list with the previous state vector, inheriting values from old parameters. This method matches parameters in the new list with those from the previous state vector using a composite key of (parameter name, spice_id, size). For matched parameters, the previous quantity values are inherited; for new parameters, their initial condition values are used. All parameters are wrapped in new ArrayWFrame objects. :param new_list: A list of tuples, each containing:
cname (str): Parameter name
csize: Parameter size
cest: Parameter estimate
cdyn: Parameter dynamics
cbody: Body object (may have spice_id attribute)
cawf (ArrayWFrame): Parameter with quantity and frame information
- Returns:
- A list of updated tuples with the same structure as new_list, where each
tuple contains (cname, csize, cest, cdyn, cbody, new_awf) with new_awf containing inherited or initial quantity values.
- Return type:
- propagate() None#
Executes the propagation of the mission sequence through all defined legs and impulsive burns.
This version uses a SCENARIO-GLOBAL state vector (union of all components across all legs) as the single source of truth for initial conditions and continuity across segments.
Key behaviors: - For each Leg/Finite Burn:
build leg->global mapping
extract leg IC from global vector
apply any pending impulsive burn to BOTH (global and leg IC) consistently
propagate
update global vector from terminal propagated state
- For each Impulsive Burn:
snapshot segment outputs
store pending dv to be applied at next leg
(global velocity is updated at the next leg, using that leg’s velocity key)
- reinitialize_from_deviation_global(deviation_global: list, *, commit: bool = True, relative_to_ref: bool = True) None#
- reinitialize_scenario_state_def(new_state_def: StateDefinition, *, refill_from_models: bool = True, update_models: bool = True, update_states_n: bool = False) None#
Reinitialize the scenario state definition and propagate changes throughout the mission sequence. This method performs a comprehensive state schema migration that: 1. Snapshots the current global state vector 2. Installs the new state definition and associated index mapping 3. Projects values from the old global state to the new one, preserving overlapping keys 4. Optionally refills new state variables from the first model that provides them 5. Updates all StateArray models with new values from the global state vector 6. Reinitializes ImpulsiveBurn models from their corresponding DV parameter blocks 7. Resets cached state tracking variables (STM, state vector, state size) :param new_state_def: The new state definition schema to install. Contains all state variable specifications. :type new_state_def:
StateDefinition:param refill_from_models: If True, fill new state variables (not present in the old state) from initial modelstate values. The first model in the mission sequence that contains a matching state variable will seed the value. Default is True.
- Parameters:
update_models (
bool, optional) – If True, propagate the updated global state values back into all StateArray model instances in the mission sequence. Default is True.update_states_n (
bool, optional) – If True, update the states_n tracking array with the new state dimensions for each rebuilt model. Default is False.
- Return type:
Notes
State key matching is based on (name, size, spice_id, frame_name, occurrence_index)
Only overlapping state variables are copied from old to new; missing variables either remain zero-initialized or are filled from models if refill_from_models is True.
ImpulsiveBurn models are matched to DV parameters by their burn occurrence order.
The method assumes DV parameters follow the naming convention “dv_man”, “dv_man1”, etc.
Cached fields (_state_vector_old, _state_size_old, _STM_old, _delta_v) are reset.
- update_stm(new_list: list)#
Updates the State Transition Matrix (STM) to match a new state vector layout.
This method constructs a new STM matrix based on the provided new_list layout, copying matching blocks and cross-partials from the previous STM if available. It also handles injection of maneuver delta-v blocks if specified.
- Parameters:
new_list (
list) – The new state vector layout, where each element is a tuple containing (name, size, …, body, …). The layout determines the block structure of the STM.np.ndarray – The updated STM matrix, sized according to the new state vector layout.
- Raises:
ValueError – If the previous STM matrix (STM_old) is not square.
Notes
If no previous STM exists or mapping is disabled, returns an identity matrix, with optional delta-v maneuver injection.
Matching blocks are copied by (name, spice_id) and occurrence index.
Cross-partials between matching blocks are also copied.
Delta-v maneuver blocks (“dv_man”, “dv_man1”, “dv_man2”) are injected into corresponding velocity blocks if self.delta_v is set.
- property delta_v: ArrayWUnits | None#
The last computed impulsive delta-v, if applicable.
- property et_old: EpochArray#
The last computed epoch in the mission sequence.
- property full_state_vector#
Retrieve the full state vector array for the scenario.
- property map_STM_to_t0: bool#
Indicates whether the STM should be mapped to the initial time.
Trueif the STM is mapped to the initial state, otherwiseFalse.
- property mission_sequence: MissionSequence#
The mission sequence associated with this scenario.
- property propagated_state_array#
State array corresponding to the propagated solution.
- Base:
Propagator
- Type:
np.ndarray
- property propagator: Propagator#
The propagator responsible for trajectory calculations.
- property state_vector_old: StateArray#
The last computed state vector.
- property total_epochsTDB#
Returns the total number of epochs for the TDB (presumably “Trajectory Data Base” or similar) by retrieving the epoch value from the primary “position” data source.
- property total_parameters: list[ArrayWUnits]#
The total set of propagated parameters.
- property total_position#
Returns the primary position value by invoking the _pick_primary method with “position” as the argument.
- property total_velocity#
Calculate and return the total velocity from the primary velocity attribute.