42 """ Target handler for compass simulation
45 target : (sutraWrap.Target) : Sutra target instance
47 context : (carmaContext) : CarmaContext instance
49 config : (config module) : Parameters configuration structure module
51 sources : (List) : List of SutraSource instances used for raytracing
53 def __init__(self, context, config, tel):
54 """ Initialize a TargetCompass component for target related supervision
57 context : (carmaContext) : CarmaContext instance
59 config : (config module) : Parameters configuration structure module
61 tel : (TelescopeCompass) : A TelescopeCompass instance
65 print(
"->target init")
71 def get_tar_image(self, tar_index : int, *, expo_type: str =
"se") -> np.ndarray:
72 """ Get the PSF in the direction of the given target
75 tar_index : (int) : Index of target
77 expo_type : (str, optional) : "se" for short exposure (default)
78 "le" for long exposure
81 psf : (np.ndarray) : PSF
83 if (expo_type ==
"se"):
84 return np.fft.fftshift(
85 np.array(self.
target.d_targets[tar_index].d_image_se))
86 elif (expo_type ==
"le"):
87 return np.fft.fftshift(
88 np.array(self.
target.d_targets[tar_index].d_image_le)
89 ) / self.
target.d_targets[tar_index].strehl_counter
91 raise ValueError(
"Unknown exposure type")
94 """ Set the phase screen seen by the tar
97 tar_index : (int) : target index
99 phase : (np.ndarray) : phase screen to set
101 self.
target.d_targets[tar_index].set_phase(phase)
103 def get_tar_phase(self, tar_index: int, *, pupil: bool =
False) -> np.ndarray:
104 """ Returns the target phase screen of target number tar_index
107 tar_index : (int) : Target index
109 pupil : (bool, optional) : If True, applies the pupil on top of the phase screen
113 tar_phase : (np.ndarray) : Target phase screen
115 tar_phase = np.array(self.
target.d_targets[tar_index].d_phase)
117 pup = self.
config.p_geom._spupil
122 """ Reset the Strehl Ratio of the target tar_index
125 tar_index : (int) : Target index
127 self.
target.d_targets[tar_index].reset_strehlmeter()
130 """ Reset the phase screen of the target tar_index
133 tar_index : (int) : Target index
135 self.
target.d_targets[tar_index].d_phase.reset()
137 def get_strehl(self, tar_index: int, *, do_fit: bool =
True) -> np.ndarray:
138 """ Return the Strehl Ratio of target number tar_index.
139 This fuction will return an array of 4 values as
140 [SR SE, SR LE, phase variance SE [µm²], phase variance LE [µm²]]
143 tar_index : (int) : Target index
145 do_fit : (bool, optional) : If True (default), fit the PSF
146 with a sinc before computing SR
149 strehl : (np.ndarray) : Strehl ratios and phase variances
151 src = self.
target.d_targets[tar_index]
152 src.comp_strehl(do_fit)
154 if (src.phase_var_count > 0):
155 avg_var = src.phase_var_avg / src.phase_var_count
156 return [src.strehl_se, src.strehl_le, src.phase_var, avg_var]
159 """ Return the current NCPA phase screen of the target path
162 tar_index : (int) : Index of the target
165 ncpa : (np.ndarray) : NCPA phase screen
167 return np.array(self.
target.d_targets[tar_index].d_ncpa_phase)
169 def set_ncpa_tar(self, tar_index: int, ncpa: np.ndarray) ->
None:
170 """ Set the additional fixed NCPA phase in the target path.
171 ncpa must be of the same size of the spupil support
174 tar_index : (int) : WFS index
176 ncpa : (ndarray) : NCPA phase screen to set [µm]
178 self.
target.d_targets[tar_index].set_ncpa(ncpa)
180 def comp_tar_image(self, tarNum: int, *, puponly: int = 0, compLE: bool =
True) ->
None:
184 tarNum: (int): target index
186 puponly: (int, optionnal) : if set to 1, computes Airy (default=0)
188 compLE: (bool, optionnal) : if True, the computed image is taken into account in long exposure image (default=True)
190 self.
target.d_targets[tarNum].comp_image(puponly, compLE)
192 def comp_strehl(self, tarNum: int, *, do_fit: bool =
True) ->
None:
193 """ Computes the Strehl ratio
196 tarNum: (int): target index