shesha.sim

COMPASS simulation package Abstraction layer for initialization and execution of a COMPASS simulation

class shesha.sim.simulator.Simulator(filepath: str = None, use_DB: bool = False)

The Simulator class is self sufficient for running a COMPASS simulation Initializes and run a COMPASS simulation

applyControl(nControl: int, compVoltage: bool = True)

Computes the final voltage vector to apply on the DM by taking into account delay and perturbation voltages, and shape the DMs

nControl: (int): controller index compVoltage: (bool): If True (default), computes the voltage vector from the command one (delay + perturb). Else, directly applies the current voltage vector

clear_init() → None

Delete objects initialized in a previous simulation

compStrehl(tarNum: int = 0)

Computes the Strehl ratio

tarNum: (int): (optionnal) target index (default 0)

compTarImage(tarNum: int = 0, puponly: int = 0, compLE: bool = True)

Computes the PSF

tarNum: (int): (optionnal) target index (default=0) puponly: (int): (optionnal) if set to 1, computes Airy (default=0) compLE: (bool): (optionnal) if True, the computed image is taken into account in long exposure image (default=True)

compWfsImage(wfsNum: int = 0, noise: bool = True)

Computes the image produced by the WFS from its phase screen

wfsNum: (int): wfs index

doCentroids(nControl: int)

Computes the centroids from the Wfs image

nControl: (int): controller index

doCentroidsGeom(nControl: int)

Computes the centroids geom from the Wfs image

nControl: (int): controller index

doClipping(nControl: int)

Clip the commands between vmin and vmax values set in the RTC

nControl: (int): controller index

doControl(nControl: int, n: int = 0, wfs_direction: bool = False)

Computes the command from the Wfs slopes

nControl: (int): controller index n: (int) : target or wfs index (only used with GEO controller)

force_context() → None

Active all the GPU devices specified in the parameters file

getStrehl(numTar: int)

Return the Strehl Ratio of target number numTar as [SR short exp., SR long exp., np.var(phiSE), np.var(phiLE)]

numTar: (int): target index

init_sim() → None

Initializes the simulation by creating all the sutra objects that will be used

load_from_file(filepath: str) → None

Load the parameters from the parameters file

Parameters:filepath: (str): path to the parameters file
load_from_module(filepath: str) → None

Load the parameters from the parameters file

Parameters:filepath: (str): path to the parameters file
loop(n: int = 1, monitoring_freq: int = 100, **kwargs)

Perform the AO loop for n iterations

Parameters:n: (int): (optional) Number of iteration that will be done monitoring_freq: (int): (optional) Monitoring frequency [frames]
moveAtmos()

Move the turbulent layers according to wind speed and direction for a single iteration

next(*, move_atmos: bool = True, see_atmos: bool = True, nControl: int = 0, tar_trace: Iterable[int] = None, wfs_trace: Iterable[int] = None, do_control: bool = True, apply_control: bool = True) → None

Iterates the AO loop, with optional parameters

Parameters:

move_atmos: (bool): move the atmosphere for this iteration, default: True

nControl: (int): Controller number to use, default 0 (single control configurations)

tar_trace: (None or list[int]): list of targets to trace. None equivalent to all.

wfs_trace: (None or list[int]): list of WFS to trace. None equivalent to all.

apply_control: (bool): (optional) if True (default), apply control on DMs

raytraceTar(tarNum, layers: list, rst: bool = True)

Performs the raytracing operation to obtain the phase seen by the tarNum target The phase screen is reset before the operations if rst is not set to False

tarNum: (int): target index layers: (list): list of string containing the layers to raytrace through.

Accepted are : “all” -> raytrace through all layers
“atmos” -> raytrace through turbulent layers only “dm” -> raytrace through DM shape only “ncpa” -> raytrace through NCPA only “tel” -> raytrace through telescope aberrations only

rst: (bool): reset the phase screen before raytracing (default = True)

raytraceWfs(wfsNum, layers: list, rst: bool = True)

Performs the raytracing operation to obtain the phase seen by the wfsNum Wfs The phase screen is reset before the operations if rst is not set to False

wfsNum: (int): wfs index layers: (list): list of string containing the layers to raytrace through.

Accepted are : “all” -> raytrace through all layers
“atmos” -> raytrace through turbulent layers only “dm” -> raytrace through DM shape only “ncpa” -> raytrace through NCPA only “tel” -> raytrace through telescope aberrations only

rst: (bool): reset the phase screen before raytracing (default = True)