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

This class implements generic supervisor to handle compass simulation. More...

Inheritance diagram for shesha.supervisor.compassSupervisor.CompassSupervisor:
Collaboration diagram for shesha.supervisor.compassSupervisor.CompassSupervisor:

Public Member Functions

def __init__ (self, config, bool cacao=False)
 
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 record_ao_circular_buffer (self, int cb_count, np.ndarray projection_matrix, int sub_sample=1, int controller_index=0, int tar_index=0, bool see_atmos=True, str cube_data_type=None, str cube_data_file_path="", int ncpa=0, np.ndarray ncpa_wfs=None, np.ndarray ref_slopes=None, bool ditch_strehl=True)
 Used to record a synchronized circular buffer AO loop data. More...
 
- Public Member Functions inherited from shesha.supervisor.genericSupervisor.GenericSupervisor
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...
 
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

 cacao
 Instantiates a CompassSupervisor object. More...
 
 basis
 
 calibration
 
 tel
 
 atmos
 
 dms
 
 target
 
 wfs
 
 rtc
 
- Public Attributes inherited from shesha.supervisor.genericSupervisor.GenericSupervisor
 context
 
 config
 
 telescope
 
 atmos
 
 target
 
 wfs
 
 dms
 
 rtc
 
 is_init
 
 iter
 Init the a supervisor. More...
 

Detailed Description

This class implements generic supervisor to handle compass simulation.

Definition at line 57 of file compassSupervisor.py.

Constructor & Destructor Documentation

◆ __init__()

def shesha.supervisor.compassSupervisor.CompassSupervisor.__init__ (   self,
  config,
bool  cacao = False 
)

Definition at line 119 of file compassSupervisor.py.

119  raise ValueError("Configuration not loaded or Telescope not initilaized")
120 
121  def _init_wfs(self):
122  """Initialize the wfs component of the supervisor as a WfsCompass
123  """
124  if self.tel is not None:
125  self.wfs = WfsCompass(self.context, self.config, self.tel)
126  else:
127  raise ValueError("Configuration not loaded or Telescope not initilaized")
128 
129  def _init_rtc(self):

Member Function Documentation

◆ next()

None shesha.supervisor.compassSupervisor.CompassSupervisor.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.

   Overload the GenericSupervisor next() method to handle the GEO controller
   specific raytrace order operations
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 from shesha.supervisor.genericSupervisor.GenericSupervisor.

Definition at line 201 of file compassSupervisor.py.

201  def record_ao_circular_buffer(
202  self, cb_count: int, projection_matrix : np.ndarray, sub_sample: int = 1, controller_index: int = 0,
203  tar_index: int = 0, see_atmos: bool = True, cube_data_type: str = None,
204  cube_data_file_path: str = "", ncpa: int = 0, ncpa_wfs: np.ndarray = None,
205  ref_slopes: np.ndarray = None, ditch_strehl: bool = True):
206  """ Used to record a synchronized circular buffer AO loop data.
207 
208  Parameters:
209  cb_count: (int) : the number of iterations to record.
210 
211  projection_matrix : (np.ndarray) : projection matrix on modal basis to compute residual coefficients
212 
213  sub_sample: (int) : sub sampling of the data (default=1, I.e no subsampling)
214 
215  controller_index: (int) :
216 
217  tar_index: (int) : target number
218 
219  see_atmos: (int) : used for the next function to enable or not the Atmos
220 
221  cube_data_type: (int) : if specified ("tarPhase" or "psfse") returns the target phase or short exposure PSF data cube in the output variable
222 
223  cube_data_file_path: (int) : if specified it will also save the target phase cube data (full path on the server)
224 
225  ncpa: (int) : !!experimental!!!: Used only in the context of PYRWFS + NCPA compensation on the fly (with optical gain)
226  defines how many iters the NCPA refslopes are updates with the proper optical gain. Ex: if NCPA=10 refslopes will be updates every 10 iters.
227 
228  ncpa_wfs: (int) : the ncpa phase as seen from the wfs array with dims = size of Mpupil
229 
230  ref_slopes: (int) : the reference slopes to use.
231 
232  ditch_strehl: (int) : resets the long exposure SR computation at the beginning of the Circular buffer (default= True)
233 
234  Return:
235  slopes: (int) : the slopes CB
236 
237  volts: (int) : the volts applied to the DM(s) CB
238 
239  ai: (int) : the modal coefficient of the residual phase projected on the currently used modal Basis
240 
241  psf_le: (int) : Long exposure PSF over the <cb_count> iterations (I.e SR is reset at the begining of the CB if ditch_strehl=True)
242 
243  sthrel_se_list: (int) : The SR short exposure evolution during CB recording
244 
Here is the caller graph for this function:

◆ record_ao_circular_buffer()

def shesha.supervisor.compassSupervisor.CompassSupervisor.record_ao_circular_buffer (   self,
int  cb_count,
np.ndarray  projection_matrix,
int   sub_sample = 1,
int   controller_index = 0,
int   tar_index = 0,
bool   see_atmos = True,
str   cube_data_type = None,
str   cube_data_file_path = "",
int   ncpa = 0,
np.ndarray   ncpa_wfs = None,
np.ndarray   ref_slopes = None,
bool   ditch_strehl = True 
)

Used to record a synchronized circular buffer AO loop data.

Parameters
cb_count (int) : the number of iterations to record.
projection_matrix (np.ndarray) : projection matrix on modal basis to compute residual coefficients
sub_sample (int) : sub sampling of the data (default=1, I.e no subsampling)
controller_index (int) :
tar_index (int) : target number
see_atmos (int) : used for the next function to enable or not the Atmos
cube_data_type (int) : if specified ("tarPhase" or "psfse") returns the target phase or short exposure PSF data cube in the output variable
cube_data_file_path (int) : if specified it will also save the target phase cube data (full path on the server)
ncpa (int) : !!experimental!!!: Used only in the context of PYRWFS + NCPA compensation on the fly (with optical gain) defines how many iters the NCPA refslopes are updates with the proper optical gain. Ex: if NCPA=10 refslopes will be updates every 10 iters.
ncpa_wfs (int) : the ncpa phase as seen from the wfs array with dims = size of Mpupil
ref_slopes (int) : the reference slopes to use.
ditch_strehl (int) : resets the long exposure SR computation at the beginning of the Circular buffer (default= True)
Return
slopes (int) : the slopes CB
volts (int) : the volts applied to the DM(s) CB
ai (int) : the modal coefficient of the residual phase projected on the currently used modal Basis
psf_le (int) : Long exposure PSF over the <cb_count> iterations (I.e SR is reset at the begining of the CB if ditch_strehl=True)
sthrel_se_list (int) : The SR short exposure evolution during CB recording
sthrel_le_list (int) : The SR long exposure evolution during CB recording
g_ncpa_list (int) : the gain applied to the NCPA (PYRWFS CASE) if NCPA is set to True
cube_data (int) : the tarPhase or psfse cube data (see cube_data_type)

Definition at line 290 of file compassSupervisor.py.

290  self.next()
291  for t in range(len(self.config.p_targets)):
292  self.target.comp_tar_image(t)
293 
294  srse, srle, _, _ = self.target.get_strehl(tar_index)
295  sthrel_se_list.append(srse)
296  sthrel_le_list.append(srle)
297  if (j % sub_sample == 0):
298  ai_vector = self.calibration.compute_modal_residuals(projection_matrix, selected_actus=self.basis.selected_actus)
299  if (ai_data is None):
300  ai_data = np.zeros((len(ai_vector), int(cb_count / sub_sample)))
301  ai_data[:, k] = ai_vector
302 
303  slopes_vector = self.rtc.get_slopes(controller_index)
304  if (slopes_data is None):
305  slopes_data = np.zeros((len(slopes_vector),
306  int(cb_count / sub_sample)))
307  slopes_data[:, k] = slopes_vector
308 
309  volts_vector = self.rtc.get_command(controller_index) # get_command or get_voltages ?
310  if (volts_data is None):
311  volts_data = np.zeros((len(volts_vector),
312  int(cb_count / sub_sample)))
313  volts_data[:, k] = volts_vector
314 
315  if (cube_data_type):
316  if (cube_data_type == "tarPhase"):
317  dataArray = self.target.get_tar_phase(tar_index, pupil=True)
318  elif (cube_data_type == "psfse"):
319  dataArray = self.target.get_tar_image(tar_index, expo_type="se")
320  else:
321  raise ValueError("unknown dataData" % cube_data_type)
322  if (cube_data is None):
323  cube_data = np.zeros((*dataArray.shape,
324  int(cb_count / sub_sample)))
325  cube_data[:, :, k] = dataArray
326  k += 1
327  if (cube_data_file_path != ""):
328  print("Saving tarPhase cube at: ", cube_data_file_path)
329  pfits.writeto(cube_data_file_path, cube_data, overwrite=True)
330 
331  psf_le = self.target.get_tar_image(tar_index, expo_type="le")
332  return slopes_data, volts_data, ai_data, psf_le, sthrel_se_list, sthrel_le_list, g_ncpa_list, cube_data
Here is the call graph for this function:

Member Data Documentation

◆ atmos

shesha.supervisor.compassSupervisor.CompassSupervisor.atmos

(AtmosComponent) : An AtmosComponent instance

Definition at line 142 of file compassSupervisor.py.

◆ basis

shesha.supervisor.compassSupervisor.CompassSupervisor.basis

Definition at line 122 of file compassSupervisor.py.

◆ cacao

shesha.supervisor.compassSupervisor.CompassSupervisor.cacao

Instantiates a CompassSupervisor object.

(bool) : CACAO features enabled in the RTC

Parameters
config (config module) : Configuration module
cacao (bool, optional) : If True, enables CACAO features in RTC (Default is False) /!\ Requires OCTOPUS to be installed

Definition at line 120 of file compassSupervisor.py.

◆ calibration

shesha.supervisor.compassSupervisor.CompassSupervisor.calibration

Definition at line 123 of file compassSupervisor.py.

◆ dms

shesha.supervisor.compassSupervisor.CompassSupervisor.dms

(DmComponent) : A DmComponent instance

Definition at line 149 of file compassSupervisor.py.

◆ rtc

shesha.supervisor.compassSupervisor.CompassSupervisor.rtc

(RtcComponent) : A Rtc component instance

Definition at line 177 of file compassSupervisor.py.

◆ target

shesha.supervisor.compassSupervisor.CompassSupervisor.target

(targetComponent) : A TargetComponent instance

Definition at line 157 of file compassSupervisor.py.

◆ tel

shesha.supervisor.compassSupervisor.CompassSupervisor.tel

Definition at line 135 of file compassSupervisor.py.

◆ wfs

shesha.supervisor.compassSupervisor.CompassSupervisor.wfs

(WfsComponent) : A WfsComponent instance

Definition at line 167 of file compassSupervisor.py.


The documentation for this class was generated from the following file: