46 from typing
import Iterable
50 """ This class implements a single stage (e.g. first stage, second stage) supervisor
51 to handle compass simulations of cascaded AO. The main supervision will be handled by another
55 context : (CarmaContext) : a CarmaContext instance
57 config : (config) : Parameters structure
59 is_init : (bool) : Flag equals to True if the supervisor has already been initialized
61 iter : (int) : Frame counter
63 telescope : (TelescopeComponent) : a TelescopeComponent instance
65 atmos : (AtmosComponent) : An AtmosComponent instance
67 target : (targetComponent) : A TargetComponent instance
69 wfs : (WfsComponent) : A WfsComponent instance
71 dms : (DmComponent) : A DmComponent instance
73 rtc : (RtcComponent) : A Rtc component instance
75 cacao : (bool) : CACAO features enabled in the RTC
77 basis : (ModalBasis) : a ModalBasis instance (optimizer)
79 calibration : (Calibration) : a Calibration instance (optimizer)
81 modalgains : (ModalGains) : a ModalGain instance (optimizer) using CLOSE algorithm
83 close_modal_gains : (list of floats) : list of the previous values of the modal gains
86 def next(self, *, move_atmos: bool =
True, nControl: int = 0,
87 tar_trace: Iterable[int] =
None, wfs_trace: Iterable[int] =
None,
88 do_control: bool =
True, apply_control: bool =
True,
89 compute_tar_psf: bool =
True, stack_wfs_image: bool =
False,
90 do_centroids: bool =
True, compute_corono: bool=
True) ->
None:
91 """Iterates the AO loop, with optional parameters, considering it is a single
92 stage and may be called in the middle of WFS frames.
93 Overload the CompassSupervisor next() method to arrange tasks orders and allow cascaded
97 move_atmos: (bool): move the atmosphere for this iteration. Default is True
99 nControl: (int): Controller number to use. Default is 0 (single control configuration)
101 tar_trace: (List): list of targets to trace. None is equivalent to all (default)
103 wfs_trace: (List): list of WFS to trace. None is equivalent to all (default)
105 do_control : (bool) : Performs RTC operations if True (Default)
107 apply_control: (bool): if True (default), apply control on DMs
109 compute_tar_psf : (bool) : If True (default), computes the PSF at the end of the
112 stack_wfs_image : (bool) : If False (default), the Wfs image is computed as
113 usual. Otherwise, a newly computed WFS image is accumulated
116 do_centroids : (bool) : If True (default), the last WFS image is stacked and
117 centroids computation is done. WFS image must be reset before
118 next loop (in the manager).
120 compute_corono: (bool): If True (default), computes the coronagraphic image
126 nControl = [nControl]
129 geo_index =
next(( i
for i,c
in enumerate(self.
configconfig.p_controllers)
130 if c.type== scons.ControllerType.GEO ), -1)
132 if tar_trace
is None and self.
targettarget
is not None:
133 tar_trace = range(len(self.
configconfig.p_targets))
134 if wfs_trace
is None and self.
wfswfs
is not None:
135 wfs_trace = range(len(self.
configconfig.p_wfss))
137 if move_atmos
and self.
atmosatmos
is not None:
138 self.
atmosatmos.move_atmos()
140 self.
teltel.update_input_phase()
142 if ( geo_index > -1):
145 if tar_trace
is not None:
149 self.
rtcrtc.apply_control(nControl)
151 if self.
atmosatmos.is_enable:
152 self.
targettarget.raytrace(t, tel=self.
teltel, atm=self.
atmosatmos, ncpa=
False)
154 self.
targettarget.raytrace(t, tel=self.
teltel, ncpa=
False)
156 if do_control
and self.
rtcrtc
is not None:
157 self.
rtcrtc.do_control(nControl, sources=self.
targettarget.sources)
158 self.
targettarget.raytrace(t, dms=self.
dmsdms, ncpa=
True, reset=
False)
166 for ncontrol
in nControl :
168 self.
rtcrtc.apply_control(ncontrol)
172 if tar_trace
is not None:
174 if self.
atmosatmos.is_enable:
175 self.
targettarget.raytrace(t, tel=self.
teltel, atm=self.
atmosatmos,
178 self.
targettarget.raytrace(t, tel=self.
teltel, dms=self.
dmsdms)
180 if wfs_trace
is not None:
182 if self.
atmosatmos.is_enable:
183 self.
wfswfs.raytrace(w, tel=self.
teltel, atm=self.
atmosatmos)
185 self.
wfswfs.raytrace(w, tel=self.
teltel)
187 if not self.
configconfig.p_wfss[w].open_loop
and self.
dmsdms
is not None:
188 self.
wfswfs.raytrace(w, dms=self.
dmsdms, ncpa=
False, reset=
False)
192 wfs_image = self.
wfswfs.get_wfs_image(w)
193 self.
wfswfs.compute_wfs_image(w)
194 self.
wfswfs.set_wfs_image(w, self.
wfswfs.get_wfs_image(w) + wfs_image)
196 self.
wfswfs.compute_wfs_image(w)
198 if self.
rtcrtc
is not None:
199 for ncontrol
in nControl :
203 self.
rtcrtc.do_centroids(ncontrol)
206 self.
rtcrtc.do_control(ncontrol)
209 self.
rtcrtc.publish()
213 for tar_index
in tar_trace:
214 self.
targettarget.comp_tar_image(tar_index)
215 self.
targettarget.comp_strehl(tar_index)
217 if self.
coronocorono
is not None and compute_corono:
218 for coro_index
in range(len(self.
configconfig.p_coronos)):
219 self.
coronocorono.compute_image(coro_index)
221 if self.
configconfig.p_controllers[0].close_opti
and (
not self.
rtcrtc._rtc.d_control[0].open_loop):
230 Reset the simulation to return to its original state.
231 Overwrites the compassSupervisor reset function, reseting explicitely the WFS image,
232 to force a new integration of the frame.
234 self.
atmosatmos.reset_turbu()
235 self.
wfswfs.reset_noise()
236 self.
wfswfs.reset_image()
237 for tar_index
in range(len(self.
configconfig.p_targets)):
238 self.
targettarget.reset_strehl(tar_index)
239 self.
dmsdms.reset_dm()
240 self.
rtcrtc.open_loop()
241 self.
rtcrtc.close_loop()
This class implements generic supervisor to handle compass simulation.
atmos
(AtmosComponent) : An AtmosComponent instance
dms
(DmComponent) : A DmComponent instance
rtc
(RtcComponent) : A Rtc component instance
target
(targetComponent) : A TargetComponent instance
cacao
(bool) : CACAO features enabled in the RTC
modalgains
(ModalGains) : a ModalGain instance (optimizer) using CLOSE algorithm
close_modal_gains
(list of floats) : list of the previous values of the modal gains
wfs
(WfsComponent) : A WfsComponent instance
iter
(int) : Frame counter
config
(config) : Parameters structure
This class implements a single stage (e.g.
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, bool stack_wfs_image=False, bool do_centroids=True, bool compute_corono=True)
Iterates the AO loop, with optional parameters, considering it is a single stage and may be called in...
def reset(self)
Reset the simulation to return to its original state.
Numerical constants for shesha and config enumerations for safe-typing.
Initialization and execution of a COMPASS supervisor.
User layer for optimizing AO supervisor loop.