Optical Systems

class Asterix.optics.OpticalSystem(modelconfig)

Bases: object

Super class OpticalSystem allows passing parameters to all subclasses.

We can then creat blocks inside this super class. An OpticalSystem start and end in the pupil plane. The entrance and exit pupil plane must always of the same size (dim_overpad_pupil) With these conventions, they can be easily assemble to create complex optical systems.

AUTHOR : Johan Mazoyer

Methods

EF_from_phase_and_ampl([phase_abb, ...])

Create an electrical field from an phase and amplitude aberrations as follows:

EF_through([entrance_EF])

Propagate the electric field from entrance pupil to exit pupil.

add_photon_noise(focal_plane_intensity, ...)

Add photon noise to an image in contrast.

generate_ampl_aberr(SIMUconfig[, ...])

Generate and save amplitude aberations.

generate_phase_aberr(SIMUconfig[, ...])

Generate and save phase aberrations.

individual_normalizations([wavelengths])

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

measure_normalization()

Measure several values to normalize the data.

todetector([entrance_EF, wavelength, ...])

Propagate the electric field from entrance plane through the system and then to Science focal plane.

todetector_intensity([entrance_EF, ...])

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

transmission([noFPM])

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

EF_through(entrance_EF=1.0, **kwargs)

Propagate the electric field from entrance pupil to exit pupil.

NEED TO BE DEFINED FOR ALL OpticalSystem subclasses

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other parameters can be passed for OpticalSystem objects EF_trough functions

Returns:
exit_EF2D array, of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electric field in the pupil plane a the exit of the system

todetector(entrance_EF=1.0, wavelength=None, center_on_pixel=False, in_contrast=True, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system and then to Science focal plane.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

in_contrastbool, default True

Normalize to np.sqrt(self.norm_monochrom[self.wav_vec.tolist().index(wavelength)])) (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EFor during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other kw parameters can be passed direclty to self.EF_through function

Returns:
ef_focal_plane2D array of size [self.dimScience, self.dimScience]

Electric field in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

todetector_intensity(entrance_EF=1.0, wavelengths=None, in_contrast=True, center_on_pixel=False, nb_photons=0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF3D complex array of size [nb_wav, self.dim_overpad_pupil, self.dim_overpad_pupil]

or 2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthsfloat or float array of wavelength in m.

Default is all wavelenthg in self.wav_vec

in_contrastbool, default True. normalize to

self.norm_polychrom (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EF or during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

nb_photonsfloat, optional, default 0

Number of photons entering the pupil. If 0, no photon noise.

**kwargs

Other kw parameters can be passed direclty to self.EF_through function

Returns:
focal_plane_intensity2D array of size [self.dimScience, self.dimScience]

Intensity in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

add_photon_noise(focal_plane_intensity, nb_photons, in_contrast=True)

Add photon noise to an image in contrast.

This is only applied to images for which the normalization factors have been measured (for wavelength in self.wave_vec). You need to have measured the normalization previously (running self.measure_normalization). Making it separate allow us to run the propagation only once in cases where we want both the image with and without photon noise.

AUTHOR : Johan Mazoyer

Parameters:
  • focal_plane_intensity (numpy array of shape (self.dimScience,self.dimScience)) – the focal plane intensity, normalized in contrast

  • nb_photons (float) – Number of photons entering the pupil.

  • in_contrast (bool, default True.) – If True, the data are normalized in contrast

Returns:
focal_plane_intensitynumpy array of shape (self.dimScience,self.dimScience)

the focal plane intensity, with photon noise, normalized in contrast

transmission(noFPM=True, **kwargs)

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

By default, transmission is done at the reference WL, and there is no reason to depend heavily on the WL.

AUTHOR : Johan Mazoyer

Parameters:
  • noFPM (bool, defaut True) – if the optical transfert function EF_through has a noFPM parameter

  • **kwargs – other kw parameters can be passed direclty to self.EF_through function

Returns:
transmissionfloat

ratio exit flux / clear entrance pupil flux

measure_normalization()

Measure several values to normalize the data.

Function must be used at the end of all Optical Systems initalization.

Measure 3 values:
  • self.norm_monochrom. Array of size len(self.wav_vec)

    the PSF per WL, use to normalize to_detector

  • self.norm_polychrom. float

    the polychromatic PSF used to normalize to_detector_Intensity

  • self.normPupto1, which is used to measure the photon noise

    This is the factor that we use to measure photon noise. From an image in contrast, we now normalize by the total amount of energy (*self.norm_polychrom / self.sum_polychrom) and then account for the energy lost in the process (self.transmission()). Can be used as follow: Im_intensity_photons = Im_Intensity_contrast * self.normPupto1 * nb_photons

AUTHOR : Johan Mazoyer

individual_normalizations(wavelengths=None)

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

AUTHOR : Johan Mazoyer

Parameters:
wavelengthsfloat or list of floats.

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
norm_polychromfloat

Maximum value of the PSF in polychrom light. Used to normalize to_detector_intensity().

sum_polychromfloat

Sum of the PSF in polychrom light. Used to normalize for photon noise.

norm_monochromnumpy array of the same length as wavelengths

Norm of PSFs at each wavelength. Can be used to individually normalize PSFs in monochromatic light.

sum_monochromnumpy array of the same length as wavelengths

Sum of PSFs at each wavelength. Not sure if useful at all but comes for free here.

generate_phase_aberr(SIMUconfig, up_or_down='up', Model_local_dir=None, silence=False)

Generate and save phase aberrations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

parameter of this simualtion (describing the phase)

up_or_downstring, default, ‘up’

‘up’ or ‘do’, use to access the right parameters in the parameter file for upstream (entrance pupil) or downstream (Lyot plane) aberrations

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse. In this case the phase aberrations is saved if Model_local_dir is not None

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_phase2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

phase aberration at the reference wavelength

generate_ampl_aberr(SIMUconfig, Model_local_dir=None, silence=False)

Generate and save amplitude aberations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

Parameter of this simualtion (describing the amplitude)

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse.

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_ampl2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Amplitude abberation

EF_from_phase_and_ampl(phase_abb=0.0, ampl_abb=0.0, wavelengths=-1.0)

Create an electrical field from an phase and amplitude aberrations as follows:

EF = (1 + ample_abb)*exp(i*phase_abb * self.wavelength_0 / wavelength) can be monochromatic (return 2d compex array) or polychromatic (return 3d compex array) if no phase nor amplitude, return 1.

AUTHOR : Johan Mazoyer

Parameters:
phase_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Phase aberration at reference wavelength self.wavelength_0. if 0, no phase aberration (default)

ampl_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Amplitude aberration at reference wavelength self.wavelength_0. if 0, no amplitude aberration (default)

wavelengthsfloat or list of floats

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
EFscalar or numpy 2D array or numpy 3d array
Electric field in the pupil plane a the exit of the system:

1. if no phase / amplitude 2D array, of size phase_abb.shape if monochromatic or 3D array of size [self.nb_wav,phase_abb.shape] in case of polychromatic

class Asterix.optics.Pupil(modelconfig, prad=0.0, PupType=None, angle_rotation=0, Model_local_dir=None, silence=False)

Bases: OpticalSystem

Initialize and describe the behavior of single pupil pupil is a sub class of OpticalSystem.

Obviously you can define your pupil without that with 2d arrray multiplication (this is a fairly simple object).

The main advantage of defining them using OpticalSystem is that you can use default OpticalSystem functions to obtain PSF, transmission, etc… and concatenate them with other elements

AUTHOR : Johan Mazoyer

Methods

EF_from_phase_and_ampl([phase_abb, ...])

Create an electrical field from an phase and amplitude aberrations as follows:

EF_through([entrance_EF, wavelength, ...])

Propagate the electric field through the pupil AUTHOR : Johan Mazoyer

add_photon_noise(focal_plane_intensity, ...)

Add photon noise to an image in contrast.

generate_ampl_aberr(SIMUconfig[, ...])

Generate and save amplitude aberations.

generate_phase_aberr(SIMUconfig[, ...])

Generate and save phase aberrations.

individual_normalizations([wavelengths])

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

measure_normalization()

Measure several values to normalize the data.

todetector([entrance_EF, wavelength, ...])

Propagate the electric field from entrance plane through the system and then to Science focal plane.

todetector_intensity([entrance_EF, ...])

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

transmission([noFPM])

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

EF_from_phase_and_ampl(phase_abb=0.0, ampl_abb=0.0, wavelengths=-1.0)

Create an electrical field from an phase and amplitude aberrations as follows:

EF = (1 + ample_abb)*exp(i*phase_abb * self.wavelength_0 / wavelength) can be monochromatic (return 2d compex array) or polychromatic (return 3d compex array) if no phase nor amplitude, return 1.

AUTHOR : Johan Mazoyer

Parameters:
phase_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Phase aberration at reference wavelength self.wavelength_0. if 0, no phase aberration (default)

ampl_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Amplitude aberration at reference wavelength self.wavelength_0. if 0, no amplitude aberration (default)

wavelengthsfloat or list of floats

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
EFscalar or numpy 2D array or numpy 3d array
Electric field in the pupil plane a the exit of the system:

1. if no phase / amplitude 2D array, of size phase_abb.shape if monochromatic or 3D array of size [self.nb_wav,phase_abb.shape] in case of polychromatic

add_photon_noise(focal_plane_intensity, nb_photons, in_contrast=True)

Add photon noise to an image in contrast.

This is only applied to images for which the normalization factors have been measured (for wavelength in self.wave_vec). You need to have measured the normalization previously (running self.measure_normalization). Making it separate allow us to run the propagation only once in cases where we want both the image with and without photon noise.

AUTHOR : Johan Mazoyer

Parameters:
  • focal_plane_intensity (numpy array of shape (self.dimScience,self.dimScience)) – the focal plane intensity, normalized in contrast

  • nb_photons (float) – Number of photons entering the pupil.

  • in_contrast (bool, default True.) – If True, the data are normalized in contrast

Returns:
focal_plane_intensitynumpy array of shape (self.dimScience,self.dimScience)

the focal plane intensity, with photon noise, normalized in contrast

generate_ampl_aberr(SIMUconfig, Model_local_dir=None, silence=False)

Generate and save amplitude aberations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

Parameter of this simualtion (describing the amplitude)

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse.

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_ampl2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Amplitude abberation

generate_phase_aberr(SIMUconfig, up_or_down='up', Model_local_dir=None, silence=False)

Generate and save phase aberrations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

parameter of this simualtion (describing the phase)

up_or_downstring, default, ‘up’

‘up’ or ‘do’, use to access the right parameters in the parameter file for upstream (entrance pupil) or downstream (Lyot plane) aberrations

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse. In this case the phase aberrations is saved if Model_local_dir is not None

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_phase2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

phase aberration at the reference wavelength

individual_normalizations(wavelengths=None)

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

AUTHOR : Johan Mazoyer

Parameters:
wavelengthsfloat or list of floats.

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
norm_polychromfloat

Maximum value of the PSF in polychrom light. Used to normalize to_detector_intensity().

sum_polychromfloat

Sum of the PSF in polychrom light. Used to normalize for photon noise.

norm_monochromnumpy array of the same length as wavelengths

Norm of PSFs at each wavelength. Can be used to individually normalize PSFs in monochromatic light.

sum_monochromnumpy array of the same length as wavelengths

Sum of PSFs at each wavelength. Not sure if useful at all but comes for free here.

measure_normalization()

Measure several values to normalize the data.

Function must be used at the end of all Optical Systems initalization.

Measure 3 values:
  • self.norm_monochrom. Array of size len(self.wav_vec)

    the PSF per WL, use to normalize to_detector

  • self.norm_polychrom. float

    the polychromatic PSF used to normalize to_detector_Intensity

  • self.normPupto1, which is used to measure the photon noise

    This is the factor that we use to measure photon noise. From an image in contrast, we now normalize by the total amount of energy (*self.norm_polychrom / self.sum_polychrom) and then account for the energy lost in the process (self.transmission()). Can be used as follow: Im_intensity_photons = Im_Intensity_contrast * self.normPupto1 * nb_photons

AUTHOR : Johan Mazoyer

todetector(entrance_EF=1.0, wavelength=None, center_on_pixel=False, in_contrast=True, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system and then to Science focal plane.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

in_contrastbool, default True

Normalize to np.sqrt(self.norm_monochrom[self.wav_vec.tolist().index(wavelength)])) (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EFor during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other kw parameters can be passed direclty to self.EF_through function

Returns:
ef_focal_plane2D array of size [self.dimScience, self.dimScience]

Electric field in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

todetector_intensity(entrance_EF=1.0, wavelengths=None, in_contrast=True, center_on_pixel=False, nb_photons=0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF3D complex array of size [nb_wav, self.dim_overpad_pupil, self.dim_overpad_pupil]

or 2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthsfloat or float array of wavelength in m.

Default is all wavelenthg in self.wav_vec

in_contrastbool, default True. normalize to

self.norm_polychrom (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EF or during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

nb_photonsfloat, optional, default 0

Number of photons entering the pupil. If 0, no photon noise.

**kwargs

Other kw parameters can be passed direclty to self.EF_through function

Returns:
focal_plane_intensity2D array of size [self.dimScience, self.dimScience]

Intensity in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

transmission(noFPM=True, **kwargs)

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

By default, transmission is done at the reference WL, and there is no reason to depend heavily on the WL.

AUTHOR : Johan Mazoyer

Parameters:
  • noFPM (bool, defaut True) – if the optical transfert function EF_through has a noFPM parameter

  • **kwargs – other kw parameters can be passed direclty to self.EF_through function

Returns:
transmissionfloat

ratio exit flux / clear entrance pupil flux

EF_through(entrance_EF=1.0, wavelength=None, dir_save_all_planes=None, **kwargs)

Propagate the electric field through the pupil AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant)

Electric field in the pupil plane a the entrance of the system. Default is 1.

wavelengthfloat

Current wavelength in m. Default is self.wavelength_0 the reference wavelength

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

Returns:
exit_EF2D array, of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electric field in the pupil plane a the exit of the system

class Asterix.optics.Coronagraph(modelconfig, coroconfig, Model_local_dir=None, silence=False)

Bases: OpticalSystem

Initialize and describe the behavior of a coronagraph system (from apod plane to the Lyot plane).

AUTHOR : Johan Mazoyer

Methods

ClassicalLyot()

Create a classical Lyot coronagraph of radius rad_LyotFP.

EF_from_phase_and_ampl([phase_abb, ...])

Create an electrical field from an phase and amplitude aberrations as follows:

EF_through([entrance_EF, wavelength, noFPM, ...])

Propagate the electric field from the apodizer plane before the apodizer pupil to the Lyot plane after the Lyot pupil.

FQPM()

Create a Four Quadrant Phase Mask coronagraph.

HLC()

Create an HLC of radius rad_LyotFP.

KnifeEdgeCoro()

Create a Knife edge coronagraph of size (dimScience,dimScience).

Vortex([vortex_charge])

Create a vortex coronagraph with charge 'vortex_charge'.

WrappedVortex([offset, cen_shift, ...])

Create a wrapped vortex coronagraph.

add_photon_noise(focal_plane_intensity, ...)

Add photon noise to an image in contrast.

generate_ampl_aberr(SIMUconfig[, ...])

Generate and save amplitude aberations.

generate_phase_aberr(SIMUconfig[, ...])

Generate and save phase aberrations.

individual_normalizations([wavelengths])

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

measure_normalization()

Measure several values to normalize the data.

todetector([entrance_EF, wavelength, ...])

Propagate the electric field from entrance plane through the system and then to Science focal plane.

todetector_intensity([entrance_EF, ...])

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

transmission([noFPM])

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

EF_from_phase_and_ampl(phase_abb=0.0, ampl_abb=0.0, wavelengths=-1.0)

Create an electrical field from an phase and amplitude aberrations as follows:

EF = (1 + ample_abb)*exp(i*phase_abb * self.wavelength_0 / wavelength) can be monochromatic (return 2d compex array) or polychromatic (return 3d compex array) if no phase nor amplitude, return 1.

AUTHOR : Johan Mazoyer

Parameters:
phase_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Phase aberration at reference wavelength self.wavelength_0. if 0, no phase aberration (default)

ampl_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Amplitude aberration at reference wavelength self.wavelength_0. if 0, no amplitude aberration (default)

wavelengthsfloat or list of floats

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
EFscalar or numpy 2D array or numpy 3d array
Electric field in the pupil plane a the exit of the system:

1. if no phase / amplitude 2D array, of size phase_abb.shape if monochromatic or 3D array of size [self.nb_wav,phase_abb.shape] in case of polychromatic

add_photon_noise(focal_plane_intensity, nb_photons, in_contrast=True)

Add photon noise to an image in contrast.

This is only applied to images for which the normalization factors have been measured (for wavelength in self.wave_vec). You need to have measured the normalization previously (running self.measure_normalization). Making it separate allow us to run the propagation only once in cases where we want both the image with and without photon noise.

AUTHOR : Johan Mazoyer

Parameters:
  • focal_plane_intensity (numpy array of shape (self.dimScience,self.dimScience)) – the focal plane intensity, normalized in contrast

  • nb_photons (float) – Number of photons entering the pupil.

  • in_contrast (bool, default True.) – If True, the data are normalized in contrast

Returns:
focal_plane_intensitynumpy array of shape (self.dimScience,self.dimScience)

the focal plane intensity, with photon noise, normalized in contrast

generate_ampl_aberr(SIMUconfig, Model_local_dir=None, silence=False)

Generate and save amplitude aberations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

Parameter of this simualtion (describing the amplitude)

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse.

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_ampl2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Amplitude abberation

generate_phase_aberr(SIMUconfig, up_or_down='up', Model_local_dir=None, silence=False)

Generate and save phase aberrations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

parameter of this simualtion (describing the phase)

up_or_downstring, default, ‘up’

‘up’ or ‘do’, use to access the right parameters in the parameter file for upstream (entrance pupil) or downstream (Lyot plane) aberrations

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse. In this case the phase aberrations is saved if Model_local_dir is not None

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_phase2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

phase aberration at the reference wavelength

individual_normalizations(wavelengths=None)

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

AUTHOR : Johan Mazoyer

Parameters:
wavelengthsfloat or list of floats.

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
norm_polychromfloat

Maximum value of the PSF in polychrom light. Used to normalize to_detector_intensity().

sum_polychromfloat

Sum of the PSF in polychrom light. Used to normalize for photon noise.

norm_monochromnumpy array of the same length as wavelengths

Norm of PSFs at each wavelength. Can be used to individually normalize PSFs in monochromatic light.

sum_monochromnumpy array of the same length as wavelengths

Sum of PSFs at each wavelength. Not sure if useful at all but comes for free here.

measure_normalization()

Measure several values to normalize the data.

Function must be used at the end of all Optical Systems initalization.

Measure 3 values:
  • self.norm_monochrom. Array of size len(self.wav_vec)

    the PSF per WL, use to normalize to_detector

  • self.norm_polychrom. float

    the polychromatic PSF used to normalize to_detector_Intensity

  • self.normPupto1, which is used to measure the photon noise

    This is the factor that we use to measure photon noise. From an image in contrast, we now normalize by the total amount of energy (*self.norm_polychrom / self.sum_polychrom) and then account for the energy lost in the process (self.transmission()). Can be used as follow: Im_intensity_photons = Im_Intensity_contrast * self.normPupto1 * nb_photons

AUTHOR : Johan Mazoyer

todetector(entrance_EF=1.0, wavelength=None, center_on_pixel=False, in_contrast=True, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system and then to Science focal plane.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

in_contrastbool, default True

Normalize to np.sqrt(self.norm_monochrom[self.wav_vec.tolist().index(wavelength)])) (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EFor during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other kw parameters can be passed direclty to self.EF_through function

Returns:
ef_focal_plane2D array of size [self.dimScience, self.dimScience]

Electric field in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

todetector_intensity(entrance_EF=1.0, wavelengths=None, in_contrast=True, center_on_pixel=False, nb_photons=0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF3D complex array of size [nb_wav, self.dim_overpad_pupil, self.dim_overpad_pupil]

or 2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthsfloat or float array of wavelength in m.

Default is all wavelenthg in self.wav_vec

in_contrastbool, default True. normalize to

self.norm_polychrom (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EF or during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

nb_photonsfloat, optional, default 0

Number of photons entering the pupil. If 0, no photon noise.

**kwargs

Other kw parameters can be passed direclty to self.EF_through function

Returns:
focal_plane_intensity2D array of size [self.dimScience, self.dimScience]

Intensity in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

transmission(noFPM=True, **kwargs)

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

By default, transmission is done at the reference WL, and there is no reason to depend heavily on the WL.

AUTHOR : Johan Mazoyer

Parameters:
  • noFPM (bool, defaut True) – if the optical transfert function EF_through has a noFPM parameter

  • **kwargs – other kw parameters can be passed direclty to self.EF_through function

Returns:
transmissionfloat

ratio exit flux / clear entrance pupil flux

EF_through(entrance_EF=1.0, wavelength=None, noFPM=False, EF_aberrations_introduced_in_LS=1.0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from the apodizer plane before the apodizer pupil to the Lyot plane after the Lyot pupil.

AUTHOR : Johan Mazoyer

03/22 : Correction in the babinet propagation

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]; or float

Can also be a float scalar in which case entrance_EF is constant; default=1. Electric field in the pupil plane at the entrance of the system.

wavelengthfloat

Current wavelength in m. Default is self.wavelength_0, the reference wavelength.

noFPMbool

If True, remove the FPM if one want to measure an un-obstructed PSF; default False.

EF_aberrations_introduced_in_LS2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electrical field created by the downstream aberrations introduced directly in the Lyot Stop. Can also be a float scalar in which case entrance_EF is constant; default=1.

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

Returns:
exit_EF2D array, of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electric field in the pupil plane at the exit of the system

FQPM()

Create a Four Quadrant Phase Mask coronagraph.

AUTHOR : Axel Potier Modified by Johan Mazoyer

Returns:
fqpmlist of len(self.wav_vec) 2D arrays

Complex transmission of the FQPM mask at all wavelengths.

Vortex(vortex_charge=2)

Create a vortex coronagraph with charge ‘vortex_charge’.

AUTHOR : Johan Mazoyer

Parameters:

vortex_charge (int, default 2) – Charge of the vortex. Usually a positive, even number (2, 4, 6). Default is charge 2.

Returns:
vortexlist of 2D numpy array

The complex FP mask at all wavelengths.

WrappedVortex(offset=0, cen_shift=(0, 0), inclination_x=0, inclination_y=0)

Create a wrapped vortex coronagraph.

Parameters:
offsetfloat

General offset to the whole ramp; default 0.

cen_shifttuple of floats

x- and y-shift of the center of the mask with respect to the center of the array in pixels, which is between pixels as long as ‘dim’ is even; default (0,0).

inclination_xfloat, default 0

Inclination of the phase mask around the x-axis in degrees.

inclination_yfloat, default 0

Inclination of the phase mask around the y-axis in degrees.

Returns:
wrapped_vortexlist of 2D numpy array

The complex FP masks at all wavelengths.

KnifeEdgeCoro()

Create a Knife edge coronagraph of size (dimScience,dimScience).

AUTHOR : Axel Potier Modified by Johan Mazoyer

Returns:
knife_allwllist of len(self.wav_vec) 2D arrays

Complex transmission of the knife-edge coronagraph mask at all wavelengths.

ClassicalLyot()

Create a classical Lyot coronagraph of radius rad_LyotFP.

AUTHOR : Johan Mazoyer

Returns:
ClassicalLyotFPM_allwllist of 2D numpy arrays

The FP masks at all wavelengths.

HLC()

Create an HLC of radius rad_LyotFP.

AUTHOR : Johan Mazoyer

Returns:
hlc_all_wllist of 2D numpy array

The FP masks at all wavelengths.

class Asterix.optics.DeformableMirror(modelconfig, DMconfig, Name_DM='DM3', Model_local_dir=None, silence=False)

Bases: OpticalSystem

Initialize and describe the behavior of a deformable mirror (in pupil plane or out of pupil plane) coronagraph is a sub class of OpticalSystem.

AUTHOR : Johan Mazoyer

Methods

EF_from_phase_and_ampl([phase_abb, ...])

Create an electrical field from an phase and amplitude aberrations as follows:

EF_through([entrance_EF, wavelength, ...])

Propagate the electric field through the DM.

add_photon_noise(focal_plane_intensity, ...)

Add photon noise to an image in contrast.

create_DM_basis([basis_type, silence])

Create a DM basis.

creatingpushact(DMconfig[, silence])

OPD map induced in the DM plane for each actuator.

generate_ampl_aberr(SIMUconfig[, ...])

Generate and save amplitude aberations.

generate_phase_aberr(SIMUconfig[, ...])

Generate and save phase aberrations.

id_in_pupil_actuators([silence])

Create a vector with the index of all the actuators located in the entrance pupil.

individual_normalizations([wavelengths])

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

measure_normalization()

Measure several values to normalize the data.

prop_pup_to_DM_and_back(entrance_EF, ...[, ...])

Propagate the field towards an out-of-pupil plane , add the DM phase, and propagate to the next pupil plane.

todetector([entrance_EF, wavelength, ...])

Propagate the electric field from entrance plane through the system and then to Science focal plane.

todetector_intensity([entrance_EF, ...])

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

transmission([noFPM])

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

voltage_to_phase(actu_vect[, einstein_sum])

Generate the phase applied on one DM for a give vector of actuator amplitude We decided to do it without matrix multiplication to save time because a lot of the time we have lot of zeros in it.

EF_through(entrance_EF=1.0, wavelength=None, DMphase=0.0, dir_save_all_planes=None, **kwargs)

Propagate the electric field through the DM. if z_DM = 0, then it’s just a phase multiplication if z_DM != 0, this is where we do the fresnel

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant)

Default is 1. Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

DMphase2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (DM_phase is constant), default is 0

Phase on DM CAREFUL !! If the DM is part of a testbed. this variable name is changed to DMXXphase (DMXX: name of the DM) to avoid confusion

dir_save_all_planesstring or None, default None

if not None, directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

Returns:
exit_EF2D array, of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electric field in the pupil plane a the exit of the system

EF_from_phase_and_ampl(phase_abb=0.0, ampl_abb=0.0, wavelengths=-1.0)

Create an electrical field from an phase and amplitude aberrations as follows:

EF = (1 + ample_abb)*exp(i*phase_abb * self.wavelength_0 / wavelength) can be monochromatic (return 2d compex array) or polychromatic (return 3d compex array) if no phase nor amplitude, return 1.

AUTHOR : Johan Mazoyer

Parameters:
phase_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Phase aberration at reference wavelength self.wavelength_0. if 0, no phase aberration (default)

ampl_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Amplitude aberration at reference wavelength self.wavelength_0. if 0, no amplitude aberration (default)

wavelengthsfloat or list of floats

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
EFscalar or numpy 2D array or numpy 3d array
Electric field in the pupil plane a the exit of the system:

1. if no phase / amplitude 2D array, of size phase_abb.shape if monochromatic or 3D array of size [self.nb_wav,phase_abb.shape] in case of polychromatic

add_photon_noise(focal_plane_intensity, nb_photons, in_contrast=True)

Add photon noise to an image in contrast.

This is only applied to images for which the normalization factors have been measured (for wavelength in self.wave_vec). You need to have measured the normalization previously (running self.measure_normalization). Making it separate allow us to run the propagation only once in cases where we want both the image with and without photon noise.

AUTHOR : Johan Mazoyer

Parameters:
  • focal_plane_intensity (numpy array of shape (self.dimScience,self.dimScience)) – the focal plane intensity, normalized in contrast

  • nb_photons (float) – Number of photons entering the pupil.

  • in_contrast (bool, default True.) – If True, the data are normalized in contrast

Returns:
focal_plane_intensitynumpy array of shape (self.dimScience,self.dimScience)

the focal plane intensity, with photon noise, normalized in contrast

creatingpushact(DMconfig, silence=False)

OPD map induced in the DM plane for each actuator.

This large array is initialized at the beginning and will be use to transorm a voltage into a phase for each DM. This is saved in .fits to save times if the parameter have not changed

In case of “misregistration = True” we measure it once for creating the interaction matrix and then once again, between the matrix measrueemnt and the correction with a small mismatch to simulate its effect.

AUTHOR : Axel Potier

Parameters:
DMconfigdict

DM configuration parameters dictionary

silenceboolean, default False.

Whether to silence print outputs.

Returns:
pushact3D numpy arrayof size [self.number_act, self.dim_overpad_pupil, self.dim_overpad_pupil]

DM OPD maps induced in the DM plane for each actuator.

generate_ampl_aberr(SIMUconfig, Model_local_dir=None, silence=False)

Generate and save amplitude aberations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

Parameter of this simualtion (describing the amplitude)

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse.

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_ampl2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Amplitude abberation

generate_phase_aberr(SIMUconfig, up_or_down='up', Model_local_dir=None, silence=False)

Generate and save phase aberrations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

parameter of this simualtion (describing the phase)

up_or_downstring, default, ‘up’

‘up’ or ‘do’, use to access the right parameters in the parameter file for upstream (entrance pupil) or downstream (Lyot plane) aberrations

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse. In this case the phase aberrations is saved if Model_local_dir is not None

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_phase2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

phase aberration at the reference wavelength

individual_normalizations(wavelengths=None)

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

AUTHOR : Johan Mazoyer

Parameters:
wavelengthsfloat or list of floats.

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
norm_polychromfloat

Maximum value of the PSF in polychrom light. Used to normalize to_detector_intensity().

sum_polychromfloat

Sum of the PSF in polychrom light. Used to normalize for photon noise.

norm_monochromnumpy array of the same length as wavelengths

Norm of PSFs at each wavelength. Can be used to individually normalize PSFs in monochromatic light.

sum_monochromnumpy array of the same length as wavelengths

Sum of PSFs at each wavelength. Not sure if useful at all but comes for free here.

measure_normalization()

Measure several values to normalize the data.

Function must be used at the end of all Optical Systems initalization.

Measure 3 values:
  • self.norm_monochrom. Array of size len(self.wav_vec)

    the PSF per WL, use to normalize to_detector

  • self.norm_polychrom. float

    the polychromatic PSF used to normalize to_detector_Intensity

  • self.normPupto1, which is used to measure the photon noise

    This is the factor that we use to measure photon noise. From an image in contrast, we now normalize by the total amount of energy (*self.norm_polychrom / self.sum_polychrom) and then account for the energy lost in the process (self.transmission()). Can be used as follow: Im_intensity_photons = Im_Intensity_contrast * self.normPupto1 * nb_photons

AUTHOR : Johan Mazoyer

todetector(entrance_EF=1.0, wavelength=None, center_on_pixel=False, in_contrast=True, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system and then to Science focal plane.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

in_contrastbool, default True

Normalize to np.sqrt(self.norm_monochrom[self.wav_vec.tolist().index(wavelength)])) (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EFor during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other kw parameters can be passed direclty to self.EF_through function

Returns:
ef_focal_plane2D array of size [self.dimScience, self.dimScience]

Electric field in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

todetector_intensity(entrance_EF=1.0, wavelengths=None, in_contrast=True, center_on_pixel=False, nb_photons=0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF3D complex array of size [nb_wav, self.dim_overpad_pupil, self.dim_overpad_pupil]

or 2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthsfloat or float array of wavelength in m.

Default is all wavelenthg in self.wav_vec

in_contrastbool, default True. normalize to

self.norm_polychrom (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EF or during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

nb_photonsfloat, optional, default 0

Number of photons entering the pupil. If 0, no photon noise.

**kwargs

Other kw parameters can be passed direclty to self.EF_through function

Returns:
focal_plane_intensity2D array of size [self.dimScience, self.dimScience]

Intensity in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

transmission(noFPM=True, **kwargs)

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

By default, transmission is done at the reference WL, and there is no reason to depend heavily on the WL.

AUTHOR : Johan Mazoyer

Parameters:
  • noFPM (bool, defaut True) – if the optical transfert function EF_through has a noFPM parameter

  • **kwargs – other kw parameters can be passed direclty to self.EF_through function

Returns:
transmissionfloat

ratio exit flux / clear entrance pupil flux

id_in_pupil_actuators(silence=False)

Create a vector with the index of all the actuators located in the entrance pupil.

AUTHOR: Johan Mazoyer

Returns:
WhichInPupil1D array

Index of all the actuators located inside the pupil.

silenceboolean, default False.

Whether to silence print outputs.

prop_pup_to_DM_and_back(entrance_EF, phase_DM, wavelength, dir_save_all_planes=None)

Propagate the field towards an out-of-pupil plane , add the DM phase, and propagate to the next pupil plane.

AUTHOR : Raphaël Galicher, Johan Mazoyer

REVISION HISTORY :

Revision 1.1 2021-02-10 Raphaël Galicher (Initial revision) Revision 2.0 2021-02-28 Johan Mazoyer (Make it more general for all DMs, put in the struc)

Parameters:
pupil_wavefront2D array (float, double or complex)

Wavefront in the pupil plane.

phase_DM2D array

Phase introduced by out of PP DM.

wavelengthfloat

Wavelength in m.

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

Returns:
EF_back_in_pup_plane2D array (complex)

Wavefront in the pupil plane following the DM

voltage_to_phase(actu_vect, einstein_sum=False)

Generate the phase applied on one DM for a give vector of actuator amplitude We decided to do it without matrix multiplication to save time because a lot of the time we have lot of zeros in it.

The phase is define at the reference wl and multiply by wl_ratio in DM.EF_through

AUTHOR: Johan Mazoyer

Parameters:
actu_vect1D array

Values of the amplitudes for each actuator.

einstein_sumboolean, default false

Use numpy Einstein sum to sum the pushact[i]*actu_vect[i] gives the same results as normal sum. Seems ot be faster for unique actuator but slower for more complex phases.

Returns:
DM_phase: 2D array

phase map in the same unit as actu_vect * DM_pushact.

create_DM_basis(basis_type='actuator', silence=False)

Create a DM basis. TODO do a zernike basis ?

AUTHOR: Johan Mazoyer

Parameters:
basis_typestring, default ‘actuator’

the type of basis. ‘fourier’ or ‘actuator’.

silenceboolean, default False.

Whether to silence print outputs.

Returns:
basis: 2d numpy array

Basis [Size basis, Number of active act in the DM].

class Asterix.optics.Testbed(list_os, list_os_names, silence=False)

Bases: OpticalSystem

Initialize and describe the behavior of a testbed. This is a particular subclass of Optical System, because we do not know what is inside It can only be initialized by giving a list of Optical Systems and it will create a “testbed” with contains all the Optical Systems and associated EF_through functions and correct normlaization.

AUTHOR : Johan Mazoyer

Methods

EF_from_phase_and_ampl([phase_abb, ...])

Create an electrical field from an phase and amplitude aberrations as follows:

EF_through([entrance_EF])

Propagate the electric field from entrance pupil to exit pupil.

add_photon_noise(focal_plane_intensity, ...)

Add photon noise to an image in contrast.

basis_vector_to_act_vector(vector_basis_voltage)

transform a vector of voltages on the mode of a basis in a vector of voltages of the actuators of the DMs of the system.

generate_ampl_aberr(SIMUconfig[, ...])

Generate and save amplitude aberations.

generate_phase_aberr(SIMUconfig[, ...])

Generate and save phase aberrations.

individual_normalizations([wavelengths])

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

measure_normalization()

Measure several values to normalize the data.

todetector([entrance_EF, wavelength, ...])

Propagate the electric field from entrance plane through the system and then to Science focal plane.

todetector_intensity([entrance_EF, ...])

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

transmission([noFPM])

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

voltage_to_phases(actu_vect[, einstein_sum])

Generate the phase applied on each DMs of the testbed from a given vector of actuator amplitude.

EF_through(entrance_EF=1.0, **kwargs)

Propagate the electric field from entrance pupil to exit pupil.

NEED TO BE DEFINED FOR ALL OpticalSystem subclasses

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other parameters can be passed for OpticalSystem objects EF_trough functions

Returns:
exit_EF2D array, of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Electric field in the pupil plane a the exit of the system

voltage_to_phases(actu_vect, einstein_sum=False)

Generate the phase applied on each DMs of the testbed from a given vector of actuator amplitude. I split theactu_vect and then for each DM, it uses DM.voltage_to_phase (no s)

AUTHOR : Johan Mazoyer

Parameters:
actu_vectfloat or 1D array of size testbed.number_act

Values of the amplitudes for each actuator and each DM.

einstein_sumboolean. default False

Use numpy Einstein sum to sum the pushact[i]*actu_vect[i] gives the same results as normal sum. Seems ot be faster for unique actuator but slower for more complex phases.

Returns:
phases3D array of size [testbed.number_DMs, testbed.dim_overpad_pupil,testbed.dim_overpad_pupil]

Phase maps for each DMs by order of light path in the same unit as actu_vect * DM_pushact.

basis_vector_to_act_vector(vector_basis_voltage)

transform a vector of voltages on the mode of a basis in a vector of voltages of the actuators of the DMs of the system.

AUTHOR : Johan Mazoyer

Parameters:
vector_basis_voltage1D-array real

Vector of voltages of size (total(basisDM sizes)) on the mode of the basis for all DMs by order of the light path.

Returns:
vector_actuator_voltage1D-array real

Vector of base coefficients for all actuators of the DMs by order of the light path size (total(DM actuators)).

EF_from_phase_and_ampl(phase_abb=0.0, ampl_abb=0.0, wavelengths=-1.0)

Create an electrical field from an phase and amplitude aberrations as follows:

EF = (1 + ample_abb)*exp(i*phase_abb * self.wavelength_0 / wavelength) can be monochromatic (return 2d compex array) or polychromatic (return 3d compex array) if no phase nor amplitude, return 1.

AUTHOR : Johan Mazoyer

Parameters:
phase_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Phase aberration at reference wavelength self.wavelength_0. if 0, no phase aberration (default)

ampl_abb2D array of size [self.dim_overpad_pupil, self.dim_overpad_pupil]. real

Amplitude aberration at reference wavelength self.wavelength_0. if 0, no amplitude aberration (default)

wavelengthsfloat or list of floats

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
EFscalar or numpy 2D array or numpy 3d array
Electric field in the pupil plane a the exit of the system:

1. if no phase / amplitude 2D array, of size phase_abb.shape if monochromatic or 3D array of size [self.nb_wav,phase_abb.shape] in case of polychromatic

add_photon_noise(focal_plane_intensity, nb_photons, in_contrast=True)

Add photon noise to an image in contrast.

This is only applied to images for which the normalization factors have been measured (for wavelength in self.wave_vec). You need to have measured the normalization previously (running self.measure_normalization). Making it separate allow us to run the propagation only once in cases where we want both the image with and without photon noise.

AUTHOR : Johan Mazoyer

Parameters:
  • focal_plane_intensity (numpy array of shape (self.dimScience,self.dimScience)) – the focal plane intensity, normalized in contrast

  • nb_photons (float) – Number of photons entering the pupil.

  • in_contrast (bool, default True.) – If True, the data are normalized in contrast

Returns:
focal_plane_intensitynumpy array of shape (self.dimScience,self.dimScience)

the focal plane intensity, with photon noise, normalized in contrast

generate_ampl_aberr(SIMUconfig, Model_local_dir=None, silence=False)

Generate and save amplitude aberations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

Parameter of this simualtion (describing the amplitude)

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse.

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_ampl2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

Amplitude abberation

generate_phase_aberr(SIMUconfig, up_or_down='up', Model_local_dir=None, silence=False)

Generate and save phase aberrations.

AUTHOR : Johan Mazoyer

Parameters:
SIMUconfigdict

parameter of this simualtion (describing the phase)

up_or_downstring, default, ‘up’

‘up’ or ‘do’, use to access the right parameters in the parameter file for upstream (entrance pupil) or downstream (Lyot plane) aberrations

Model_local_dirstring or None, default None

Directory output path for model-related files created on the file for later reuse. In this case the phase aberrations is saved if Model_local_dir is not None

silenceboolean, default False.

Whether to silence print outputs.

Returns
——–
return_phase2D array, real of size [self.dim_overpad_pupil, self.dim_overpad_pupil]

phase aberration at the reference wavelength

individual_normalizations(wavelengths=None)

For a given wavelength list, this function is used to measure the maximum and total energy for each wavelength and then for the whole bandwidth.

AUTHOR : Johan Mazoyer

Parameters:
wavelengthsfloat or list of floats.

Default is all the wl of the testbed self.wav_vec wavelengths in m.

Returns:
norm_polychromfloat

Maximum value of the PSF in polychrom light. Used to normalize to_detector_intensity().

sum_polychromfloat

Sum of the PSF in polychrom light. Used to normalize for photon noise.

norm_monochromnumpy array of the same length as wavelengths

Norm of PSFs at each wavelength. Can be used to individually normalize PSFs in monochromatic light.

sum_monochromnumpy array of the same length as wavelengths

Sum of PSFs at each wavelength. Not sure if useful at all but comes for free here.

measure_normalization()

Measure several values to normalize the data.

Function must be used at the end of all Optical Systems initalization.

Measure 3 values:
  • self.norm_monochrom. Array of size len(self.wav_vec)

    the PSF per WL, use to normalize to_detector

  • self.norm_polychrom. float

    the polychromatic PSF used to normalize to_detector_Intensity

  • self.normPupto1, which is used to measure the photon noise

    This is the factor that we use to measure photon noise. From an image in contrast, we now normalize by the total amount of energy (*self.norm_polychrom / self.sum_polychrom) and then account for the energy lost in the process (self.transmission()). Can be used as follow: Im_intensity_photons = Im_Intensity_contrast * self.normPupto1 * nb_photons

AUTHOR : Johan Mazoyer

todetector(entrance_EF=1.0, wavelength=None, center_on_pixel=False, in_contrast=True, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system and then to Science focal plane.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil], or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthfloat. Default is self.wavelength_0 the reference wavelength

Current wavelength in m.

in_contrastbool, default True

Normalize to np.sqrt(self.norm_monochrom[self.wav_vec.tolist().index(wavelength)])) (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EFor during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

**kwargs

other kw parameters can be passed direclty to self.EF_through function

Returns:
ef_focal_plane2D array of size [self.dimScience, self.dimScience]

Electric field in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

todetector_intensity(entrance_EF=1.0, wavelengths=None, in_contrast=True, center_on_pixel=False, nb_photons=0, dir_save_all_planes=None, **kwargs)

Propagate the electric field from entrance plane through the system, then to Science focal plane and measure intensity.

AUTHOR : Johan Mazoyer

Parameters:
entrance_EF3D complex array of size [nb_wav, self.dim_overpad_pupil, self.dim_overpad_pupil]

or 2D complex array of size [self.dim_overpad_pupil, self.dim_overpad_pupil] or complex/float scalar (entrance_EF is constant), default is 1.

Electric field in the pupil plane a the entrance of the system.

wavelengthsfloat or float array of wavelength in m.

Default is all wavelenthg in self.wav_vec

in_contrastbool, default True. normalize to

self.norm_polychrom (see self.measure_normalization)

center_on_pixelbool Default False

If True, the PSF will be centered on a pixel If False, the PSF will be centered between 4 pixels This of course assume that no tip-tilt have been introduced in the entrance_EF or during self.EF_through

dir_save_all_planesstring or None, default None

If not None, absolute directory to save all planes in fits for debugging purposes. This can generate a lot of fits especially if in a loop, use with caution.

nb_photonsfloat, optional, default 0

Number of photons entering the pupil. If 0, no photon noise.

**kwargs

Other kw parameters can be passed direclty to self.EF_through function

Returns:
focal_plane_intensity2D array of size [self.dimScience, self.dimScience]

Intensity in the focal plane. the lambda / D is defined with the entrance pupil diameter, such as: self.wavelength_0 / (2*self.prad) = self.Science_sampling pixels

transmission(noFPM=True, **kwargs)

Measure ratio of photons lost when crossing the system compared to a clear round aperture of radius self.prad.

By default, transmission is done at the reference WL, and there is no reason to depend heavily on the WL.

AUTHOR : Johan Mazoyer

Parameters:
  • noFPM (bool, defaut True) – if the optical transfert function EF_through has a noFPM parameter

  • **kwargs – other kw parameters can be passed direclty to self.EF_through function

Returns:
transmissionfloat

ratio exit flux / clear entrance pupil flux