Beispiel #1
0
    def execute(self, field):
        if any(field.shape != self.tile.shape):
            raise AttributeError("Field passed to PSF incorrect shape")

        if not np.iscomplex(field.ravel()[0]):
            infield = fft.fftn(field, **fftkwargs)
        else:
            infield = field

        return np.real(fft.ifftn(infield * self.kpsf, **fftkwargs))
Beispiel #2
0
    def __call__(self, field):
        """
        Accept a field, apply the point-spread-function, and return
        the resulting image of a blurred field
        """
        # in order to avoid translations from the psf, we must create
        # real-space vectors that are zero in the corner and go positive
        # in one direction and negative on the other side of the image
        tile = peri.util.Tile(field.shape)
        rx, ry = tile.kvectors(norm=1.0 / tile.shape)

        # get the sigmas from ourselves
        sx, sy = self.values

        # calculate the real-space psf from the r-vectors and sigmas
        # normalize based on the calculated values, no the usual normalization
        psf = np.exp(-((rx / sx)**2 + (ry / sy)**2) / 2)
        psf = psf / psf.sum()
        self.psf = psf

        # perform the convolution with ffts and return the result
        out = fft.fftn(fft.ifftn(field) * fft.ifftn(psf))
        return fftnorm(np.real(out))
Beispiel #3
0
    def execute(self, field):
        if any(field.shape != self.tile.shape):
            raise AttributeError("Field passed to PSF incorrect shape")

        if not np.iscomplex(field.ravel()[0]):
            infield = fft.fftn(field, **fftkwargs)
        else:
            infield = field

        outfield = np.zeros_like(infield, dtype='float')

        for i in range(field.shape[0]):
            z = int(self.tile.l[0] + i)
            kpsf = self._pad(self.array[z])
            outfield[i] = np.real(fft.ifftn(infield * kpsf, **fftkwargs))[i]

        return outfield