Пример #1
0
    def __init__(
            self,
            wavelength=632.8e-9,    # wavelength in [m]
            aperture_radius=0.002,  # aperture radius in [m]
            focal_length=500e-3,    # focal length in [m]
            pixel_size=7.4e-6,      # pixel size in [m]
            image_width=75,         # [pixels], odd to get the origin as well
            image_height=151,       # [pixels]
            fspace=np.linspace(     # defocus planes specified by an array of
                -3.0, 2.0, 6),      # defocus parameters
            n_beta=4                # max radial order for the Zernikes
            ):

        # compute the diffraction unit (lambda/NA)
        fu = enz.get_field_unit(
            wavelength=wavelength,
            aperture_radius=aperture_radius,
            exit_pupil_sphere_radius=focal_length)

        def make_space(w, p, fu):
            if w % 2 == 0:
                return np.linspace(-(w/2 - 0.5), w/2 - 0.5, w)*p/fu
            else:
                return np.linspace(-(w - 1)/2, (w - 1)/2, w)*p/fu

        # image side space
        xspace = make_space(image_width, pixel_size, fu)
        yspace = make_space(image_height, pixel_size, fu)

        # consider complex-valued Zernike polynomials up to the radial order
        # n_beta to approximate the PSF, see Eq. (1) and Eq. (2) in [A2015]
        cpsf = CPsf(n_beta)

        # make a cartesian grid to evaluate the PSF
        t1 = time()
        cpsf.make_cart_grid(x_sp=xspace, y_sp=yspace, f_sp=fspace)
        t2 = time()
        print('make_cart_grid {:.6f} sec'.format(t2 - t1))

        self.xspace = xspace
        self.yspace = yspace
        self.fspace = fspace

        self.cpsf = cpsf
        self.image_size = (image_height, image_width)
Пример #2
0
    def __init__(
            self,
            wavelength=632.8e-9,    # wavelength in [m]
            aperture_radius=0.002,  # aperture radius in [m]
            focal_length=500e-3,    # focal length in [m]
            pixel_size=7.4e-6,      # pixel size in [m]
            image_width=75,         # [pixels], odd to get the origin as well
            image_height=151,       # [pixels]
            fspace=np.linspace(     # defocus planes specified by an array of
                -3.0, 2.0, 6),      # defocus parameters
            n_beta=4                # max radial order for the Zernikes
            ):

        # compute the diffraction unit (lambda/NA)
        fu = enz.get_field_unit(
            wavelength=wavelength,
            aperture_radius=aperture_radius,
            exit_pupil_sphere_radius=focal_length)

        def make_space(w, p, fu):
            if w % 2 == 0:
                return np.linspace(-(w/2 - 0.5), w/2 - 0.5, w)*p/fu
            else:
                return np.linspace(-(w - 1)/2, (w - 1)/2, w)*p/fu

        # image side space
        xspace = make_space(image_width, pixel_size, fu)
        yspace = make_space(image_height, pixel_size, fu)

        # consider complex-valued Zernike polynomials up to the radial order
        # n_beta to approximate the PSF, see Eq. (1) and Eq. (2) in [A2015]
        cpsf = CPsf(n_beta)

        # make a cartesian grid to evaluate the PSF
        t1 = time()
        cpsf.make_cart_grid(x_sp=xspace, y_sp=yspace, f_sp=fspace)
        t2 = time()
        print('make_cart_grid {:.6f} sec'.format(t2 - t1))

        self.xspace = xspace
        self.yspace = yspace
        self.fspace = fspace

        self.cpsf = cpsf
        self.image_size = (image_height, image_width)
Пример #3
0
    def make(
            self, wavelength, aperture_radius, focal_length, pixel_size,
            image_width, image_height,
            n_alpha, n_beta,
            fit_L, fit_K,
            focus_positions):

        self.wavelength = wavelength
        self.aperture_radius = aperture_radius
        self.focal_length = focal_length

        self.image_width = image_width
        self.image_height = image_height
        self.pixel_size = pixel_size

        self.n_alpha, self.n_beta = n_alpha, n_beta

        self.fit_L, self.fit_K = fit_L, fit_K

        self.focus_positions = np.array(focus_positions)

        fu = enz.get_field_unit(
            wavelength,
            aperture_radius, focal_length)

        def make_space(w, p, fu):
            if w % 2 == 0:
                return np.linspace(-(w/2 - 0.5), w/2 - 0.5, w)*p/fu
            else:
                return np.linspace(-(w - 1)/2, (w - 1)/2, w)*p/fu

        # image side space
        xspace = make_space(image_width, pixel_size, fu)
        yspace = make_space(image_height, pixel_size, fu)
        self.xspace, self.yspace = xspace, yspace

        # phase
        self.phase_grid = RZern(n_alpha)
        self.phase_fit = FitZern(self.phase_grid, self.fit_L, self.fit_K)
        print('phase: n_alpha = {}, N_alpha = {}'.format(
            self.n_alpha, self.phase_grid.nk))

        # complex psf
        self.cpsf = CPsf(n_beta)
        self.gpf_fit = FitZern(self.cpsf.czern, self.fit_L, self.fit_K)
        print('cpsf:  n_beta  = {}, N_beta  = {}, N_f = {}'.format(
            n_beta, self.cpsf.czern.nk, self.focus_positions.size))

        # make phase polar grid
        t1 = time.time()
        self.phase_grid.make_pol_grid(
            self.phase_fit.rho_j,
            self.phase_fit.theta_i)
        t2 = time.time()
        print('make phase pol grid {:.6f}'.format(t2 - t1))

        # make gpf polar grid (Zernike approximation)
        t1 = time.time()
        self.cpsf.czern.make_pol_grid(
            self.phase_fit.rho_j,
            self.phase_fit.theta_i)
        t2 = time.time()
        print('make gpf pol grid {:.6f}'.format(t2 - t1))

        # make cpsf cart grid
        t1 = time.time()
        self.cpsf.make_cart_grid(
            x_sp=xspace, y_sp=yspace, f_sp=focus_positions)
        t2 = time.time()
        print('make cpsf cart grid {:.6f}'.format(t2 - t1))
Пример #4
0
    def make(self, wavelength, aperture_radius, focal_length, pixel_size,
             image_width, image_height, n_alpha, n_beta, fit_L, fit_K,
             focus_positions):

        self.wavelength = wavelength
        self.aperture_radius = aperture_radius
        self.focal_length = focal_length

        self.image_width = image_width
        self.image_height = image_height
        self.pixel_size = pixel_size

        self.n_alpha, self.n_beta = n_alpha, n_beta

        self.fit_L, self.fit_K = fit_L, fit_K

        self.focus_positions = np.array(focus_positions)

        fu = enz.get_field_unit(wavelength, aperture_radius, focal_length)

        def make_space(w, p, fu):
            if w % 2 == 0:
                return np.linspace(-(w / 2 - 0.5), w / 2 - 0.5, w) * p / fu
            else:
                return np.linspace(-(w - 1) / 2, (w - 1) / 2, w) * p / fu

        # image side space
        xspace = make_space(image_width, pixel_size, fu)
        yspace = make_space(image_height, pixel_size, fu)
        self.xspace, self.yspace = xspace, yspace

        # phase
        self.phase_grid = RZern(n_alpha)
        self.phase_fit = FitZern(self.phase_grid, self.fit_L, self.fit_K)
        print('phase: n_alpha = {}, N_alpha = {}'.format(
            self.n_alpha, self.phase_grid.nk))

        # complex psf
        self.cpsf = CPsf(n_beta)
        self.gpf_fit = FitZern(self.cpsf.czern, self.fit_L, self.fit_K)
        print('cpsf:  n_beta  = {}, N_beta  = {}, N_f = {}'.format(
            n_beta, self.cpsf.czern.nk, self.focus_positions.size))

        # make phase polar grid
        t1 = time.time()
        self.phase_grid.make_pol_grid(self.phase_fit.rho_j,
                                      self.phase_fit.theta_i)
        t2 = time.time()
        print('make phase pol grid {:.6f}'.format(t2 - t1))

        # make gpf polar grid (Zernike approximation)
        t1 = time.time()
        self.cpsf.czern.make_pol_grid(self.phase_fit.rho_j,
                                      self.phase_fit.theta_i)
        t2 = time.time()
        print('make gpf pol grid {:.6f}'.format(t2 - t1))

        # make cpsf cart grid
        t1 = time.time()
        self.cpsf.make_cart_grid(x_sp=xspace,
                                 y_sp=yspace,
                                 f_sp=focus_positions)
        t2 = time.time()
        print('make cpsf cart grid {:.6f}'.format(t2 - t1))