def _resample_residual(self, star, epsf):
        """
        Compute a normalized residual image in the oversampled ePSF
        grid.

        A normalized residual image is calculated by subtracting the
        normalized ePSF model from the normalized star at the location
        of the star in the undersampled grid.  The normalized residual
        image is then resampled from the undersampled star grid to the
        oversampled ePSF grid.

        Parameters
        ----------
        star : `EPSFStar` object
            A single star object.

        epsf : `EPSFModel` object
            The ePSF model.

        Returns
        -------
        image : 2D `~numpy.ndarray`
            A 2D image containing the resampled residual image.  The
            image contains NaNs where there is no data.
        """

        # find the integer index of EPSFStar pixels in the oversampled
        # ePSF grid
        x = epsf._oversampling[0] * star._xidx_centered
        y = epsf._oversampling[1] * star._yidx_centered
        epsf_xcenter, epsf_ycenter = epsf.origin
        xidx = _py2intround(x + epsf_xcenter)
        yidx = _py2intround(y + epsf_ycenter)

        mask = np.logical_and(np.logical_and(xidx >= 0, xidx < epsf.shape[1]),
                              np.logical_and(yidx >= 0, yidx < epsf.shape[0]))
        xidx = xidx[mask]
        yidx = yidx[mask]

        # Compute the normalized residual image by subtracting the
        # normalized ePSF model from the normalized star at the location
        # of the star in the undersampled grid.  Then, resample the
        # normalized residual image in the oversampled ePSF grid.
        # [(star - (epsf * xov * yov)) / (xov * yov)]
        # --> [(star / (xov * yov)) - epsf]
        stardata = ((star._data_values_normalized / np.prod(epsf._oversampling)) -
                    epsf.evaluate(x=x, y=y, flux=1.0, x_0=0.0, y_0=0.0,
                                  use_oversampling=False))

        resampled_img = np.full(epsf.shape, np.nan)
        resampled_img[yidx, xidx] = stardata[mask]

        return resampled_img
Compute a normalized residual image in the oversampled ePSF
        grid.

        A normalized residual image is calculated by subtracting the
        normalized ePSF model from the normalized star at the location
        of the star in the undersampled grid.  The normalized residual
        image is then resampled from the undersampled star grid to the
        oversampled ePSF grid.

        Parameters
        ----------
        star : `EPSFStar` object
            A single star object.

        epsf : `EPSFModel` object
            The ePSF model.

        Returns
        -------
        image : 2D `~numpy.ndarray`
            A 2D image containing the resampled residual image.  The
            image contains NaNs where there is no data.