40 from carmaWrap
import context
42 from abc
import ABC, abstractmethod
45 class CoronagraphCompass():
46 """ Class for Compass Coronagraph modules
49 _spupil: (np.ndarray[ndim=2, dtype=np.float32]): Telescope pupil mask
51 _pupdiam : (int): Number of pixels along the pupil diameter
53 _dim_image :(int): Coronagraphic image dimension
55 _p_corono: (Param_corono): Coronagraph parameters
57 _target: (TargetCompass): Compass Target used as input for the coronagraph
59 _norm_img : (float): Normalization factor for coronagraphic image
61 _norm_psf : (float): Normalization factor for PSF
63 _coronos: (Coronagraph): Coronagraph instances
66 """ Initialize a coronagraph instance with generic attributes
69 p_corono: (Param_corono): Compass coronagraph parameters
71 p_geom: (Param_geom): Compass geometry parameters
73 targetCompass: (TargetCompass): Compass Target used as input for the coronagraph
75 coroType: (CoronoType): type of coronagraph
80 def add_corono(self, context:context, p_corono: conf.Param_corono, p_geom: conf.Param_geom,
81 targetCompass: TargetCompass):
85 p_corono: (Param_corono): Compass coronagraph parameters
87 p_geom: (Param_geom): Compass geometry parameters
89 targetCompass: (TargetCompass): Compass Target used as input for the coronagraph
91 if(p_corono._type == scons.CoronoType.CUSTOM)
or (p_corono._type == scons.CoronoType.SPHERE_APLC):
93 self.
_coronos_coronos.append(StellarCoronagraphCompass(context, targetCompass, p_corono, p_geom))
95 elif(p_corono._type == scons.CoronoType.PERFECT):
97 self.
_coronos_coronos.append(PerfectCoronagraphCompass(context, targetCompass, p_corono, p_geom))
99 def compute_image(self, coro_index: int, *, comp_psf: bool =
True, accumulate: bool =
True):
100 """ Compute the SE coronagraphic image, and accumulate it in the LE image
103 coro_index: (int): Index of the coronagraph
105 comp_psf: (bool, optionnal): If True (default), also compute the PSF SE & LE
107 accumulate: (bool, optional): If True (default), the computed SE image is accumulated in
112 def compute_psf(self, coro_index: int, *, accumulate: bool =
True):
113 """ Compute the SE psf, and accumulate it in the LE image
116 coro_index: (int): Index of the coronagraph
118 accumulate: (bool, optional): If True (default), the computed SE psf is accumulated in
123 def get_image(self, coro_index: int, *, expo_type:str=scons.ExposureType.LE):
124 """ Return the coronagraphic image
127 coro_index: (int): Index of the coronagraph
129 expo_type: (str, optional): If "le" (default), returns the long exposure image.
130 If "se", returns short exposure one.
133 img: (np.ndarra[ndim=2,dtype=np.float32]): coronagraphic image
137 def get_psf(self, coro_index: int, *, expo_type:str=scons.ExposureType.LE):
141 coro_index: (int): Index of the coronagraph
143 expo_type: (str, optional): If "le" (default), returns the long exposure psf.
144 If "se", returns short exposure one.
147 img: (np.ndarra[ndim=2,dtype=np.float32]): psf
151 def reset(self, *, coro_index: int=
None):
152 """ Reset long exposure image and PSF
155 coro_index: (int): Index of the coronagraph to reset. If not provided, reset all coronagraphs
157 if coro_index
is None:
158 for corono
in self.
_coronos_coronos:
163 def get_contrast(self, coro_index, *, expo_type=scons.ExposureType.LE, d_min=None, d_max=None, width=None, normalized_by_psf=True):
164 """ Computes average, standard deviation, minimum and maximum of coronagraphic
165 image intensity, over rings at several angular distances from the optical axis.
167 A ring includes the pixels between the following angular distances :
168 d_min + k * width - width / 2 and d_min + k * width + width / 2 (in lambda/D units)
169 with k = 0, 1, 2... until d_min + k * width > d_max (excluded).
172 coro_index: (int): Index of the coronagraph
174 expo_type: (str, optional): If "le" (default), computes contrast on the long exposure image.
175 If "se", it uses the short exposure one.
177 d_min: (float, optional): Angular radius of the first ring in lambda/D unit.
180 d_max: (float, optional): Maximum angular distances in lambda/D unit.
181 Default includes the whole image.
183 width: (float, optional): Width of one ring in lambda/D unit.
184 Default = 1 [lambda/D]
186 normalized_by_psf: (bool, optional): If True (default), the coronagraphic image
187 is normalized by the maximum of the PSF
190 distances: (1D array): angular distances to the optical axis in lambda/D unit
192 mean: (1D array): corresponding average intensities
194 std: (1D array): corresponding standard deviations
196 mini: (1D array): corresponding minimums
198 maxi: (1D array): corresponding maximums
200 return self.
_coronos_coronos[coro_index].
get_contrast(expo_type=expo_type, d_min=d_min, d_max=d_max,
202 normalized_by_psf=normalized_by_psf)
205 """ Set the amplitude of the electric field
208 coro_index: (int): Index of the coronagraph
210 amplitude: (np.ndarray[ndim=3, dtype=np.float32]): amplitude for each wavelength
def get_psf(self, int coro_index, *str expo_type=scons.ExposureType.LE)
Return the psf.
def compute_psf(self, int coro_index, *bool accumulate=True)
Compute the SE psf, and accumulate it in the LE image.
def add_corono(self, context context, conf.Param_corono p_corono, conf.Param_geom p_geom, TargetCompass targetCompass)
Add a coronagraph.
def get_contrast(self, coro_index, *expo_type=scons.ExposureType.LE, d_min=None, d_max=None, width=None, normalized_by_psf=True)
Computes average, standard deviation, minimum and maximum of coronagraphic image intensity,...
def set_electric_field_amplitude(self, coro_index, np.ndarray amplitude)
Set the amplitude of the electric field.
def compute_image(self, int coro_index, *bool comp_psf=True, bool accumulate=True)
Compute the SE coronagraphic image, and accumulate it in the LE image.
def reset(self, *int coro_index=None)
Reset long exposure image and PSF.
def get_image(self, int coro_index, *str expo_type=scons.ExposureType.LE)
Return the coronagraphic image.
Parameter classes for COMPASS.
Numerical constants for shesha and config enumerations for safe-typing.