def __call__(self, resolution, z=0, **kwargs):
        """
        Return a binning matrix for the given resolution and optional redshift,
        based on the original wavelengths provided when the class was initiated.

        :param resolution:
            Spectral resolving power.

        :param z: [optional]
            The redshift.
        """

        # Calculate the redshifted wavelengths.
        wavelengths = self.to_wavelengths * (1 + z)

        # Calculate the width of the kernel at each point.
        fwhms = (wavelengths/resolution)**2
        if self.from_resolution:
            fwhms -= (wavelengths/self.from_resolution)**2

        # 2.355 ~= 2 * sqrt(2*log(2))
        sigmas = fwhms/2.3548200450309493
        N_kernel_pixels = int(np.ceil(sigmas[-1] * self._threshold_pixels))
        integer_offsets = self.from_wavelengths.searchsorted(wavelengths)

        # For +/- N_kernel_pixels at each point, calculate the kernel and retain
        # the indices.
        ios = integer_offsets[0]
        indices = np.tile(np.arange(ios - N_kernel_pixels,
            ios + N_kernel_pixels), self.N).reshape(self.N, 2 * N_kernel_pixels)
        indices[1:, :] += np.cumsum(np.diff(integer_offsets)).reshape(-1, 1)
        indices = np.clip(indices, 0, self.M - 1)

        x_indices = indices.flatten()
        y_indices = np.repeat(np.arange(self.N), 2 * N_kernel_pixels)

        # Calculate the kernel at each point.
        pdf = np.exp(
            -(self.from_wavelengths[indices].T - wavelengths)**2/(2*sigmas**2))
        pdf /= pdf.sum(axis=0)

        return sparse.coo_matrix((pdf.T.flatten(), (x_indices, y_indices)),
            shape=(self.M, self.N))
def __call__ ( self , resolution , z = 0 , ** kwargs ) : wavelengths = self . to_wavelengths * ( 1 + z ) fwhms = ( wavelengths / resolution ) ** 2 if self . from_resolution : fwhms -= ( wavelengths / self . from_resolution ) ** 2 sigmas = fwhms / 2.3548200450309493 N_kernel_pixels = int ( np . ceil ( sigmas [ - 1 ] * self . _threshold_pixels ) ) integer_offsets = self . from_wavelengths . searchsorted ( wavelengths ) ios = integer_offsets [ 0 ] indices = np . tile ( np . arange ( ios - N_kernel_pixels , ios + N_kernel_pixels ) , self . N ) . reshape ( self . N , 2 * N_kernel_pixels ) indices [ 1 : , : ] += np . cumsum ( np . diff ( integer_offsets ) ) . reshape ( - 1 , 1 ) indices = np . clip ( indices , 0 , self . M - 1 ) x_indices = indices . flatten ( ) y_indices = np . repeat ( np . arange ( self . N ) , 2 * N_kernel_pixels ) pdf = np . exp ( - ( self . from_wavelengths [ indices ] . T - wavelengths ) ** 2 / ( 2 * sigmas ** 2 ) ) pdf /= pdf . sum ( axis = 0 ) return sparse . coo_matrix ( ( pdf . T . flatten ( ) , ( x_indices , y_indices ) ) , shape = ( self . M , self . N ) )
Return a binning matrix for the given resolution and optional redshift,
        based on the original wavelengths provided when the class was initiated.

        :param resolution:
            Spectral resolving power.

        :param z: [optional]
            The redshift.