shesha.ao¶
-
shesha.ao.basis.command_on_Btt(rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_dms: list, p_geom: shesha.config.PGEOM.Param_geom, nfilt: int)¶ Compute a command matrix in Btt modal basis (see error breakdown) and set it on the sutra_rtc. It computes by itself the volts to Btt matrix.
- Parameters
rtc: (Rtc) : rtc object
dms: (Dms): dms object
p_dms: (list of Param_dm): dms settings
p_geom: (Param_geom): geometry settings
nfilt: (int): number of modes to filter
-
shesha.ao.basis.command_on_KL(rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_controller: shesha.config.PCONTROLLER.Param_controller, p_dms: List[shesha.config.PDMS.Param_dm], p_geom: shesha.config.PGEOM.Param_geom, p_atmos: shesha.config.PATMOS.Param_atmos, p_tel: shesha.config.PTEL.Param_tel, nfilt: int)¶ Compute a command matrix in KL modal basis and set it on the sutra_rtc. It computes by itself the volts to KL matrix.
- Parameters
rtc: (Rtc) : rtc object
dms: (Dms): dms object
p_dms: (list of Param_dm): dms settings
p_geom: (Param_geom): geometry settings
p_atmos : (Param_atmos) : atmos parameters
p_tel : (Param_tel) : telescope parameters
nfilt: (int): number of modes to filter
-
shesha.ao.basis.compute_IFsparse(g_dm: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_dms: list, p_geom: shesha.config.PGEOM.Param_geom)¶ - Compute the influence functions of all DMs as a sparse matrix :
push on each actuator
get the corresponding dm shape
apply pupil mask and store in a column
- Parameters
g_dm: (Dms) : Dms object
p_dms: (Param_dms) : dms settings
p_geom: (Param_geom) : geom settings
- Returns
IFbasis = (csr_matrix) : DM IF basis
-
shesha.ao.basis.compute_KL2V(p_controller: shesha.config.PCONTROLLER.Param_controller, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_dms: list, p_geom: shesha.config.PGEOM.Param_geom, p_atmos: shesha.config.PATMOS.Param_atmos, p_tel: shesha.config.PTEL.Param_tel)¶ Compute the Karhunen-Loeve to Volt matrix (transfer matrix between the KL space and volt space for a pzt dm)
- Parameters
p_controller: (Param_controller) : p_controller settings
dms : (shesha_dms) : Dms object
p_dms: (list of Param_dm) : dms settings
p_geom : (Param_geom) : geometry parameters
p_atmos : (Param_atmos) : atmos parameters
p_tel : (Param_tel) : telescope parameters
- Returns
KL2V : (np.array(np.float32,dim=2)) : KL to Volt matrix
-
shesha.ao.basis.compute_btt(IFpzt, IFtt, influ_petal=None, return_delta=False)¶ Returns Btt to Volts and Volts to Btt matrices
- Parameters
IFpzt : (csr_matrix) : influence function matrix of pzt DM, sparse and arrange as (Npts in pup x nactus)
IFtt : (np.ndarray(ndim=2,dtype=np.float32)) : Influence function matrix of the TT mirror arrange as (Npts in pup x 2)
- influ_petal(np.ndarray)Influence function matrix of M4 petals.
Default is None, if set, the Btt produced is also orthogonal to petal modes, then only driven by petal DM
return_delta : (bool, optional) : If True, returns delta instead of P. Default is False
- Returns
Btt : (np.ndarray(ndim=2,dtype=np.float32)) : Btt to Volts matrix
P : (np.ndarray(ndim=2,dtype=np.float32)) : Volts to Btt matrix
-
shesha.ao.basis.compute_cmat_with_Btt(rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, Btt: numpy.ndarray, nfilt: int)¶ Compute a command matrix on the Btt basis and load it in the GPU
- Parameters
rtc: (Rtc): rtc object
Btt: (np.ndarray[ndim=2, dtype=np.float32]) : volts to Btt matrix
nfilt: (int): number of modes to filter
-
shesha.ao.basis.compute_cmat_with_KL(rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, KL2V: numpy.ndarray, nfilt: int)¶ Compute a command matrix on the KL basis and load it in the GPU
- Parameters
rtc: (Rtc): rtc object
KL2V: (np.ndarray[ndim=2, dtype=np.float32]) : volts to KL matrix
nfilt: (int): number of modes to filter
-
shesha.ao.basis.compute_dm_basis(g_dm, p_dm: shesha.config.PDMS.Param_dm, p_geom: shesha.config.PGEOM.Param_geom)¶ - Compute a the DM basis as a sparse matrix :
push on each actuator
get the corresponding dm shape
apply pupil mask and store in a column
- Parameters
g_dm: (Dm) : Dm object
p_dm: (Param_dm) : dm settings
p_geom: (Param_geom) : geom settings
- Returns
IFbasis = (csr_matrix) : DM IF basis
-
shesha.ao.basis.compute_fourier(nActu: int, pitch: float, actu_x_pos: numpy.ndarray, actu_y_pos: numpy.ndarray, periodic='n')¶ - Values you are looking for are:
config.p_dm0.nact config.p_dm0._pitch config.p_dm0._i1 config.p_dm0._j1
-
shesha.ao.cmats.Btt_for_cmat(rtc, dms, p_dms, p_geom)¶ Compute a command matrix in Btt modal basis (see error breakdown) and set it on the sutra_rtc. It computes by itself the volts to Btt matrix.
- Parameters
rtc: (Rtc) : rtc object
dms: (Dms): dms object
p_dms: (list of Param_dm): dms settings
p_geom: (Param_geom): geometry settings
-
shesha.ao.cmats.cmat_init(ncontrol: int, rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_controller: shesha.config.PCONTROLLER.Param_controller, p_wfss: List[shesha.config.PWFS.Param_wfs], p_atmos: shesha.config.PATMOS.Param_atmos, p_tel: shesha.config.PTEL.Param_tel, p_dms: List[shesha.config.PDMS.Param_dm], nmodes: int = 0) → None¶ Compute the command matrix on the GPU
- Parameters
ncontrol: (int) :
rtc: (Rtc) :
p_controller: (Param_controller) : controller settings
p_wfss: (list of Param_wfs) : wfs settings
p_atmos: (Param_atmos) : atmos settings
p_tel : (Param_tel) : telescope settings
p_dms: (list of Param_dm) : dms settings
M2V : (np.ndarray[ndim=2, dtype=np.float32]): (optional) KL to volts matrix (for KL cmat)
nmodes: (int) : (optional) number of kl modes
-
shesha.ao.cmats.generic_imat_inversion(M2V: numpy.ndarray, modalIMat: numpy.ndarray, modeSelect: Optional[numpy.ndarray] = None, modeGains: Optional[numpy.ndarray] = None) → numpy.ndarray¶ Generic numpy modal interaction matrix inversion function
- Parameters
M2V: (nActu x nModes) : modal basis matrix
modalIMat: (nSlopes x nModes) : modal interaction matrix
modeSelect: (nModes, dtype=bool): (Optional): mode selection, mode at False is filtered
modeGains: (nModes, dtype=bool): (Optional): modal gains to apply. These are gain in the reconstruction sens, ie they are applied multiplicatively on the command matrix
-
shesha.ao.cmats.get_cmat(D, nfilt, Btt=None, rtc=None, svd=None)¶ Compute a command matrix from an interaction matrix ‘D’
- usage:
get_cmat(D,nfilt) get_cmat(D,nfilt,Btt=BTT,rtc=RTC) get_cmat(D,nfilt,svd=SVD)
- Parameters
D: (np.ndarray[ndim=2, dtype=np.float32]): interaction matrix
nfilt: (int): number of element to filter
Btt: (np.ndarray[ndim=2, dtype=np.float32]): Btt modal basis
rtc: (Rtc) :
svd: (tuple of np.ndarray[ndim=1, dtype=np.float32): svd of D.T*D (obtained from np.linalg.svd)
-
shesha.ao.imats.get_metaD(sup, TS_xpos=None, TS_ypos=None, ind_TS=- 1, save_metaD=False, nControl=0)¶ Create an interaction matrix for the current simulation given TS position :parameters:
sim : : current COMPASS simulation TS_xpos : np.ndarray : TS position (x axis) TS_ypos : np.ndarray : TS position (y axis)
- Returns
metaD : np.ndarray :interaction matrix
-
shesha.ao.imats.imat_geom(wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_wfss: List[shesha.config.PWFS.Param_wfs], p_dms: List[shesha.config.PDMS.Param_dm], p_controller: shesha.config.PCONTROLLER.Param_controller, meth: int = 0) → numpy.ndarray¶ Compute the interaction matrix with a geometric method
- Parameters
wfs: (Sensors) : Sensors object
dms: (Dms) : Dms object
p_wfss: (list of Param_wfs) : wfs settings
p_dms: (list of Param_dm) : dms settings
p_controller: (Param_controller) : controller settings
meth: (int) : (optional) method type (0 or 1)
-
shesha.ao.imats.imat_geom_ts(wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_wfss: shesha.config.PWFS.Param_wfs, ind_TS: int, p_dms: List[shesha.config.PDMS.Param_dm], ind_DMs: List[int], meth: int = 0) → numpy.ndarray¶ Compute the interaction matrix with a geometric method for a single truth sensor
- Parameters
wfs: (Sensors) : Sensors object
dms: (Dms) : Dms object
p_wfss: (list of Param_wfs) : wfs settings
ind_TS: (int) : index of the truth sensor in the wfs settings list
p_dms: (list of Param_dm) : dms settings
ind_DMs: (list of int) : indices of used DMs
p_controller: (Param_controller) : controller settings
meth: (int) : (optional) method type (0 or 1)
-
shesha.ao.imats.imat_geom_ts_multiple_direction(wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_wfss: List[shesha.config.PWFS.Param_wfs], p_dms: List[shesha.config.PDMS.Param_dm], p_geom: shesha.config.PGEOM.Param_geom, ind_TS: int, ind_dmseen: List, p_tel: shesha.config.PTEL.Param_tel, x, y, meth: int = 0) → numpy.ndarray¶ Compute the interaction matrix with a geometric method for multiple truth sensors (with different direction)
- Parameters
wfs: (Sensors) : Sensors object
dms: (Dms) : Dms object
p_wfss: (list of Param_wfs) : wfs settings
ind_TS: (int) : index of the truth sensor in the wfs settings list
p_dms: (list of Param_dm) : dms settings
ind_DMs: (list of int) : indices of used DMs
p_controller: (Param_controller) : controller settings
meth: (int) : (optional) method type (0 or 1)
-
shesha.ao.imats.imat_init(ncontrol: int, rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_dms: list, wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_wfss: list, p_tel: shesha.config.PTEL.Param_tel, p_controller: shesha.config.PCONTROLLER.Param_controller, M2V=None, dataBase: dict = {}, use_DB: bool = False) → None¶ Initialize and compute the interaction matrix on the GPU
- Parameters
ncontrol: (int) : controller’s index
rtc: (Rtc) : Rtc object
dms: (Dms) : Dms object
p_dms: (Param_dms) : dms settings
wfs: (Sensors) : Sensors object
p_wfss: (list of Param_wfs) : wfs settings
p_tel: (Param_tel) : telescope settings
p_controller: (Param_controller) : controller settings
M2V:(np.array) : KL_matrix
dataBase:(dict): (optional) dict containing paths to files to load
use_DB:(bool) : (optional) use dataBase flag
-
shesha.ao.modopti.open_loopSlp(tel: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, atmos: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, nrec: int, ncontrol: int, p_wfss: list)¶ Return a set of recorded open-loop slopes, usefull for initialize modal control optimization
- Parameters
tel: (Telescope) : Telescope object
atmos: (Atmos) : Atmos object
wfs: (Sensors) : Sensors object
rtc: (Rtc) : Rtc object
nrec: (int) : number of samples to record
ncontrol: (int) : controller’s index
p_wfss: (list of Param_wfs) : wfs settings
-
shesha.ao.tomo.create_nact_geom(p_dm: shesha.config.PDMS.Param_dm)¶ Compute the DM coupling matrix
- Param
p_dm : (Param_dm) : dm parameters
- Returns
Nact : (np.array(dtype=np.float64)) : the DM coupling matrix
-
shesha.ao.tomo.create_piston_filter(p_dm: shesha.config.PDMS.Param_dm)¶ Create the piston filter matrix
- Parameters
p_dm: (Param_dm): dm settings
-
shesha.ao.tomo.do_tomo_matrices(ncontrol: int, rtc: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_wfss: List[shesha.config.PWFS.Param_wfs], dms: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, atmos: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, p_controller: shesha.config.PCONTROLLER.Param_controller, p_geom: shesha.config.PGEOM.Param_geom, p_dms: list, p_tel: shesha.config.PTEL.Param_tel, p_atmos: shesha.config.PATMOS.Param_atmos)¶ Compute Cmm and Cphim matrices for the MV controller on GPU
- Parameters
ncontrol: (int): controller index
rtc: (Rtc) : rtc object
p_wfss: (list of Param_wfs) : wfs settings
dms: (Dms) : Dms object
atmos: (Atmos) : Atmos object
wfs: (Sensors) : Sensors object
p_controller: (Param_controller): controller settings
p_geom: (Param_geom) : geom settings
p_dms: (list of Param_dms) : dms settings
p_tel: (Param_tel) : telescope settings
p_atmos: (Param_atmos) : atmos settings
-
shesha.ao.tomo.selectDMforLayers(p_atmos: shesha.config.PATMOS.Param_atmos, p_controller: shesha.config.PCONTROLLER.Param_controller, p_dms: list)¶ For each atmos layer, select the DM which have to handle it in the Cphim computation for MV controller
- Parameters
p_atmos : (Param_atmos) : atmos parameters
p_controller : (Param_controller) : controller parameters
p_dms :(list of Param_dm) : dms parameters
- Returns
indlayersDM : (np.array(dtype=np.int32)) : for each atmos layer, the Dm number corresponding to it
-
shesha.ao.wfs.comp_new_fstop(wfs: shesha.sutra_wrap.smart_import.<locals>.tmp_cls, n: int, p_wfs: shesha.config.PWFS.Param_wfs, fssize: float, fstop: bytes)¶ Compute a new field stop for pyrhr WFS
- Parameters
n : (int) : WFS index
wfs : (Param_wfs) : WFS parameters
fssize : (float) : field stop size [arcsec]
fstop : (string) : “square” or “round” (field stop shape)
-
shesha.ao.wfs.comp_new_pyr_ampl(nwfs: int, ampli: float, p_wfss: list, p_tel: shesha.config.PTEL.Param_tel, npts_force: Optional[int] = None)¶ Set the pyramid modulation amplitude
- Parameters
nwfs : (int): WFS index
ampli : (float) : new amplitude in units of lambda/D
p_wfss : (list of Param_wfs) : list of wfs parameters
p_tel : (Param_tel) : Telescope parameters
-
shesha.ao.wfs.noise_cov(nw: int, p_wfs: shesha.config.PWFS.Param_wfs, p_atmos: shesha.config.PATMOS.Param_atmos, p_tel: shesha.config.PTEL.Param_tel)¶ Compute the diagonal of the noise covariance matrix for a SH WFS (arcsec^2) Photon noise: (pi^2/2)*(1/Nphotons)*(d/r0)^2 / (2*pi*d/lambda)^2 Electronic noise: (pi^2/3)*(wfs.noise^2/N^2photons)*wfs.npix^2*(wfs.npix*wfs.pixsize*d/lambda)^2 / (2*pi*d/lambda)^2
- Parameters
nw: wfs number
p_wfs: (Param_wfs) : wfs settings
p_atmos: (Param_atmos) : atmos settings
p_tel: (Param_tel) : telescope settings
- Returns
cov : (np.ndarray(ndim=1,dtype=np.float64)) : noise covariance diagonal