Exemple #1
0
 def test_rotate(self):
     """Test rotate."""
     npt.assert_array_equal(
         np_adjust.rotate(self.data1),
         np.array([[8, 7, 6], [5, 4, 3], [2, 1, 0]]),
         err_msg='Incorrect rotation',
     )
Exemple #2
0
def psf_convolve(data, psf, psf_rot=False, psf_type='fixed', method='scipy'):
    """Convolve data with PSF

    This method convolves an image with a PSF

    Parameters
    ----------
    data : np.ndarray
        Input data array, normally an array of 2D images
    psf : np.ndarray
        Input PSF array, normally either a single 2D PSF or an array of 2D
        PSFs
    psf_rot: bool
        Option to rotate PSF by 180 degrees
    psf_type : str {'fixed', 'obj_var'}, optional
        PSF type (default is 'fixed')
    method : str {'astropy', 'scipy'}, optional
        Convolution method (default is 'astropy')

        'fixed':
            The PSF is fixed, i.e. it is the same for each image

        'obj_var':
            The PSF is object variant, i.e. it is different for each image

    Returns
    -------
    np.ndarray convolved data

    Raises
    ------
    ValueError
        If `psf_type` is not 'fixed' or 'obj_var'

    """

    if psf_type not in ('fixed', 'obj_var'):
        raise ValueError('Invalid PSF type. Options are "fixed" or "obj_var"')

    if psf_rot and psf_type == 'fixed':
        psf = rotate(psf)

    elif psf_rot:
        psf = rotate_stack(psf)

    if psf_type == 'fixed':
        return np.array([convolve(data_i, psf, method=method) for data_i in
                        data])

    elif psf_type == 'obj_var':

        return convolve_stack(data, psf, method=method)
Exemple #3
0
def psf_convolve(data, psf, psf_rot=False, psf_type='fixed', method='scipy'):
    """Convolve data with PSF

    This method convolves an image with a PSF

    Parameters
    ----------
    data : np.ndarray
        Input data array, normally an array of 2D images
    psf : np.ndarray
        Input PSF array, normally either a single 2D PSF or an array of 2D
        PSFs
    psf_rot: bool
        Option to rotate PSF by 180 degrees
    psf_type : str {'fixed', 'obj_var'}, optional
        PSF type (default is 'fixed')
    method : str {'astropy', 'scipy'}, optional
        Convolution method (default is 'astropy')

        'fixed':
            The PSF is fixed, i.e. it is the same for each image

        'obj_var':
            The PSF is object variant, i.e. it is different for each image

    Returns
    -------
    np.ndarray convolved data

    Raises
    ------
    ValueError
        If `psf_type` is not 'fixed' or 'obj_var'

    """

    if psf_type not in ('fixed', 'obj_var'):
        raise ValueError('Invalid PSF type. Options are "fixed" or "obj_var"')

    if psf_rot and psf_type == 'fixed':
        psf = rotate(psf)

    elif psf_rot:
        psf = rotate_stack(psf)

    if psf_type == 'fixed':
        return np.array(
            [convolve(data_i, psf, method=method) for data_i in data])

    elif psf_type == 'obj_var':

        return convolve_stack(data, psf, method=method)
Exemple #4
0
def psf_convolve(data, psf, psf_rot=False):
    """PSF Convolution.

    Parameters
    ----------
    data : np.ndarray
        Input data, 2D image
    psf : np.ndarray
        Input PSF, 2D image
    psf_rot : bool, optional
        Option to rotate the input PSF (default is False)

    Returns
    -------
    np.ndarray convolved image

    """
    if psf_rot:
        psf = rotate(psf)

    return convolve(data, psf)