def __init__(self,inFoc,outFoc,deltaZ,lbda,pxsize,F,pupilRadius,jmax): print 'phaseDiversity ...' #PSF self.inFoc = inFoc self.outFoc = outFoc shapeinFoc = np.shape(self.inFoc) shapeoutFoc = np.shape(self.outFoc) if shapeinFoc == shapeoutFoc: self.shape = shapeinFoc else: raise myExceptions.PSFssizeError('the shape of the in/out PSFs is not the same',[shapeinFoc,shapeoutFoc]) if shapeinFoc[0]==shapeinFoc[1] and np.mod(shapeinFoc[0],2)==0: self.N = shapeinFoc[0] else: raise myExceptions.PSFssizeError('Either PSF is not square or mod(N,2) != 0',shapeinFoc) # properties self.deltaZ = deltaZ self.lbda = lbda self.pxsize = pxsize self.F = F self.pupilRadius = pupilRadius self.dxp = self.F*self.lbda/(self.N*self.pxsize) self.rad = int(np.ceil(self.pupilRadius/self.dxp)) if 2*self.rad > self.N/2.: raise myExceptions.PupilSizeError('Npupil (2*rad) is bigger than N/2 which is not correct for the fft computation',[]) self.NyquistCriterion() self.jmax = jmax self.oddjs = fs.getOddJs(4,self.jmax) self.evenjs = fs.getEvenJs(4,self.jmax) # result computation self.result = self.retrievePhase()
def __init__(self, inFoc, outFocpos, outFocneg, deltaZ, lbda, pxsize, F, pupilRadius, jmin, jmax): # # input: # inFoc,outFocpos,outFocneg are the 3 squared PSFs data, (focused, defocused positiv and defocused negative) # deltaZ is the displacement of the detector to acquire the two defocused PSFs # lbda is the wavelength of the incoming light # pxsize is the pixel size of the detector # F is the focal length of the imaging system # pupilRadius is the radius of the exit pupil # jmin and jmax gives the boundary on the js to retrieve print 'phaseDiversity ...' #PSF self.inFoc = inFoc self.outFocpos = outFocpos self.outFocneg = outFocneg shapeinFoc = np.shape(self.inFoc) shapeoutFocpos = np.shape(self.outFocpos) shapeoutFocneg = np.shape(self.outFocneg) if shapeinFoc == shapeoutFocpos and shapeinFoc == shapeoutFocneg: self.shape = shapeinFoc else: raise myExceptions.PSFssizeError( 'the shape of the in/out PSFs is not the same', [shapeinFoc, shapeoutFocpos]) if shapeinFoc[0] == shapeinFoc[1] and np.mod(shapeinFoc[0], 2) == 0: self.N = shapeinFoc[0] else: raise myExceptions.PSFssizeError( 'Either PSF is not square or mod(N,2) != 0', shapeinFoc) # properties self.deltaZ = deltaZ self.lbda = lbda self.pxsize = pxsize self.F = F self.pupilRadius = pupilRadius self.dxp = self.F * self.lbda / (self.N * self.pxsize) self.rad = int(np.ceil(self.pupilRadius / self.dxp)) if 2 * self.rad > self.N / 2.: raise myExceptions.PupilSizeError( 'Npupil (2*rad) is bigger than N/2 which is not correct for the fft computation', []) self.NyquistCriterion() self.jmin = jmin self.jmax = jmax self.oddjs = fs.getOddJs(self.jmin, self.jmax) self.evenjs = fs.getEvenJs(self.jmin, self.jmax) # result computation self.result = self.retrievePhase()
if 4 not in jswth4: jswth4 = np.append(4, jspresent) ajswtha4 = np.append(a4dephasing, ajspresent) else: ajswtha4[jswth4 == 4] += a4dephasing PSFinfoc = psf.PSF(jspresent, ajspresent, N, dxp, pupilRadius) PSFoutfoc = psf.PSF(jswth4, ajswtha4, N, dxp, pupilRadius) PSFoutfocPerf = psf.PSF([4], [a4dephasing], N, dxp, pupilRadius) deltaPSFinFoc = PSFinfoc.Sp**2 * PSFinfoc.PSF - PSFinfoc.Sp**2 * PSFinfoc.perfectPSF deltaPSFoutFoc = PSFoutfoc.Sp**2 * PSFoutfoc.PSF - PSFoutfocPerf.Sp**2 * PSFoutfocPerf.PSF oddjs = fs.getOddJs(1, jmax) ajsodd = .0 * oddjs ajsodd[oddjs == 7] = 10e-9 / lbda * 2 * np.pi f2j = fs.f2j(j, N, oddjs, ajsodd, deltaphi, dxp, pupilRadius) y2 = (fs.y2(deltaPSFoutFoc, N, oddjs, ajsodd, deltaphi, dxp, pupilRadius)).reshape([400, 400]) oddDeltaPSF = fs.getOddPart(deltaPSFoutFoc) oddPhasor = ph.phasor(oddjs, ajsodd, N, dxp, pupilRadius) oddPhase = oddPhasor.phase pupilSin = oddPhasor.pupil * np.sin(deltaphi) pupilCos = oddPhasor.pupil * np.cos(deltaphi) FFTPupilSin = fs.scaledfft2(pupilSin, dxp) FFTPupilCos = fs.scaledfft2(pupilCos, dxp)
lbda = 0.6375e-6 F = 80e-3 pxsize = 5.3e-6 N = 400 dxp = lbda * F / (N * pxsize) deltaZ = 3.19e-3 jmin = 4 jmax = 30 rmsWFerror = 20. noiseStdLevels = [1e-3, 2e-3, 5e-3, 1e-2, 2e-2, 5e-2] PSFinfoc = psf.PSF([1], [0], N, dxp, pupilRadius) jmin = 4 jmax = 30 oddjs = fs.getOddJs(jmin, jmax) evenjs = fs.getEvenJs(jmin, jmax) A1 = np.zeros((N**2, len(oddjs))) for ij in np.arange(len(oddjs)): phiJ = fs.f1j(oddjs[ij], N, dxp, pupilRadius) A1[:, ij] = phiJ M1 = np.linalg.pinv(A1) stdErrorOddsAjs = np.sqrt(np.sum(M1**2, 1)) deltaphi = fs.deltaPhi(N, deltaZ, F, 2 * pupilRadius, lbda, dxp) A2 = np.zeros((N**2, len(evenjs))) for ij in np.arange(len(evenjs)): phiJ = fs.f2jeven(evenjs[ij], N, deltaphi, dxp, pupilRadius) A2[:, ij] = phiJ M2 = np.linalg.pinv(A2)