WF Estimation

class Asterix.wfsc.estimator.Estimator(Estimationconfig, testbed: Testbed, matrix_dir='', save_for_bench=False, realtestbed_dir='', silence=False)

Bases: object

Estimator Class allows you to define a WF estimator.

It must contains 2 functions at least:
  • an initialization (e.g. PWP matrix) Estimator.__init__(), with parameters:
    • the testbed structure

    • the estimation parameters

    • saving directories

    The estimator initialization requires previous initialization of the testbed.

  • an probe function Estimator.probe(), with parameters:
    • the entrance EF

    • DM voltages

    • the estimation wavelengths

    It returns the probed images as a list (of length nb_wav_estim) of 3d arrays (nprobes,dimEstim,dimEstim). For perfect estimation, it resturns the electrical field.

  • an estimation function Estimator.estimate(), with parameters:
    • the probed images

    It returns the estimation as a list (of length nb_wav_estim) of 2D arrays (dimEstim,dimEstim). In all generality, it can be pupil or focal plane, complex or real with keywords (Estim.is_focal_plane = True, Estim.is_complex = True) to explain the form of the output and potentially prevent wrongfull combination of estim + correc.

AUTHOR : Johan Mazoyer

Methods

estimate(probed_fp_images[, ...])

Run an estimation from a testbed, with a given input the probed images.

probe(testbed[, entrance_EF, ...])

Use the DM or the testbed to probe the aberrations with a given input wavefront and a state of the DMs.

probe(testbed: Testbed, entrance_EF=1.0, voltage_vector=0.0, perfect_estimation=False, **kwargs)

Use the DM or the testbed to probe the aberrations with a given input wavefront and a state of the DMs.

AUTHOR : Johan Mazoyer

Parameters:
testbedOpticalSystem.Testbed

Testbed object which describe your testbed

entrance_EFcomplex float or 2D array, default 1.

initial EF field

voltage_vector1D float array

vector of voltages vectors for each DMs

perfect_estimationbool, default = False

if true This is equivalent to have self.technique = “perfect” but even if we are using another technique, we sometimes need a perfect estimation and it avoid re-initialization of the estimation.

Returns:
probed_fp_imageslist of 3D arrays

Probed images for each wavelengths. Each arrays are of size of sixe [2*nprobes, dimEstim, dimEstim] if PWP or [1 + nprobes, dimEstim, dimEstim] if BTP.

estimate(probed_fp_images, perfect_estimation=False, dtype_complex='complex128', testbed=None, **kwargs)

Run an estimation from a testbed, with a given input the probed images. For some estimation algorithms (btp) we need to use a model of the testbed.

AUTHOR : Johan Mazoyer

Parameters:
probed_fp_imageslist of 3D arrays

Probed images for each probes. Each arrays are of size of sixe [2*nprobes, dimEstim, dimEstim] if PWP or [1 + nprobes, dimEstim, dimEstim] if BTP.

perfect_estimationbool, default = False

if true This is equivalent to have self.technique = “perfect” but even if we are using another technique, we sometimes need a perfect estimation and it avoid re-initialization of the estimation.

dtype_complexstring, default ‘complex128’

bit number for the complex arrays in the PW matrices. Can be ‘complex128’ or ‘complex64’. The latter increases the speed of the mft but at the cost of lower precision.

testbedtestbed object, default = None

testbed object for btp which requires a testbed model.

Returns:
estimationlist of 2D array

list is the number of wl in the estimation, usually 1 or testbed.nb_wav Each arrays are of size of sixe [dimEstim, dimEstim]. estimation of the Electrical field

Asterix.wfsc.wf_sensing_functions.create_pw_matrix(testbed: Testbed, voltage_probes, dimEstim, cutsvd, matrix_dir, wav_vec_estim=None, silence=False, **kwargs)

Build the nbwl times interaction matrix for pair-wise probing.

AUTHOR : Johan Mazoyer

Sept 2022 : created

Parameters:
testbedTestbed Optical_element

a testbed with one or more DM

amplitudefloat

amplitude of the actuator pokes for pair(wise probing in nm

voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

dimEstimint

size of the output image after resizing in pixels

cutsvdfloat

value not to exceed for the inverse eigeinvalues at each pixels

matrix_dirstring

path to directory to save all the matrices here

wav_vec_estimlist of float, default None

list of wavelengths to do the estimations.

silenceboolean, default False.

Whether to silence print outputs.

Returns:
PWVectorlist of 2D array

vector probe to be multiplied by the image difference matrix in order to retrieve the focal plane electric field

Asterix.wfsc.wf_sensing_functions.create_singlewl_pw_matrix(testbed: Testbed, voltage_probes, dimEstim, cutsvd, matrix_dir, wavelength, silence=False, **kwargs)

Build the interaction matrix for pair-wise probing at 1 WL.

AUTHOR : Axel Potier Modified by Johan Mazoyer

Sept 2022 : .fits file saving directly in the function to clean up estimator

Parameters:
testbedTestbed Optical_element

a testbed with one or more DM

amplitudefloat

amplitude of the actuator pokes for pair(wise probing in nm

voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

dimEstimint

size of the output image after resizing in pixels

cutsvdfloat

value not to exceed for the inverse eigeinvalues at each pixels

matrix_dirstring

path to directory to save all the matrices here

wavelengthfloat

wavelength in m.

silenceboolean, default False.

Whether to silence print outputs.

Returns:
PWVector2D array

vector probe to be multiplied by the image difference matrix in order to retrieve the focal plane electric field

Asterix.wfsc.wf_sensing_functions.name_header_pwp_matrix(testbed: Testbed, dimEstim, voltage_probes, cutsvd, wavelength, matrix_dir)

Create the name of the file and header of the PW matrix that will be used to identify precisely parameter used in the calcul of this matrix and recalculate if need be. We then load a potential matrix and compare the header to the one existing.

AUTHOR : Johan Mazoyer

Parameters:
testbedTestbed Optical_element

a testbed with one or more DM

voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

cutsvdfloat

value not to exceed for the inverse eigeinvalues at each pixels

dimEstimint

size of the output image after resizing in pixels

wavelengthfloat

wavelength in m.

matrix_dirstring

path to directory to save all the matrices.

Returns:
filePWstring

file name of the pw/btp matrix. If there is no identical matrix already measured in fits file, None.

headerfits.Header() Object

header of the pw/btp matrix

bool_already_existing_matrix :bool

If there is no identical matrix already saved in fits file.

Asterix.wfsc.wf_sensing_functions.calculate_pw_estimate(Difference, Vectorprobes, dimimages, dir_save_all_planes=None, pwp_or_btp='pwp', dtype_complex='complex128')

Calculate the focal plane electric field from the probe image differences and the modeled probe matrix.

AUTHOR : Axel Potier

Parameters:
Difference3D array

Cube with image difference for each probes.

Vectorprobes2D array

Model probe matrix for the same probe as for difference.

dimimagesint

Size of the output image after resizing in pixels.

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.

pwp_or_btpstring, default ‘pwp’
type of algorithm used, can be

‘pw’ Pair Wise Probing ‘btp’ Borde Traub Probing where the probe is pushed positevely

dtype_complexstring, default ‘complex128’

bit number for the complex arrays in the PWP matrices. Can be ‘complex128’ or ‘complex64’. The latter increases the speed of the mft but at the cost of lower precision.

Returns:
EF_field2D array

PWP estimation of the electrical field in the focal plane.

Asterix.wfsc.wf_sensing_functions.generate_actu_probe_voltages(testbed: Testbed, posprobes, amplitudePW, name_DM_to_probe_in_PW)

Generate the DM commands for each actuator probes.

Parameters:
testbedTestbed Optical_element

Testbed with one or more DM.

posprobes1D-array

list of index of the number actuators probes.

amplitudePWfloat

PWP probes amplitude in nm.

Returns:
voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

Asterix.wfsc.wf_sensing_functions.simulate_pw_probes(input_wavefront, testbed: Testbed, voltage_probes, voltage_vector=0.0, wavelengths=None, pwp_or_btp='pwp', **kwargs)

Simulate the acquisition of probe images using Pair-wise.

Parameters:
input_wavefrontcomplex scalar or 2d complex array or 3d complex array, default is 1 (flat WF)

Input wavefront in pupil plane.

testbedTestbed Optical_element

Testbed with one or more DM.

voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

voltage_vector1D float array or float, default 0

Vector of voltages vectors for each DMs arounf which we do the difference.

wavelengthsfloat or list of floats, default None

Wavelengths of the probes in m.

pwp_or_btpstring, default ‘pwp’
type of algorithm used, can be

‘pw’ Pair Wise Probing ‘btp’ Borde Traub Probing where the probe is pushed positevely

Returns:
Probed_images3D array

Cube with all probed images. Use for pair-wise probing.

Asterix.wfsc.wf_sensing_functions.btp_difference(Probed_images, testbed: Testbed, voltage_probes, wavelengths=None)

make the difference [I(+probe) - I(0) - psi_k_model] for borde and traub probing.

Parameters:
testbedTestbed Optical_element

Testbed with one or more DM.

voltage_probes2D float array of size [len(posprobes), testbed.number_actuators]

Array of voltages vectors for each probes

voltage_vector1D float array or float, default 0

Vector of voltages vectors for each DMs arounf which we do the difference.

wavelengthsfloat, default None

Wavelength of the estimation in m.

Returns:
Difference3D array

Cube with image difference for each probes. Use for pair-wise probing.

Asterix.wfsc.wf_sensing_functions.pw_difference(Probed_images)

Calculate the difference of images [I(+probe) - I(-probe)]

Parameters:
Probed_images
Returns:
Difference3D array

Cube with image difference for each probes. Use for pair-wise probing.