COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
shesha.supervisor.canapassSupervisor.CanapassSupervisor Class Reference
Inheritance diagram for shesha.supervisor.canapassSupervisor.CanapassSupervisor:
Collaboration diagram for shesha.supervisor.canapassSupervisor.CanapassSupervisor:

Public Member Functions

None __init__ (self, str config_file=None, bool cacao=True)
 
def get_config (self)
 Returns the configuration in use, in a supervisor specific format. More...
 
def get_config_fab (self)
 
None load_config (self, str config_file)
 Load the configuration for the compass supervisor. More...
 
- Public Member Functions inherited from shesha.supervisor.compassSupervisor.CompassSupervisor
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)
 
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...
 

Additional Inherited Members

- Public Attributes inherited from shesha.supervisor.compassSupervisor.CompassSupervisor
 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

Definition at line 75 of file canapassSupervisor.py.

Constructor & Destructor Documentation

◆ __init__()

None shesha.supervisor.canapassSupervisor.CanapassSupervisor.__init__ (   self,
str   config_file = None,
bool   cacao = True 
)

Definition at line 77 of file canapassSupervisor.py.

77  def __init__(self, config_file: str = None, cacao: bool = True) -> None:
78  CompassSupervisor.__init__(self, config_file=config_file, cacao=cacao)
79 

Member Function Documentation

◆ get_config()

def shesha.supervisor.canapassSupervisor.CanapassSupervisor.get_config (   self)

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

Reimplemented from shesha.supervisor.genericSupervisor.GenericSupervisor.

Definition at line 81 of file canapassSupervisor.py.

81  """ Returns the configuration in use, in a supervisor specific format """
82  return CompassSupervisor.get_config(self)
83 

◆ get_config_fab()

def shesha.supervisor.canapassSupervisor.CanapassSupervisor.get_config_fab (   self)

Definition at line 84 of file canapassSupervisor.py.

84  def get_config_fab(self):
85  aodict = OrderedDict()
86  dataDict = {}
87  if (root is None):
88  root = self
89 
90  if (root.config.p_tel is not None):
91  aodict.update({"teldiam": root.config.p_tel.diam})
92  aodict.update({"telobs": root.config.p_tel.cobs})
93  aodict.update({"pixsize": root.config.p_geom._pixsize})
94  # TURBU
95  aodict.update({"r0": root.config.p_atmos.r0})
96  aodict.update({"Fe": 1 / root.config.p_loop.ittime})
97  aodict.update({"nbTargets": len(root.config.p_targets)})
98  else:
99  aodict.update({"nbTargets": 1})
100 
101  # WFS
102  aodict.update({"nbWfs": len(root.config.p_wfss)})
103  aodict.update({"nbCam": aodict["nbWfs"]})
104  aodict.update({"nbOffaxis": 0})
105  aodict.update({"nbNgsWFS": 1})
106  aodict.update({"nbLgsWFS": 0})
107  aodict.update({"nbFigSensor": 0})
108  aodict.update({"nbSkyWfs": aodict["nbWfs"]})
109  aodict.update({"nbOffNgs": 0})
110 
111  # DMS
112  aodict.update({"nbDms": len(root.config.p_dms)})
113  aodict.update({"Nactu": root.rtc.d_control[0].nactu})
114  # List of things
115  aodict.update({"list_NgsOffAxis": []})
116  aodict.update({"list_Fig": []})
117  aodict.update({"list_Cam": [0]})
118  aodict.update({"list_SkyWfs": [0]})
119  aodict.update({"list_ITS": []})
120  aodict.update({"list_Woofer": []})
121  aodict.update({"list_Tweeter": []})
122  aodict.update({"list_Steering": []})
123 
124  listOfNstatesPerController = []
125  listOfcontrolLawTypePerController = []
126  for control in self.config.p_controllers:
127  listOfNstatesPerController.append(control.nstates)
128  listOfcontrolLawTypePerController.append(control.type)
129  aodict.update({"list_nstatesPerController": listOfNstatesPerController})
130  aodict.update({"list_controllerType": listOfcontrolLawTypePerController})
131 
132  # fct of Nb of wfss
133  NslopesList = []
134  NsubapList = []
135  listWfsType = []
136  listCentroType = []
137 
138  pyrModulationList = []
139  pyr_npts = []
140  pyr_pupsep = []
141  pixsize = []
142  xPosList = []
143  yPosList = []
144  fstopsize = []
145  fstoptype = []
146  npixPerSub = []
147  nxsubList = []
148  nysubList = []
149  lambdaList = []
150  dms_seen = []
151  colTmpList = []
152  noise = []
153  #new_hduwfsl = pfits.HDUList()
154  #new_hduwfsSubapXY = pfits.HDUList()
155  for i in range(aodict["nbWfs"]):
156  #new_hduwfsl.append(pfits.ImageHDU(root.config.p_wfss[i]._isvalid)) # Valid subap array
157  #new_hduwfsl[i].header["DATATYPE"] = "valid_wfs%d" % i
158  dataDict["wfsValid_" + str(i)] = root.config.p_wfss[i]._isvalid
159 
160  xytab = np.zeros((2, root.config.p_wfss[i]._validsubsx.shape[0]))
161  xytab[0, :] = root.config.p_wfss[i]._validsubsx
162  xytab[1, :] = root.config.p_wfss[i]._validsubsy
163  dataDict["wfsValidXY_" + str(i)] = xytab
164 
165  #new_hduwfsSubapXY.append(pfits.ImageHDU(xytab)) # Valid subap array inXx Y on the detector
166  #new_hduwfsSubapXY[i].header["DATATYPE"] = "validXY_wfs%d" % i
167  pixsize.append(root.config.p_wfss[i].pixsize)
168  """
169  if (root.config.p_centroiders[i].type == "maskedpix"):
170  factor = 4
171  else:
172  factor = 2
173  NslopesList.append(
174  root.config.p_wfss[i]._nvalid * factor) # slopes per wfs
175  """
176  listCentroType.append(
177  root.config.p_centroiders[i].
178  type) # assumes that there is the same number of centroiders and wfs
179  NsubapList.append(root.config.p_wfss[i]._nvalid) # subap per wfs
180  listWfsType.append(root.config.p_wfss[i].type)
181  xPosList.append(root.config.p_wfss[i].xpos)
182  yPosList.append(root.config.p_wfss[i].ypos)
183  fstopsize.append(root.config.p_wfss[i].fssize)
184  fstoptype.append(root.config.p_wfss[i].fstop)
185  nxsubList.append(root.config.p_wfss[i].nxsub)
186  nysubList.append(root.config.p_wfss[i].nxsub)
187  lambdaList.append(root.config.p_wfss[i].Lambda)
188  if (root.config.p_wfss[i].dms_seen is not None):
189  dms_seen.append(list(root.config.p_wfss[i].dms_seen))
190  noise.append(root.config.p_wfss[i].noise)
191 
192  if (root.config.p_centroiders[i].type == CentroiderType.MASKEDPIX):
193  NslopesList.append(root.config.p_wfss[i]._nvalid * 4) # slopes per wfs
194  else:
195  NslopesList.append(root.config.p_wfss[i]._nvalid * 2) # slopes per wfs
196 
197  if (root.config.p_wfss[i].type == "pyrhr"):
198  pyrModulationList.append(root.config.p_wfss[i].pyr_ampl)
199  pyr_npts.append(root.config.p_wfss[i].pyr_npts)
200  pyr_pupsep.append(root.config.p_wfss[i].pyr_pup_sep)
201  npixPerSub.append(1)
202  else:
203  pyrModulationList.append(0)
204  pyr_npts.append(0)
205  pyr_pupsep.append(0)
206  npixPerSub.append(root.config.p_wfss[i].npix)
207  """
208  confname = filepath.split("/")[-1].split('.conf')[0]
209  print(filepath.split(".conf")[0] + '_wfsConfig.fits')
210  new_hduwfsl.writeto(
211  filepath.split(".conf")[0] + '_wfsConfig.fits', overwrite=True)
212  new_hduwfsSubapXY.writeto(
213  filepath.split(".conf")[0] + '_wfsValidXYConfig.fits', overwrite=True)
214  """
215  if (len(dms_seen) != 0):
216  aodict.update({"listWFS_dms_seen": dms_seen})
217 
218  aodict.update({"listWFS_NslopesList": NslopesList})
219  aodict.update({"listWFS_NsubapList": NsubapList})
220  aodict.update({"listWFS_CentroType": listCentroType})
221  aodict.update({"listWFS_WfsType": listWfsType})
222  aodict.update({"listWFS_pixarc": pixsize})
223  aodict.update({"listWFS_pyrModRadius": pyrModulationList})
224  aodict.update({"listWFS_pyrModNPts": pyr_npts})
225  aodict.update({"listWFS_pyrPupSep": pyr_pupsep})
226  aodict.update({"listWFS_fstopsize": fstopsize})
227  aodict.update({"listWFS_fstoptype": fstoptype})
228  aodict.update({"listWFS_NsubX": nxsubList})
229  aodict.update({"listWFS_NsubY": nysubList})
230  aodict.update({"listWFS_Nsub": nysubList})
231  aodict.update({"listWFS_NpixPerSub": npixPerSub})
232  aodict.update({"listWFS_Lambda": lambdaList})
233  if (len(noise) != 0):
234  aodict.update({"listWFS_noise": noise})
235 
236  listDmsType = []
237  NactuX = []
238  Nactu = []
239  unitPerVolt = []
240  push4imat = []
241  coupling = []
242  push4iMatArcSec = []
243  #new_hdudmsl = pfits.HDUList()
244 
245  for j in range(aodict["nbDms"]):
246  listDmsType.append(root.config.p_dms[j].type)
247  NactuX.append(
248  root.config.p_dms[j].nact) # nb of actuators across the diameter !!
249  Nactu.append(root.config.p_dms[j]._ntotact) # nb of actuators in total
250  unitPerVolt.append(root.config.p_dms[j].unitpervolt)
251  push4imat.append(root.config.p_dms[j].push4imat)
252  coupling.append(root.config.p_dms[j].coupling)
253  tmp = []
254  if (root.config.p_dms[j]._i1 is
255  not None): # Simu Case where i1 j1 is known (simulated)
256  if (root.config.p_dms[j].type != 'tt'):
257  tmpdata = np.zeros((4, len(root.config.p_dms[j]._i1)))
258  tmpdata[0, :] = root.config.p_dms[j]._j1
259  tmpdata[1, :] = root.config.p_dms[j]._i1
260  tmpdata[2, :] = root.config.p_dms[j]._xpos
261  tmpdata[3, :] = root.config.p_dms[j]._ypos
262  else:
263  tmpdata = np.zeros((4, 2))
264 
265  dataDict["dmData" + str(j)] = tmpdata
266  """
267  new_hdudmsl.append(pfits.ImageHDU(tmpdata)) # Valid subap array
268  new_hdudmsl[j].header["DATATYPE"] = "valid_dm%d" % j
269  """
270  #for k in range(aodict["nbWfs"]):
271  # tmp.append(root.computeDMrange(j, k))
272 
273  push4iMatArcSec.append(tmp)
274 
275  # new_hdudmsl.writeto(filepath.split(".conf")[0] + '_dmsConfig.fits', overwrite=True)
276  if (len(push4iMatArcSec) != 0):
277  aodict.update({"listDMS_push4iMat": push4imat})
278  aodict.update({"listDMS_unitPerVolt": unitPerVolt})
279  aodict.update({"listDMS_Nxactu": NactuX})
280  aodict.update({"listDMS_Nyactu": NactuX})
281  aodict.update({"listDMS_Nactu": Nactu})
282 
283  aodict.update({"listDMS_type": listDmsType})
284  aodict.update({"listDMS_coupling": coupling})
285 
286  if (root.config.p_targets is not None): # simu case
287  listTargetsLambda = []
288  listTargetsXpos = []
289  listTargetsYpos = []
290  listTargetsDmsSeen = []
291  listTargetsMag = []
292  listTARGETS_pixsize = []
293  for k in range(aodict["nbTargets"]):
294  listTargetsLambda.append(root.config.p_targets[k].Lambda)
295  listTargetsXpos.append(root.config.p_targets[k].xpos)
296  listTargetsYpos.append(root.config.p_targets[k].ypos)
297  listTargetsMag.append(root.config.p_targets[k].mag)
298  listTargetsDmsSeen.append(list(root.config.p_targets[k].dms_seen))
299  PSFPixsize = (root.config.p_targets[k].Lambda * 1e-6) / (
300  root.config.p_geom._pixsize *
301  root.config.p_geom.get_ipupil().shape[0]) * 206265.
302  listTARGETS_pixsize.append(PSFPixsize)
303 
304  aodict.update({"listTARGETS_Lambda": listTargetsLambda})
305  aodict.update({"listTARGETS_Xpos": listTargetsXpos})
306  aodict.update({"listTARGETS_Ypos": listTargetsYpos})
307  aodict.update({"listTARGETS_Mag": listTargetsMag})
308  aodict.update({"listTARGETS_DmsSeen": listTargetsDmsSeen})
309  aodict.update({"listTARGETS_pixsize": listTARGETS_pixsize})
310 
311  listDmsType = []
312  Nslopes = sum(NslopesList)
313  Nsubap = sum(NsubapList)
314  aodict.update({"Nslopes": Nslopes})
315  aodict.update({"Nsubap": Nsubap})
316  return aodict, dataDict
317 

◆ load_config()

None shesha.supervisor.canapassSupervisor.CanapassSupervisor.load_config (   self,
str  config_file 
)

Load the configuration for the compass supervisor.

Definition at line 320 of file canapassSupervisor.py.

320  """
321  CompassSupervisor.load_config(self, config_file)
322  print("switching to a generic controller")
323  self.config.p_controllers[0].type = scons.ControllerType.GENERIC
324 
325 
Here is the caller graph for this function:

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