COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
shesha.init.rtc_init Namespace Reference

Initialization of a Rtc object. More...

Functions

def rtc_init (carmaWrap_context context, Telescope tel, Sensors wfs, Dms dms, Atmos atmos, list p_wfss, conf.Param_tel p_tel, conf.Param_geom p_geom, conf.Param_atmos p_atmos, float ittime, p_centroiders=None, p_controllers=None, p_dms=None, do_refslp=False, brahma=False, cacao=False, tar=None, dataBase={}, use_DB=False)
 Initialize all the SutraRtc objects : centroiders and controllers. More...
 
Rtc rtc_standalone (carmaWrap_context context, int nwfs, list nvalid, int nactu, list centroider_type, list delay, list offset, list scale, bool brahma=False, bool fp16=False, bool cacao=False)
 TODO docstring. More...
 
def init_centroider (context, int nwfs, conf.Param_wfs p_wfs, conf.Param_centroider p_centroider, conf.Param_tel p_tel, conf.Param_atmos p_atmos, Sensors wfs, Rtc rtc)
 Initialize a centroider object in Rtc. More...
 
def comp_weights (conf.Param_centroider p_centroider, conf.Param_wfs p_wfs, int npix)
 Compute the weights used by centroider wcog and corr. More...
 
def init_controller (context, int i, conf.Param_controller p_controller, list p_wfss, conf.Param_geom p_geom, list p_dms, conf.Param_atmos p_atmos, float ittime, conf.Param_tel p_tel, Rtc rtc, Dms dms, Sensors wfs, Telescope tel, Atmos atmos, List[conf.Param_centroider] p_centroiders, do_refslp=False, dataBase={}, use_DB=False)
 Initialize the controller part of rtc. More...
 
def init_controller_geo (int i, Rtc rtc, Dms dms, conf.Param_geom p_geom, conf.Param_controller p_controller, list p_dms, roket=False)
 Initialize geometric controller. More...
 
def init_controller_ls (int i, conf.Param_controller p_controller, list p_wfss, conf.Param_geom p_geom, list p_dms, conf.Param_atmos p_atmos, float ittime, conf.Param_tel p_tel, Rtc rtc, Dms dms, Sensors wfs, Telescope tel, Atmos atmos, dict dataBase={}, bool use_DB=False)
 
def init_controller_cured (int i, Rtc rtc, conf.Param_controller p_controller, list p_dms, list p_wfss)
 
def init_controller_mv (int i, conf.Param_controller p_controller, list p_wfss, conf.Param_geom p_geom, list p_dms, conf.Param_atmos p_atmos, conf.Param_tel p_tel, Rtc rtc, Dms dms, Sensors wfs, Atmos atmos)
 Initialize the MV controller. More...
 
def init_controller_generic (int i, conf.Param_controller p_controller, list p_dms, Rtc rtc)
 Initialize the generic controller. More...
 

Detailed Description

Initialization of a Rtc object.

Author
COMPASS Team https://github.com/ANR-COMPASS
Version
5.0.0
Date
2020/05/18

This file is part of COMPASS https://anr-compass.github.io/compass/

Copyright (C) 2011-2019 COMPASS Team https://github.com/ANR-COMPASS All rights reserved. Distributed under GNU - LGPL

COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

COMPASS: End-to-end AO simulation tool using GPU acceleration The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.

The final product includes a software package for simulating all the critical subcomponents of AO, particularly in the context of the ELT and a real-time core based on several control approaches, with performances consistent with its integration into an instrument. Taking advantage of the specific hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to conduct large simulation campaigns called to the ELT.

The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and various systems configurations such as multi-conjugate AO.

COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with COMPASS. If not, see https://www.gnu.org/licenses/lgpl-3.0.txt.

Function Documentation

◆ comp_weights()

def shesha.init.rtc_init.comp_weights ( conf.Param_centroider  p_centroider,
conf.Param_wfs  p_wfs,
int  npix 
)

Compute the weights used by centroider wcog and corr.

:parameters: p_centroider (Param_centroider) : centroider settings p_wfs (Param_wfs) : wfs settings npix (int):

Definition at line 279 of file rtc_init.py.

279  """
280  if (p_centroider.type_fct == scons.CentroiderFctType.MODEL):
281 
282  if (p_wfs.gsalt > 0):
283  tmp = p_wfs._lgskern
284  tmp2 = utilities.makegaussian(tmp.shape[1],
285  npix * p_wfs._nrebin).astype(np.float32)
286  tmp3 = np.zeros((tmp.shape[1], tmp.shape[1], p_wfs._nvalid),
287  dtype=np.float32)
288 
289  for j in range(p_wfs._nvalid):
290  tmp3[:, :, j] = np.fft.ifft2(
291  np.fft.fft2(tmp[:, :, j]) * np.fft.fft2(tmp2.T)).real
292  tmp3[:, :, j] *= tmp3.shape[0] * tmp3.shape[1]
293  tmp3[:, :, j] = np.fft.fftshift(tmp3[:, :, j])
294 
295  offset = (p_wfs._Ntot - p_wfs._nrebin * p_wfs.npix) // 2
296  j = offset + p_wfs._nrebin * p_wfs.npix
297  tmp = np.zeros((j - offset + 1, j - offset + 1, tmp3.shape[2]),
298  dtype=np.float32)
299  tmp3 = np.cumsum(tmp3[offset:j, offset:j, :], axis=0)
300  tmp[1:, 1:, :] = np.cumsum(tmp3, axis=1)
301  tmp = np.diff(tmp[::p_wfs._nrebin, ::p_wfs._nrebin, :], axis=0)
302  tmp = np.diff(tmp, axis=1)
303 
304  p_centroider.weights = tmp
305  else:
306  p_centroider.type_fct = scons.CentroiderFctType.GAUSS
307  print("No LGS found, centroider weighting function becomes gaussian")
308 
309  if (p_centroider.type_fct == scons.CentroiderFctType.GAUSS):
310  if p_centroider.width is None:
311  p_centroider.width = npix
312  if (p_wfs.npix % 2 == 1):
313  p_centroider.weights = utilities.makegaussian(
314  p_wfs.npix, p_centroider.width, p_wfs.npix // 2,
315  p_wfs.npix // 2).astype(np.float32)
316  elif (p_centroider.type == scons.CentroiderType.CORR):
317  p_centroider.weights = utilities.makegaussian(
318  p_wfs.npix, p_centroider.width, p_wfs.npix // 2,
319  p_wfs.npix // 2).astype(np.float32)
320  else:
321  p_centroider.weights = utilities.makegaussian(
322  p_wfs.npix, p_centroider.width, p_wfs.npix // 2 - 0.5,
323  p_wfs.npix // 2 - 0.5).astype(np.float32)
324 
325 
Here is the caller graph for this function:

◆ init_centroider()

def shesha.init.rtc_init.init_centroider (   context,
int  nwfs,
conf.Param_wfs  p_wfs,
conf.Param_centroider  p_centroider,
conf.Param_tel  p_tel,
conf.Param_atmos  p_atmos,
Sensors  wfs,
Rtc  rtc 
)

Initialize a centroider object in Rtc.

:parameters: context (carmaWrap_context): context nwfs (int) : index of wfs p_wfs (Param_wfs): wfs settings p_centroider (Param_centroider) : centroider settings wfs (Sensors): Sensor object rtc (Rtc) : Rtc object

Definition at line 203 of file rtc_init.py.

203  wfs: (Sensors): Sensor object
204  rtc : (Rtc) : Rtc object
205  """
206  if (p_wfs.type == scons.WFSType.SH):
207  if (p_centroider.type != scons.CentroiderType.CORR):
208  s_offset = p_wfs.npix // 2. - 0.5
209  else:
210  if (p_centroider.type_fct == scons.CentroiderFctType.MODEL):
211  if (p_wfs.npix % 2 == 0):
212  s_offset = p_wfs.npix // 2 - 0.5
213  else:
214  s_offset = p_wfs.npix // 2
215  else:
216  s_offset = p_wfs.npix // 2 - 0.5
217  s_scale = p_wfs.pixsize
218 
219  elif (p_wfs.type == scons.WFSType.PYRHR or p_wfs.type == scons.WFSType.PYRLR):
220  s_offset = 0.
221  s_scale = (p_wfs.Lambda * 1e-6 / p_tel.diam) * \
222  p_wfs.pyr_ampl * CONST.RAD2ARCSEC
223 
224  rtc.add_centroider(context, p_wfs._nvalid, s_offset, s_scale, p_centroider.filter_TT,
225  context.active_device, p_centroider.type, wfs.d_wfs[nwfs])
226  rtc.d_centro[-1].load_validpos(p_wfs._validsubsx, p_wfs._validsubsy,
227  p_wfs._nvalid * p_wfs.nPupils)
228 
229  rtc.d_centro[-1].set_npix(p_wfs.npix)
230 
231  if (p_centroider.type != scons.CentroiderType.MASKEDPIX):
232  p_centroider._nslope = 2 * p_wfs._nvalid
233  else:
234  p_centroider._nslope = p_wfs._validsubsx.size
235 
236  if (p_centroider.type == scons.CentroiderType.PYR):
237  # FIXME SIGNATURE CHANGES
238  rtc.d_centro[nwfs].set_pyr_method(p_centroider.method)
239  rtc.d_centro[nwfs].set_pyr_thresh(p_centroider.thresh)
240 
241  elif (p_wfs.type == scons.WFSType.SH):
242  if (p_centroider.type == scons.CentroiderType.TCOG):
243  rtc.d_centro[nwfs].set_threshold(p_centroider.thresh)
244  elif (p_centroider.type == scons.CentroiderType.BPCOG):
245  rtc.d_centro[nwfs].set_nmax(p_centroider.nmax)
246  elif (p_centroider.type == scons.CentroiderType.WCOG or
247  p_centroider.type == scons.CentroiderType.CORR):
248  r0 = p_atmos.r0 * (p_wfs.Lambda / 0.5)**(6 / 5.)
249  seeing = CONST.RAD2ARCSEC * (p_wfs.Lambda * 1.e-6) / r0
250  npix = seeing // p_wfs.pixsize
251  comp_weights(p_centroider, p_wfs, npix)
252  if p_centroider.type == scons.CentroiderType.WCOG:
253  rtc.d_centro[nwfs].init_weights()
254  rtc.d_centro[nwfs].load_weights(p_centroider.weights,
255  p_centroider.weights.ndim)
256  else:
257  corrnorm = np.ones((2 * p_wfs.npix, 2 * p_wfs.npix), dtype=np.float32)
258  p_centroider.sizex = 3
259  p_centroider.sizey = 3
260  p_centroider.interpmat = rtc_util.create_interp_mat(
261  p_centroider.sizex, p_centroider.sizey).astype(np.float32)
262 
263  if (p_centroider.weights is None):
264  raise ValueError("p_centroider.weights is None")
265  rtc.d_centro[nwfs].init_corr(p_centroider.sizex, p_centroider.sizey,
266  p_centroider.interpmat)
267  rtc.d_centro[nwfs].load_corr(p_centroider.weights, corrnorm,
268  p_centroider.weights.ndim)
269 
270 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_controller()

def shesha.init.rtc_init.init_controller (   context,
int  i,
conf.Param_controller  p_controller,
list  p_wfss,
conf.Param_geom  p_geom,
list  p_dms,
conf.Param_atmos  p_atmos,
float  ittime,
conf.Param_tel  p_tel,
Rtc  rtc,
Dms  dms,
Sensors  wfs,
Telescope  tel,
Atmos  atmos,
List[conf.Param_centroider]  p_centroiders,
  do_refslp = False,
  dataBase = {},
  use_DB = False 
)

Initialize the controller part of rtc.

:parameters: context (carmaWrap_context): context i (int) : controller index p_controller (Param_controller) : controller settings p_wfss (list of Param_wfs) : wfs settings p_geom (Param_geom) : geom settings p_dms (list of Param_dms) : dms settings p_atmos (Param_atmos) : atmos settings ittime (float) : iteration time [s] p_tel (Param_tel) : telescope settings rtc (Rtc) : Rtc objet dms (Dms) : Dms object wfs (Sensors) : Sensors object tel (Telescope) : Telescope object atmos (Atmos) : Atmos object p_centroiders (list of Param_centroider): centroiders settings

Definition at line 346 of file rtc_init.py.

346  dms: (Dms) : Dms object
347  wfs: (Sensors) : Sensors object
348  tel: (Telescope) : Telescope object
349  atmos: (Atmos) : Atmos object
350  p_centroiders: (list of Param_centroider): centroiders settings
351  """
352  if (p_controller.type != scons.ControllerType.GEO):
353  nwfs = p_controller.nwfs
354  if (len(p_wfss) == 1):
355  nwfs = p_controller.nwfs
356  # TODO fixing a bug ... still not understood
357  nvalid = sum([p_wfss[k]._nvalid for k in nwfs])
358  p_controller.set_nvalid(int(np.sum([p_wfss[k]._nvalid for k in nwfs])))
359  tmp = 0
360  for c in p_centroiders:
361  if (c.nwfs in nwfs):
362  tmp = tmp + c._nslope
363  p_controller.set_nslope(int(tmp))
364  else:
365  nslope = np.sum([c._nslope for c in p_centroiders])
366  p_controller.set_nslope(int(nslope))
367 
368  # parameter for add_controller(_geo)
369  ndms = p_controller.ndm.tolist()
370  nactu = np.sum([p_dms[j]._ntotact for j in ndms])
371  p_controller.set_nactu(int(nactu))
372 
373  alt = np.array([p_dms[j].alt for j in p_controller.ndm], dtype=np.float32)
374 
375  list_dmseen = [p_dms[j].type for j in p_controller.ndm]
376  if (p_controller.type == scons.ControllerType.GEO):
377  Nphi = np.where(p_geom._spupil)[0].size
378  else:
379  Nphi = -1
380 
381  #nslope = np.sum([c._nslope for c in p_centroiders])
382  #p_controller.set_nslope(int(nslope))
383 
384  #TODO : find a proper way to set the number of slope (other than 2 times nvalid)
385  rtc.add_controller(context, p_controller.nvalid, p_controller.nslope,
386  p_controller.nactu, p_controller.delay, context.active_device,
387  p_controller.type, dms, p_controller.ndm, p_controller.ndm.size,
388  p_controller.nwfs, p_controller.nwfs.size, Nphi, False,
389  p_controller.nstates)
390  print("CONTROLLER ADDED")
391  if (p_wfss is not None and do_refslp):
392  rtc.do_centroids_ref(i)
393 
394  if (p_controller.type == scons.ControllerType.GEO):
395  init_controller_geo(i, rtc, dms, p_geom, p_controller, p_dms)
396 
397  if (p_controller.type == scons.ControllerType.LS):
398  init_controller_ls(i, p_controller, p_wfss, p_geom, p_dms, p_atmos, ittime,
399  p_tel, rtc, dms, wfs, tel, atmos, dataBase=dataBase,
400  use_DB=use_DB)
401 
402  if (p_controller.type == scons.ControllerType.CURED):
403  init_controller_cured(i, rtc, p_controller, p_dms, p_wfss)
404 
405  if (p_controller.type == scons.ControllerType.MV):
406  init_controller_mv(i, p_controller, p_wfss, p_geom, p_dms, p_atmos, p_tel, rtc,
407  dms, wfs, atmos)
408 
409  elif (p_controller.type == scons.ControllerType.GENERIC):
410  init_controller_generic(i, p_controller, p_dms, rtc)
411  try:
412  p_controller._imat = imats.imat_geom(wfs, dms, p_wfss, p_dms, p_controller,
413  meth=0)
414  except:
415  print("p_controller._imat not set")
416 
417 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_controller_cured()

def shesha.init.rtc_init.init_controller_cured ( int  i,
Rtc  rtc,
conf.Param_controller  p_controller,
list  p_dms,
list  p_wfss 
)

Definition at line 525 of file rtc_init.py.

525  p_wfss: (list of Param_wfs) : wfs settings
526  """
527 
528  print("initializing cured controller")
529  if (scons.DmType.TT in [p_dms[j].type for j in range(len(p_dms))]):
530  tt_flag = True
531  else:
532  tt_flag = False
533  rtc.d_control[i].init_cured(p_wfss[0].nxsub, p_wfss[0]._isvalid,
534  p_controller.cured_ndivs, tt_flag)
535  rtc.d_control[i].set_gain(p_controller.gain)
536 
537 
Here is the caller graph for this function:

◆ init_controller_generic()

def shesha.init.rtc_init.init_controller_generic ( int  i,
conf.Param_controller  p_controller,
list  p_dms,
Rtc  rtc 
)

Initialize the generic controller.

:parameters: i (int): controller index p_controller (Param_controller): controller settings p_dms (list of Param_dm): dms settings rtc (Rtc): Rtc object

Definition at line 579 of file rtc_init.py.

579  rtc: (Rtc): Rtc object
580  """
581  size = sum([p_dms[j]._ntotact for j in range(len(p_dms))])
582  decayFactor = np.ones(size, dtype=np.float32)
583  mgain = np.ones(size, dtype=np.float32) * p_controller.gain
584  matE = np.identity(size, dtype=np.float32)
585  cmat = np.zeros((size, p_controller.nslope), dtype=np.float32)
586 
587  rtc.d_control[i].set_decayFactor(decayFactor)
588  rtc.d_control[i].set_modal_gains(mgain)
589  rtc.d_control[i].set_cmat(cmat)
590  rtc.d_control[i].set_matE(matE)
Here is the caller graph for this function:

◆ init_controller_geo()

def shesha.init.rtc_init.init_controller_geo ( int  i,
Rtc  rtc,
Dms  dms,
conf.Param_geom  p_geom,
conf.Param_controller  p_controller,
list  p_dms,
  roket = False 
)

Initialize geometric controller.

:parameters: i (int): controller index rtc (Rtc): rtc object dms (Dms): Dms object p_geom (Param_geom): geometry settings p_controller (Param_controller): controller settings p_dms (list of Param_dms): dms settings roket (bool): Flag to initialize ROKET

Definition at line 430 of file rtc_init.py.

430  roket: (bool): Flag to initialize ROKET
431  """
432  indx_pup = np.where(p_geom._spupil.flatten('F'))[0].astype(np.int32)
433  indx_mpup = np.where(p_geom._mpupil.flatten('F'))[0].astype(np.int32)
434  cpt = 0
435  indx_dm = np.zeros((p_controller.ndm.size * indx_pup.size), dtype=np.int32)
436  for dmn in range(p_controller.ndm.size):
437  tmp_s = (p_geom._ipupil.shape[0] - (p_dms[dmn]._n2 - p_dms[dmn]._n1 + 1)) // 2
438  tmp_e0 = p_geom._ipupil.shape[0] - tmp_s
439  tmp_e1 = p_geom._ipupil.shape[1] - tmp_s
440  pup_dm = p_geom._ipupil[tmp_s:tmp_e0, tmp_s:tmp_e1]
441  indx_dm[cpt:cpt + np.where(pup_dm)[0].size] = np.where(pup_dm.flatten('F'))[0]
442  cpt += np.where(pup_dm)[0].size
443  # convert unitpervolt list to a np.ndarray
444  unitpervolt = np.array([p_dms[j].unitpervolt
445  for j in range(len(p_dms))], dtype=np.float32)
446 
447  rtc.d_control[i].init_proj_sparse(dms, indx_dm, unitpervolt, indx_pup, indx_mpup,
448  roket=roket)
449 
450 
451 def init_controller_ls(i: int, p_controller: conf.Param_controller, p_wfss: list,
452  p_geom: conf.Param_geom, p_dms: list, p_atmos: conf.Param_atmos,
453  ittime: float, p_tel: conf.Param_tel, rtc: Rtc, dms: Dms,
454  wfs: Sensors, tel: Telescope, atmos: Atmos, dataBase: dict = {},
455  use_DB: bool = False):
456  """
457  Initialize the least square controller
458  :parameters:
459  i : (int) : controller index
460  p_controller: (Param_controller) : controller settings
461  p_wfss: (list of Param_wfs) : wfs settings
462  p_geom: (Param_geom) : geom settings
463  p_dms: (list of Param_dms) : dms settings
464  p_atmos: (Param_atmos) : atmos settings
465  ittime: (float) : iteration time [s]
466  p_tel: (Param_tel) : telescope settings
467  rtc: (Rtc) : Rtc objet
Here is the caller graph for this function:

◆ init_controller_ls()

def shesha.init.rtc_init.init_controller_ls ( int  i,
conf.Param_controller  p_controller,
list  p_wfss,
conf.Param_geom  p_geom,
list  p_dms,
conf.Param_atmos  p_atmos,
float  ittime,
conf.Param_tel  p_tel,
Rtc  rtc,
Dms  dms,
Sensors  wfs,
Telescope  tel,
Atmos  atmos,
dict   dataBase = {},
bool   use_DB = False 
)

Definition at line 468 of file rtc_init.py.

468  dms: (Dms) : Dms object
469  wfs: (Sensors) : Sensors object
470  tel: (Telescope) : Telescope object
471  atmos: (Atmos) : Atmos object
472  """
473  M2V = None
474  if p_controller.do_kl_imat:
475  IF = basis.compute_IFsparse(dms, p_dms, p_geom).T
476  M2V, _ = basis.compute_btt(IF[:, :-2], IF[:, -2:].toarray())
477  print("Filtering ", p_controller.nModesFilt, " modes based on mode ordering")
478  M2V = M2V[:, list(range(M2V.shape[1] - 2 - p_controller.nModesFilt)) + [-2, -1]]
479 
480  if len(p_controller.klpush) == 1: # Scalar allowed, now we expand
481  p_controller.klpush = p_controller.klpush[0] * np.ones(M2V.shape[1])
482  imats.imat_init(i, rtc, dms, p_dms, wfs, p_wfss, p_tel, p_controller, M2V,
483  dataBase=dataBase, use_DB=use_DB)
484 
485  if p_controller.modopti:
486  print("Initializing Modal Optimization : ")
487  p_controller.nrec = int(2**np.ceil(np.log2(p_controller.nrec)))
488  if p_controller.nmodes is None:
489  p_controller.nmodes = sum([p_dms[j]._ntotact for j in range(len(p_dms))])
490 
491  IF = basis.compute_IFsparse(dms, p_dms, p_geom).T
492  M2V, _ = basis.compute_btt(IF[:, :-2], IF[:, -2:].toarray())
493  M2V = M2V[:, list(range(p_controller.nmodes - 2)) + [-2, -1]]
494 
495  rtc.d_control[i].init_modalOpti(p_controller.nmodes, p_controller.nrec, M2V,
496  p_controller.gmin, p_controller.gmax,
497  p_controller.ngain, 1. / ittime)
498  ol_slopes = modopti.open_loopSlp(tel, atmos, wfs, rtc, p_controller.nrec, i,
499  p_wfss)
500  rtc.d_control[i].loadopen_loopSlp(ol_slopes)
501  rtc.d_control[i].modalControlOptimization()
502  else:
503  cmats.cmat_init(i, rtc, p_controller, p_wfss, p_atmos, p_tel, p_dms,
504  nmodes=p_controller.nmodes)
505 
506  rtc.d_control[i].set_gain(p_controller.gain)
507  mgain = np.ones(
508  sum([p_dms[j]._ntotact for j in range(len(p_dms))]), dtype=np.float32)
509  cc = 0
510  for ndm in p_dms:
511  mgain[cc:cc + ndm._ntotact] = ndm.gain
512  cc += ndm._ntotact
513  rtc.d_control[i].set_modal_gains(mgain)
514 
515 
516 def init_controller_cured(i: int, rtc: Rtc, p_controller: conf.Param_controller,
517  p_dms: list, p_wfss: list):
518  """
519  Initialize the CURED controller
520  :parameters:
521  i : (int) : controller index
522  rtc: (Rtc) : Rtc objet
523  p_controller: (Param_controller) : controller settings
524  p_dms: (list of Param_dms) : dms settings
Here is the caller graph for this function:

◆ init_controller_mv()

def shesha.init.rtc_init.init_controller_mv ( int  i,
conf.Param_controller  p_controller,
list  p_wfss,
conf.Param_geom  p_geom,
list  p_dms,
conf.Param_atmos  p_atmos,
conf.Param_tel  p_tel,
Rtc  rtc,
Dms  dms,
Sensors  wfs,
Atmos  atmos 
)

Initialize the MV controller.

:parameters: i (int) : controller index p_controller (Param_controller) : controller settings p_wfss (list of Param_wfs) : wfs settings p_geom (Param_geom) : geom settings p_dms (list of Param_dms) : dms settings p_atmos (Param_atmos) : atmos settings p_tel (Param_tel) : telescope settings rtc (Rtc) : Rtc objet dms (Dms) : Dms object wfs (Sensors) : Sensors object atmos (Atmos) : Atmos object

Definition at line 554 of file rtc_init.py.

554  dms: (Dms) : Dms object
555  wfs: (Sensors) : Sensors object
556  atmos: (Atmos) : Atmos object
557  """
558  p_controller._imat = imats.imat_geom(wfs, dms, p_wfss, p_dms, p_controller)
559  # imat_init(i,rtc,p_rtc,dms,wfs,p_wfss,p_tel,clean=1,simul_name=simul_name)
560  rtc.d_control[i].set_imat(p_controller._imat)
561  rtc.d_control[i].set_gain(p_controller.gain)
562  size = sum([p_dms[j]._ntotact for j in range(len(p_dms))])
563  mgain = np.ones(size, dtype=np.float32)
564  rtc.d_control[i].set_modal_gains(mgain)
565  tomo.do_tomo_matrices(i, rtc, p_wfss, dms, atmos, wfs, p_controller, p_geom, p_dms,
566  p_tel, p_atmos)
567  cmats.cmat_init(i, rtc, p_controller, p_wfss, p_atmos, p_tel, p_dms)
568 
569 
Here is the caller graph for this function:

◆ rtc_init()

def shesha.init.rtc_init.rtc_init ( carmaWrap_context  context,
Telescope  tel,
Sensors  wfs,
Dms  dms,
Atmos  atmos,
list  p_wfss,
conf.Param_tel  p_tel,
conf.Param_geom  p_geom,
conf.Param_atmos  p_atmos,
float  ittime,
  p_centroiders = None,
  p_controllers = None,
  p_dms = None,
  do_refslp = False,
  brahma = False,
  cacao = False,
  tar = None,
  dataBase = {},
  use_DB = False 
)

Initialize all the SutraRtc objects : centroiders and controllers.

:parameters: context (carmaWrap_context): context tel (Telescope) : Telescope object wfs (Sensors) : Sensors object dms (Dms) : Dms object atmos (Atmos) : Atmos object p_wfss (list of Param_wfs) : wfs settings p_tel (Param_tel) : telescope settings p_geom (Param_geom) : geom settings p_atmos (Param_atmos) : atmos settings ittime (float) : iteration time [s] p_centroiders (list of Param_centroider): (optional) centroiders settings p_controllers (list of Param_controller): (optional) controllers settings p_dms (list of Param_dms) : (optional) dms settings do_refslp (bool): (optional) do ref slopes flag, default=False brahma (bool) : (optional) brahma flag cacao (bool) : (optional) cacao flag tar (Target) : (optional) dataBase (dict): (optional) dict containig paths to files to load use_DB (bool): use dataBase flag :return: Rtc (Rtc) : Rtc object

Definition at line 79 of file rtc_init.py.

79  dataBase: (dict): (optional) dict containig paths to files to load
80  use_DB: (bool): use dataBase flag
81  :return:
82  Rtc : (Rtc) : Rtc object
83  """
84  # initialisation var
85  # ________________________________________________
86  if brahma:
87  rtc = Rtc_brahma(context, wfs, tar, "rtc_brahma")
88  elif cacao:
89  rtc = Rtc_cacao_FFF("compass_calPix", "compass_loopData")
90  else:
91  rtc = Rtc()
92 
93  if p_wfss is None:
94  return rtc
95 
96  if p_centroiders:
97  ncentro = len(p_centroiders)
98  else:
99  ncentro = 0
100 
101  if p_controllers:
102  ncontrol = len(p_controllers)
103  else:
104  ncontrol = 0
105 
106  if p_centroiders is not None:
107  for i in range(ncentro):
108  nwfs = p_centroiders[i].nwfs
109  init_centroider(context, nwfs, p_wfss[nwfs], p_centroiders[i], p_tel,
110  p_atmos, wfs, rtc)
111 
112  if p_controllers is not None:
113  if (p_wfss is not None and p_dms is not None):
114  for i in range(ncontrol):
115  if not "dm" in dataBase:
116  imat = imats.imat_geom(wfs, dms, p_wfss, p_dms, p_controllers[i],
117  meth=0)
118  else:
119  imat = None
120 
121  if p_dms[0].type == scons.DmType.PZT:
122  dm_init.correct_dm(context, dms, p_dms, p_controllers[i], p_geom,
123  imat, dataBase=dataBase, use_DB=use_DB)
124 
125  init_controller(context, i, p_controllers[i], p_wfss, p_geom, p_dms,
126  p_atmos, ittime, p_tel, rtc, dms, wfs, tel, atmos,
127  p_centroiders, do_refslp, dataBase=dataBase,
128  use_DB=use_DB)
129 
130  # add a geometric controller for processing error breakdown
131  roket_flag = True in [w.roket for w in p_wfss]
132  if (roket_flag):
133  p_controller = p_controllers[0]
134  Nphi = np.where(p_geom._spupil)[0].size
135 
136  list_dmseen = [p_dms[j].type for j in p_controller.ndm]
137  nactu = np.sum([p_dms[j]._ntotact for j in p_controller.ndm])
138 
139  rtc.add_controller(context, p_controller.nvalid, p_controller.nslope,
140  p_controller.nactu, p_controller.delay,
141  context.active_device, scons.ControllerType.GEO, dms,
142  p_controller.ndm, p_controller.ndm.size,
143  p_controller.nwfs, p_controller.nwfs.size, Nphi, True)
144 
145  # rtc.add_controller_geo(context, nactu, Nphi, p_controller.delay,
146  # context.active_device, p_controller.type, dms,
147  # list_dmseen, p_controller.ndm.size, True)
148 
149  # list_dmseen,alt,p_controller.ndm.size
150  init_controller_geo(ncontrol, rtc, dms, p_geom, p_controller, p_dms,
151  roket=True)
152 
153  return rtc
154 
155 
156 # MODBY J
Here is the call graph for this function:

◆ rtc_standalone()

Rtc shesha.init.rtc_init.rtc_standalone ( carmaWrap_context  context,
int  nwfs,
list  nvalid,
int  nactu,
list  centroider_type,
list  delay,
list  offset,
list  scale,
bool   brahma = False,
bool   fp16 = False,
bool   cacao = False 
)

TODO docstring.

Definition at line 160 of file rtc_init.py.

160  """
161  TODO docstring
162  """
163  print("start rtc_standalone")
164  if brahma:
165  rtc = Rtc_brahma(context, None, None, "rtc_brahma")
166  elif cacao:
167  if fp16:
168  from shesha.sutra_wrap import Rtc_cacao_FHF
169  rtc = Rtc_cacao_FHF("compass_calPix", "compass_loopData")
170  else:
171  rtc = Rtc_cacao_FFF("compass_calPix", "compass_loopData")
172  else:
173  if fp16:
174  from shesha.sutra_wrap import Rtc_FHF
175  rtc = Rtc_FHF()
176  else:
177  rtc = Rtc()
178  for k in range(nwfs):
179  # print(context, nvalid[k], offset[k], scale[k], False,
180  # context.active_device, centroider_type[k])
181  rtc.add_centroider(context, nvalid[k], offset[k], scale[k], False,
182  context.active_device, centroider_type[k])
183 
184  nslopes = sum([c.nslopes for c in rtc.d_centro])
185  rtc.add_controller(context, sum(nvalid), nslopes, nactu, delay[k],
186  context.active_device, "generic", idx_centro=np.arange(nwfs),
187  ncentro=nwfs)
188 
189  print("rtc_standalone set")
190  return rtc
191 
192 
shesha.sutra_wrap
Definition: sutra_wrap.py:1