def std(X, shape, use_full_fft=False):
    """
    Compute the standard deviation of a two-dimensional array in the
    spectral domain.

    Parameters
    ----------
    X: array_like
        A complex array representing the Fourier transform of a two-dimensional
        array.
    shape: tuple
        A two-element tuple specifying the shape of the original input array
        in the spatial domain.
    use_full_fft: bool
        If True, X represents the full FFT of the original array. Otherwise, it
        is assumed to contain only the symmetric part, i.e. in the format
        returned by numpy.fft.rfft2.

    Returns
    -------
    out: float
        The standard deviation.
    """
    res = np.sum(np.abs(X) ** 2) - np.real(X[0, 0]) ** 2
    if not use_full_fft:
        if shape[1] % 2 == 1:
            res += np.sum(np.abs(X[:, 1:]) ** 2)
        else:
            res += np.sum(np.abs(X[:, 1:-1]) ** 2)

    return np.sqrt(res / (shape[0] * shape[1]) ** 2)
Compute the standard deviation of a two-dimensional array in the
spectral domain.

Parameters
----------
X: array_like
A complex array representing the Fourier transform of a two-dimensional
array.
shape: tuple
A two-element tuple specifying the shape of the original input array
in the spatial domain.
use_full_fft: bool
If True, X represents the full FFT of the original array. Otherwise, it
is assumed to contain only the symmetric part, i.e. in the format
returned by numpy.fft.rfft2.

Returns
-------
out: float
The standard deviation.
pysteps/utils/spectral.py