COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
shesha.supervisor.genericSupervisor.GenericSupervisor Class Reference

This class defines generic methods and behavior of a supervisor It is not intended to be instantiated as it is : prefer to build a supervisor class inheriting from it. More...

Inheritance diagram for shesha.supervisor.genericSupervisor.GenericSupervisor:
Collaboration diagram for shesha.supervisor.genericSupervisor.GenericSupervisor:

Public Member Functions

def __init__ (self, config)
 
def get_config (self)
 Returns the configuration in use, in a supervisor specific format ? More...
 
int get_frame_counter (self)
 Return the current iteration number of the loop. More...
 
None force_context (self)
 Active all the GPU devices specified in the parameters file. More...
 
None next (self, *bool move_atmos=True, int nControl=0, Iterable[int] tar_trace=None, Iterable[int] wfs_trace=None, bool do_control=True, bool apply_control=True, bool compute_tar_psf=True)
 Iterates the AO loop, with optional parameters. More...
 
def loop (self, int number_of_iter, *int monitoring_freq=100, bool compute_tar_psf=True, **kwargs)
 Perform the AO loop for <number_of_iter> iterations. More...
 
def reset (self)
 Reset the simulation to return to its original state. More...
 

Public Attributes

 context
 
 config
 
 telescope
 
 atmos
 
 target
 
 wfs
 
 dms
 
 rtc
 
 is_init
 
 iter
 Init the a supervisor. More...
 

Detailed Description

This class defines generic methods and behavior of a supervisor It is not intended to be instantiated as it is : prefer to build a supervisor class inheriting from it.

This approach allows to build multiple supervisors with various components and less effort

Definition at line 53 of file genericSupervisor.py.

Constructor & Destructor Documentation

◆ __init__()

def shesha.supervisor.genericSupervisor.GenericSupervisor.__init__ (   self,
  config 
)

Definition at line 107 of file genericSupervisor.py.

107  def force_context(self) -> None:
108  """ Active all the GPU devices specified in the parameters file
109  """
110  if self.context is not None:
111  current_device = self.context.active_device
112  for device in range(len(self.config.p_loop.devices)):
113  self.context.set_active_device_force(device)
114  self.context.set_active_device(current_device)
115 
116  def _init_components(self) -> None:
117  """ Initialize all the components
118  """
119  if (self.config.p_loop.devices.size > 1):

Member Function Documentation

◆ force_context()

None shesha.supervisor.genericSupervisor.GenericSupervisor.force_context (   self)

Active all the GPU devices specified in the parameters file.

Definition at line 138 of file genericSupervisor.py.

138  self._init_wfs()
139  if self.config.p_controllers is not None or self.config.p_centroiders is not None:
140  self._init_rtc()
141 
142  self.is_init = True
143 
144  @abstractmethod
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_config()

def shesha.supervisor.genericSupervisor.GenericSupervisor.get_config (   self)

Returns the configuration in use, in a supervisor specific format ?

Return
config (config module) : Current supervisor configuration

Reimplemented in shesha.supervisor.canapassSupervisor.CanapassSupervisor.

Definition at line 125 of file genericSupervisor.py.

125  self.force_context()
126 
127  if self.config.p_tel is None or self.config.p_geom is None:

◆ get_frame_counter()

int shesha.supervisor.genericSupervisor.GenericSupervisor.get_frame_counter (   self)

Return the current iteration number of the loop.

Return
framecounter (int) : Number of iteration already performed

Definition at line 133 of file genericSupervisor.py.

133  if self.config.p_dms is not None:
134  self._init_dms()
135  if self.config.p_targets is not None:

◆ loop()

def shesha.supervisor.genericSupervisor.GenericSupervisor.loop (   self,
int  number_of_iter,
*int   monitoring_freq = 100,
bool   compute_tar_psf = True,
**  kwargs 
)

Perform the AO loop for <number_of_iter> iterations.

Parameters
number_of_iter (int) : Number of iteration that will be done
monitoring_freq (int, optional) : Monitoring frequency [frames]. Default is 100
compute_tar_psf (bool, optional) : If True (default), computes the PSF at each iteration Else, only computes it each <monitoring_freq> frames

Definition at line 316 of file genericSupervisor.py.

Here is the call graph for this function:

◆ next()

None shesha.supervisor.genericSupervisor.GenericSupervisor.next (   self,
*bool   move_atmos = True,
int   nControl = 0,
Iterable[int]   tar_trace = None,
Iterable[int]   wfs_trace = None,
bool   do_control = True,
bool   apply_control = True,
bool   compute_tar_psf = True 
)

Iterates the AO loop, with optional parameters.

Parameters
move_atmos (bool), optional: move the atmosphere for this iteration. Default is True
nControl (int, optional): Controller number to use. Default is 0 (single control configuration)
tar_trace (List, optional): list of targets to trace. None is equivalent to all (default)
wfs_trace (List, optional): list of WFS to trace. None is equivalent to all (default)
do_control (bool, optional) : Performs RTC operations if True (Default)
apply_control (bool): (optional) if True (default), apply control on DMs
compute_tar_psf (bool, optional) : If True (default), computes the PSF at the end of the iteration

Reimplemented in shesha.supervisor.compassSupervisor.CompassSupervisor.

Definition at line 240 of file genericSupervisor.py.

240  self.iter += 1
241 
242  def _print_strehl(self, monitoring_freq: int, iters_time: float, total_iters: int,
243  *, tar_index: int=0):
244  """ Print the Strehl ratio SE and LE from a target on the terminal, the estimated remaining time and framerate
245 
246  Parameters:
247  monitoring_freq : (int) : Number of frames between two prints
248 
249  iters_time : (float) : time elapsed between two prints
250 
251  total_iters : (int) : Total number of iterations
252 
253  tar_index : (int, optional) : Index of the target. Default is 0
254  """
255  framerate = monitoring_freq / iters_time
256  strehl = self.target.get_strehl(tar_index)
257  etr = (total_iters - self.iter) / framerate
258  print("%d \t %.3f \t %.3f\t %.1f \t %.1f" % (self.iter + 1, strehl[0], strehl[1],
259  etr, framerate))
260 
261  def loop(self, number_of_iter: int, *, monitoring_freq: int = 100, compute_tar_psf: bool = True,
262  **kwargs):
263  """ Perform the AO loop for <number_of_iter> iterations
264 
265  Parameters :
266  number_of_iter: (int) : Number of iteration that will be done
267 
268  monitoring_freq: (int, optional) : Monitoring frequency [frames]. Default is 100
269 
270  compute_tar_psf : (bool, optional) : If True (default), computes the PSF at each iteration
271  Else, only computes it each <monitoring_freq> frames
272  """
273  if not compute_tar_psf:
274  print("WARNING: Target PSF will be computed (& accumulated) only during monitoring"
275  )
276 
277  print("----------------------------------------------------")
278  print("iter# | S.E. SR | L.E. SR | ETR (s) | Framerate (Hz)")
279  print("----------------------------------------------------")
280  # self.next(**kwargs)
281  t0 = time.time()
282  t1 = time.time()
283  if number_of_iter == -1: # Infinite loop
284  while (True):
Here is the caller graph for this function:

◆ reset()

def shesha.supervisor.genericSupervisor.GenericSupervisor.reset (   self)

Reset the simulation to return to its original state.

Definition at line 352 of file genericSupervisor.py.

Member Data Documentation

◆ atmos

shesha.supervisor.genericSupervisor.GenericSupervisor.atmos

(AtmosComponent) : An AtmosComponent instance

Definition at line 111 of file genericSupervisor.py.

◆ config

shesha.supervisor.genericSupervisor.GenericSupervisor.config

(config) : Parameters structure

Definition at line 109 of file genericSupervisor.py.

◆ context

shesha.supervisor.genericSupervisor.GenericSupervisor.context

(CarmaContext) : a CarmaContext instance

Definition at line 108 of file genericSupervisor.py.

◆ dms

shesha.supervisor.genericSupervisor.GenericSupervisor.dms

(DmComponent) : A DmComponent instance

Definition at line 114 of file genericSupervisor.py.

◆ is_init

shesha.supervisor.genericSupervisor.GenericSupervisor.is_init

(bool) : Flag equals to True if the supervisor has already been initialized

Definition at line 116 of file genericSupervisor.py.

◆ iter

shesha.supervisor.genericSupervisor.GenericSupervisor.iter

Init the a supervisor.

(int) : Frame counter

Parameters
config (config module) : Configuration module

Definition at line 117 of file genericSupervisor.py.

◆ rtc

shesha.supervisor.genericSupervisor.GenericSupervisor.rtc

(RtcComponent) : A Rtc component instance

Definition at line 115 of file genericSupervisor.py.

◆ target

shesha.supervisor.genericSupervisor.GenericSupervisor.target

(targetComponent) : A TargetComponent instance

Definition at line 112 of file genericSupervisor.py.

◆ telescope

shesha.supervisor.genericSupervisor.GenericSupervisor.telescope

(TelescopeComponent) : a TelescopeComponent instance

Definition at line 110 of file genericSupervisor.py.

◆ wfs

shesha.supervisor.genericSupervisor.GenericSupervisor.wfs

(WfsComponent) : A WfsComponent instance

Definition at line 113 of file genericSupervisor.py.


The documentation for this class was generated from the following file:
set_active_device
#define set_active_device(new_device, silent)
Definition: carma_context.h:97
set_active_device_force
#define set_active_device_force(new_device, silent)
Definition: carma_context.h:99