topsim.core.instrument.Instrument
- class topsim.core.instrument.Instrument(env, config, planner, scheduler)[source]
The Simulation class is a wrapper for all Actors; we start the simulation through the simulation class, which in turn invokes the initial Actors and monitoring, and provides the conditions for checking if the simulation has finished.
- Parameters:
env (
simpy.Environmentobject) – The discrete-event simulation environment. This is the way TOpSim simulation maintains state across the different actors, and interfaces with the simpy processes.config (
Configinstance) – Config object wrapper for the configuration file.planner (
Plannerinstance) – The Planner Actor for the current simulationscheduler (
Schedulerinstance) – The Scheduler Actor for the current simulation
Notes
This class is a Python
ABC, meaning it requires user addition to implement the metaclasses.Recommended decisions to make in the run() method include:
Check observation and instrument are ready given current instrument demand:
>>> # Assuming self.capacity is a user-defined attribute >>> if(observation.is_ready(self.env.now, self.capacity))
Communicate with Scheduler to determine if the Buffer and Cluster have capacity to run a new Observation (Ingest and Storage conditions):
>>> self.scheduler.check_ingest_capacity( >>> observation, pipelines, max_ingest >>>)
If above conditions are reached, begin observations and request ingest allocation via scheduler:
>>> self.begin_observation(observation) >>> self.env.process(self.scheduler.allocate_ingest( >>> observation, pipelines, planner))
Note:
allocate_ingest()generates a timeout on the SimPy discrete-event queue, which is why we call env.process.Finalise an Observation and initiate the ‘clean-up’.
>>> observation.status = self.finish_observation(observation)
See also
Methods
__init__(env, config, planner, scheduler)run()The starting point for the Instrument actor; this will make decisions per timestep and then once these decisions have been resolved, yield a timeout to indicate a single timestep has passed for the Telescope.
to_df()Produce a pandas.DataFrame of output for the Simulation
Monitor.