In [ ]:
%matplotlib inline

load the modules

(if you are using astropy verion older than 1.0.5, below you may see a warning about IPython.kernel being deprecated. See https://github.com/astropy/astropy/pull/4078 )


In [ ]:
from lsst.cwfs.instrument import Instrument
from lsst.cwfs.algorithm import Algorithm
from lsst.cwfs.image import readFile, Image
import lsst.cwfs.plots as plots

Define the image objects. Input arguments: file name, field coordinates in deg, image type


In [ ]:
fieldXY = [1.185,1.185]
im1 = readFile('../tests/testImages/LSST_NE_SN25/z11_0.25_intra.txt')
I1 = Image(im1, fieldXY, Image.INTRA)

im2 = readFile('../tests/testImages/LSST_NE_SN25/z11_0.25_extra.txt')
I2 = Image(im2, fieldXY, Image.EXTRA)

Define the instrument. Input arguments: instrument name, size of image stamps


In [ ]:
inst=Instrument('lsst',I1.sizeinPix)

Run everything automatically, and print the Zernikes


In [ ]:
algo=Algorithm('exp',inst,1)
algo.runIt(inst,I1,I2,'offAxis')
print(algo.zer4UpNm)

Now we decide to chang the base algorithm from 'exp' to 'fft', and step through the iterations manually


In [ ]:
algo=Algorithm('fft',inst,3)
algo.itr0(inst,I1,I2,'offAxis')

Look at the wavefront signal image


In [ ]:
plots.plotImage(algo.S,'wavefront signal')

Do 2 more iterations


In [ ]:
algo.nextItr(inst,I1,I2,'offAxis')
plots.plotImage(algo.S,'wavefront signal')
algo.nextItr(inst,I1,I2,'offAxis')
plots.plotImage(algo.S,'wavefront signal')

continue, and finish the rest of the 14 iterations. Check the wavefront signal image at the end


In [ ]:
algo.runIt(inst,I1,I2,'offAxis')
plots.plotImage(algo.S,'wavefront signal')

switch back to the 'exp' algorithm


In [ ]:
algo=Algorithm('exp',inst,1)

run one iteration manually


In [ ]:
algo.nextItr(inst,I1,I2,'offAxis')
print('Current Iteration No = %d'%algo.currentItr)

change debug level and run 2 more iterations


In [ ]:
algo.setDebugLevel(3)
algo.nextItr(inst,I1,I2,'offAxis',2)

finish the rest of the 14 iterations


In [ ]:
algo.runIt(inst,I1,I2,'offAxis')

If you want to keep iterating, we will be using the parameters from the Iter No. algo.outerItr


In [ ]:
print(algo.outerItr)
print(algo.debugLevel)
algo.nextItr(inst,I1,I2,'offAxis',2)

plot the Zernikes Zn (n>=4)


In [ ]:
algo.setDebugLevel(0)
plots.plotZer(algo.zer4UpNm,'nm')