Ejemplo n.º 1
0
def _ifft_positive(data):
    if data.dtype == typequaternion:

        fr = get_component(data, "R")
        dr = np.fft.fft(np.fft.ifftshift(fr, -1)) * data.shape[-1]
        fi = get_component(data, "I")
        di = np.fft.fft(np.fft.ifftshift(fi, -1)) * data.shape[-1]

        # rebuild the quaternion
        data = as_quaternion(dr, di)

    else:
        data = np.fft.fft(np.fft.ifftshift(data, -1)) * data.shape[-1]

    return data
Ejemplo n.º 2
0
def _ifft(data):
    if data.dtype == typequaternion:

        fr = get_component(data, "R")
        dr = np.fft.ifft(np.fft.ifftshift(fr, -1))
        fi = get_component(data, "I")
        di = np.fft.ifft(np.fft.ifftshift(fi, -1))

        # rebuild the quaternion
        data = as_quaternion(dr, di)

    else:
        data = np.fft.ifft(np.fft.ifftshift(data, -1))

    return data
Ejemplo n.º 3
0
def _fft(data):
    if data.dtype == typequaternion:

        dr = get_component(data, "R")
        fr = np.fft.fftshift(np.fft.fft(dr), -1)
        di = get_component(data, "I")
        fi = np.fft.fftshift(np.fft.fft(di), -1)

        # rebuild the quaternion
        data = as_quaternion(fr, fi)

    else:
        data = np.fft.fftshift(np.fft.fft(data), -1)

    return data
Ejemplo n.º 4
0
def _fft_positive(data):
    if data.dtype == typequaternion:

        dr = get_component(data, "R")
        fr = np.fft.fftshift(np.fft.ifft(dr).astype(
            data.dtype)) * data.shape[-1]
        di = get_component(data, "I")
        fi = np.fft.fftshift(np.fft.ifft(di).astype(
            data.dtype)) * data.shape[-1]

        # rebuild the quaternion
        data = as_quaternion(fr, fi)

    else:
        data = np.fft.fftshift(np.fft.ifft(data).astype(
            data.dtype)) * data.shape[-1]

    return data
Ejemplo n.º 5
0
    def component(self, select="REAL"):
        """
        Take selected components of an hypercomplex array (RRR, RIR, ...).

        Parameters
        ----------
        select : str, optional, default='REAL'
            If 'REAL', only real component in all dimensions will be selected.
            ELse a string must specify which real (R) or imaginary (I) component
            has to be selected along a specific dimension. For instance,
            a string such as 'RRI' for a 2D hypercomplex array indicated
            that we take the real component in each dimension except the last
            one, for which imaginary component is preferred.

        Returns
        -------
        component
            Component of the complex or hypercomplex array.
        """
        if not select:
            # no selection - returns inchanged
            return self

        new = self.copy()

        ma = self.masked_data

        ma = get_component(ma, select)

        if isinstance(ma, np.ma.masked_array):
            new._data = ma.data
            new._mask = ma.mask
        else:
            new._data = ma

        if hasattr(ma, "mask"):
            new._mask = ma.mask
        else:
            new._mask = NOMASK

        return new