resource_usage
Module for simulating resource usage of an observing schedule.
- class ska_sdp_resource_model.simulate.resource_usage.ResourceUsageSimulator[source]
Bases:
objectClass for simulating resource usage.
- __init__()[source]
Initialises the ResourceUsageSimulator with empty event and resource logs.
- initialise_logs()[source]
Initialises the event and resource logs.
- initialise_environment()[source]
Initialises the simulation environment using the SimPy library.
- initialise_resources(hardware_config)[source]
Initialises the telescope and ScienceDataProcessor resources.
- run_simulation(observations, hardware_config)[source]
Simulates resource usage of the SDP.
- add_events_from_batch(batch)[source]
Add events from a batch to the simulation event log.
- Parameters:
batch (list) – List of SchedulingBlock or SchedulingBlockInstance objects.
- event_log_df()[source]
Return the event log for the simulation as a DataFrame.
Events are sorted by simulation start time and the duration of each event is calculated in seconds, hours, and days. An SB_type column is added to store the type of scheduling block for each event.
- Returns:
event_log_df (pd.DataFrame) – A DataFrame containing the event log.
- get_failed_blocks(scheduling_block_instances)[source]
Return a list of failed scheduling blocks.
- Parameters:
scheduling_block_instances (list) – List of SchedulingBlockInstance objects.
- Returns:
list – List of failed scheduling blocks with their latest status.
- initialise_environment()[source]
Initialise the simulation environment.
This method sets up the simulation environment using the SimPy library. It creates an instance of the simpy.Environment class and assigns it to the ‘env’ attribute of the object.
- Returns:
None
- initialise_logs()[source]
Initialise lists for containing logging.
- initialise_resources(hardware_config)[source]
Initialise the resources required for the simulation.
This method sets up the telescope resource and the ScienceDataProcessor (SDP) using the provided hardware configuration.
- Parameters:
hardware_config (dict) – A dictionary containing the hardware configuration for the Science Data Processor.
- run_simulation(observations, hardware_config)[source]
Simulate resource usage of the SDP.
- Parameters:
observations (list) – Sequence of scheduling blocks with pipeline configurations to use as input to simulation.
hardware_config (dict) – Hardware configuration.
- Returns:
dict – A dictionary containing the resource usage and event logs as DataFrames.