COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
telescopeCompass.py
1 
37 from shesha.init.geom_init import tel_init
38 import numpy as np
39 
40 
41 class TelescopeCompass(object):
42  """ Telescope handler for compass simulation
43 
44  Attributes:
45  _tel : (sutraWrap.Tel) : Sutra telescope instance
46 
47  _context : (carmaContext) : CarmaContext instance
48 
49  _config : (config module) : Parameters configuration structure module
50  """
51 
52  def __init__(self, context, config):
53  """ Initialize an AtmosCompass component for atmosphere related supervision
54 
55  Args:
56  context : (carmaContext) : CarmaContext instance
57 
58  config : (config module) : Parameters configuration structure module
59  """
60  self._context_context = context
61  self._config_config = config # Parameters configuration coming from supervisor init
62  if self._config_config.p_atmos is not None:
63  r0 = self._config_config.p_atmos.r0
64  else:
65  raise ValueError('A r0 value through a Param_atmos is required.')
66 
67  if self._config_config.p_loop is not None:
68  ittime = self._config_config.p_loop.ittime
69  else:
70  raise ValueError(
71  'An ittime (iteration time in seconds) value through a Param_loop is required.'
72  )
73  print("->telescope init")
74  self._tel_tel = tel_init(self._context_context, self._config_config.p_geom, self._config_config.p_tel, r0,
75  ittime, self._config_config.p_wfss)
76 
77  def set_input_phase(self, phase : np.ndarray):
78  """ Set a circular buffer of phase screens to be raytraced as a
79  Telescope layer. Buffer size shall be (mpup size, mpup size, N).
80 
81  Args:
82  phase : (np.ndarray[ndim=3, dtype=float]) : circular buffer of phase screen
83  """
84  if (phase.ndim != 3 or phase.shape[0] != self._config_config.p_geom._mpupil.shape[0] or phase.shape[1] != self._config_config.p_geom._mpupil.shape[1]):
85  print("Input shall be a np.ndarray of dimensions (mpup size, mpup size, N)")
86  return
87  self._tel_tel.set_input_phase(phase)
88 
89  def update_input_phase(self):
90  """ Update the index of the current phase screen in the circular buffer, so it passes to the next one
91  """
92  self._tel_tel.update_input_phase()
93 
94  def reset_input_phase(self):
95  """ Reset circular buffer d_input_phase
96  """
97  self._tel_tel.reset_input_phase()
98 
99  def get_input_phase(self):
100  """ Return the circular buffer of telescope phase screens
101 
102  Returns:
103  phase : (np.ndarray[ndim=3, dtype=float]) : circular buffer of phase screen
104  """
105  if (self._tel_tel.d_input_phase is None):
106  return None
107  return np.array(self._tel_tel.d_input_phase)
108 
109  def get_input_phase_counter(self):
110  """ Return the index of the current phase screen to be raytraced inside the telescope circular buffer
111 
112  Returns:
113  counter : (int) : Phase screen index in the circular buffer
114  """
115  return self._tel_tel.input_phase_counter
def set_input_phase(self, np.ndarray phase)
Set a circular buffer of phase screens to be raytraced as a Telescope layer.
def __init__(self, context, config)
Initialize an AtmosCompass component for atmosphere related supervision.
def get_input_phase(self)
Return the circular buffer of telescope phase screens.
def update_input_phase(self)
Update the index of the current phase screen in the circular buffer, so it passes to the next one.
def reset_input_phase(self)
Reset circular buffer d_input_phase.
def get_input_phase_counter(self)
Return the index of the current phase screen to be raytraced inside the telescope circular buffer.
Initialization of the system geometry and of the Telescope object.
Definition: geom_init.py:1