Algorithm

class lsst.ts.wep.cwfs.Algorithm(algoDir)

Bases: object

Initialize the Algorithm class.

Algorithm used to solve the transport of intensity equation to get normal/ annular Zernike polynomials.

Parameters:
algoDirstr

Algorithm configuration directory.

Methods Summary

config(algoName, inst[, debugLevel])

Configure the algorithm to solve TIE.

getBoundaryThickness()

Get the boundary thickness that the computation mask extends beyond the pupil mask.

getCompSequence()

Get the compensated sequence of Zernike order for each iteration.

getCompensatorMode()

Get the method name to compensate the wavefront by wavefront error.

getDebugLevel()

Get the debug level.

getFeedbackGain()

Get the gain value used in the outer loop iteration.

getFftDimension()

Get the FFT pad dimension in pixel.

getHistory()

Get the algorithm history.

getMaskScalingFactor()

Get the mask scaling factor for fast beam.

getNumOfInnerItr()

Get the number of inner loop iteration.

getNumOfOuterItr()

Get the number of outer loop iteration.

getNumOfZernikes()

Get the maximum number of Zernike polynomials supported.

getObsOfZernikes()

Get the obscuration of annular Zernike polynomials.

getOffAxisPolyOrder()

Get the number of polynomial order supported in off-axis correction.

getPoissonSolverName()

Get the method name to solve the Poisson equation.

getSignalClipSequence()

Get the signal clip sequence.

getWavefrontMapEsti()

Get the estimated wavefront map.

getWavefrontMapResidual()

Get the residual wavefront map.

getZer4UpInNm()

Get the coefficients of Zernike polynomials of z4-zn in nm.

getZernikeTerms()

Get the Zernike terms in using.

itr0(I1, I2, model)

Calculate the wavefront and coefficients of normal/ annular Zernike polynomials in the first iteration time.

nextItr(I1, I2, model[, nItr])

Run the outer loop iteration with the specific time defined in nItr.

outZer4Up([unit, filename, showPlot])

Put the coefficients of normal/ annular Zernike polynomials on terminal or file and show the image if it is needed.

reset()

Reset the calculation for the new input images with the same algorithm settings.

runIt(I1, I2, model[, tol])

Calculate the wavefront error by solving the transport of intensity equation (TIE).

setDebugLevel(debugLevel)

Set the debug level.

Methods Documentation

config(algoName, inst, debugLevel=0)

Configure the algorithm to solve TIE.

Parameters:
algoNamestr

Algorithm configuration file to solve the Poisson’s equation in the transport of intensity equation (TIE). It can be “fft” or “exp” here.

instInstrument

Instrument to use.

debugLevelint, optional

Show the information under the running. If the value is higher, the information shows more. It can be 0, 1, 2, or 3. (the default is 0.)

getBoundaryThickness()

Get the boundary thickness that the computation mask extends beyond the pupil mask.

It is noted that in Fast Fourier transform (FFT) algorithm, it is also the width of Neumann boundary where the derivative of the wavefront is set to zero

Returns:
int

Boundary thickness.

getCompSequence()

Get the compensated sequence of Zernike order for each iteration.

Returns:
numpy.ndarray[int]

Compensated sequence of Zernike order for each iteration.

getCompensatorMode()

Get the method name to compensate the wavefront by wavefront error.

Returns:
str

Method name to compensate the wavefront by wavefront error.

getDebugLevel()

Get the debug level.

If the value is higher, the information shows more. It can be 0, 1, 2, or 3.

Returns:
int

Debug level.

getFeedbackGain()

Get the gain value used in the outer loop iteration.

Returns:
float

Gain value used in the outer loop iteration.

getFftDimension()

Get the FFT pad dimension in pixel.

This is for the fast Fourier transform (FFT) solver only.

Returns:
int

FFT pad dimension.

getHistory()

Get the algorithm history.

Returns:
dict

Algorithm history.

Notes

The algorithm history is a dictionary that contains an entry for each iteration of the outer-loop, beginning with history[0].

The entry for each outer-loop iteration is itself a dictionary, containing the following keys:

  • initI1 - the initial I1 image

  • initI2 - the initial I2 image

  • compZk - the zernikes used for image compensation (units: nm)

  • compI1 - the compensated I1 image

  • compI2 - the compensated I2 image

  • pupilMask - pupil mask that is applied before zernike calculation

  • maskedI1 - the masked version of the compensated I1

  • maskedI2 - the masked version of the compensated I2

  • residZk - the estimated residual zernikes (units: nm)

  • residWf - the estimated residual wavefront (units: nm)

  • totZk - the current best estimate of the zernikes (units: nm)

  • totWf - the current best estimate of the wavefront (units: nm)

  • caustic - whether this iteration encountered a caustic

  • converged - whether the zernikes have converged

Further, if you are running the FFT algorithm, there is an inner-loop history saved under the key “innerLoop”. The inner-loop history is itself a dictionary that contains an entry for every iteration of the inner-loop. The entry for each iteration of the inner-loop is another dictionary, containing the following keys:

  • initS - the initial “signal”

  • FFT - the Fast Fourier transform of initS

  • estWf - the estimated wavefront

  • estS - the estimated signal

So for example, if you want to get the estimated signal from the 3rd step of the innerloop during the 2nd step of the outer loop, you would do the following: history = algorithm.getHistory() signal = history[1][“innerLoop”][2][“estS”]

getMaskScalingFactor()

Get the mask scaling factor for fast beam.

Returns:
float

Mask scaling factor for fast beam.

getNumOfInnerItr()

Get the number of inner loop iteration.

This is for the fast Fourier transform (FFT) solver only.

Returns:
int

Number of inner loop iteration.

getNumOfOuterItr()

Get the number of outer loop iteration.

Returns:
int

Number of outer loop iteration.

getNumOfZernikes()

Get the maximum number of Zernike polynomials supported.

Returns:
int

Maximum number of Zernike polynomials supported.

getObsOfZernikes()

Get the obscuration of annular Zernike polynomials.

Returns:
float

Obscuration of annular Zernike polynomials

getOffAxisPolyOrder()

Get the number of polynomial order supported in off-axis correction.

Returns:
int

Number of polynomial order supported in off-axis correction.

getPoissonSolverName()

Get the method name to solve the Poisson equation.

Returns:
str

Method name to solve the Poisson equation.

getSignalClipSequence()

Get the signal clip sequence.

The number of values should be the number of compensation plus 1. This is for the fast Fourier transform (FFT) solver only.

Returns:
numpy.ndarray

Signal clip sequence.

getWavefrontMapEsti()

Get the estimated wavefront map.

Returns:
numpy.ndarray

Estimated wavefront map.

getWavefrontMapResidual()

Get the residual wavefront map.

Returns:
numpy.ndarray

Residual wavefront map.

getZer4UpInNm()

Get the coefficients of Zernike polynomials of z4-zn in nm.

Returns:
numpy.ndarray

Zernike polynomials of z4-zn in nm.

getZernikeTerms()

Get the Zernike terms in using.

Returns:
list[int]

Zernike terms in using.

itr0(I1, I2, model)

Calculate the wavefront and coefficients of normal/ annular Zernike polynomials in the first iteration time.

Parameters:
I1CompensableImage

Intra- or extra-focal image.

I2CompensableImage

Intra- or extra-focal image.

modelstr

Optical model. It can be “paraxial”, “onAxis”, or “offAxis”.

nextItr(I1, I2, model, nItr=1)

Run the outer loop iteration with the specific time defined in nItr.

Parameters:
I1CompensableImage

Intra- or extra-focal image.

I2CompensableImage

Intra- or extra-focal image.

modelstr

Optical model. It can be “paraxial”, “onAxis”, or “offAxis”.

nItrint, optional

Outer loop iteration time. (the default is 1.)

outZer4Up(unit='nm', filename=None, showPlot=False)

Put the coefficients of normal/ annular Zernike polynomials on terminal or file and show the image if it is needed.

Parameters:
unitstr, optional

Unit of the coefficients of normal/ annular Zernike polynomials. It can be m, nm, or um. (the default is “nm”.)

filenamestr, optional

Name of output file. (the default is None.)

showPlotbool, optional

Decide to show the plot or not. (the default is False.)

reset()

Reset the calculation for the new input images with the same algorithm settings.

runIt(I1, I2, model, tol=0.001)

Calculate the wavefront error by solving the transport of intensity equation (TIE).

The inner (for fft algorithm) and outer loops are used. The inner loop is to solve the Poisson’s equation. The outer loop is to compensate the intra- and extra-focal images to mitigate the calculation of wavefront (e.g. S = -1/(delta Z) * (I1 - I2)/ (I1 + I2)).

Parameters:
I1CompensableImage

Intra- or extra-focal image.

I2CompensableImage

Intra- or extra-focal image.

modelstr

Optical model. It can be “paraxial”, “onAxis”, or “offAxis”.

tolfloat, optional

Tolerance of difference of coefficients of Zk polynomials compared with the previous iteration of outer loop. (the default is 1e-3.)

Raises:
ValueError

Check the that we have an intra- and extra-focal image.

setDebugLevel(debugLevel)

Set the debug level.

If the value is higher, the information shows more. It can be 0, 1, 2, or 3.

Parameters:
debugLevelint

Show the information under the running.