def PsdArray2Noise_1d(PsdArray, N, Semiaxis=True, Real=True):
    '\n\tGenerates a noise pattern whose Power Spectral density is given by Psd.\n\n\tParameters\n\t---------------------\n\tPsd :  1d array\n\t\tContains the numeric Psd (treated as evenly spaced array)\n\n\tSemiaxis :\n\t\t0 : does nothing\n\t\t1 : halvens Pds, then replicates the halven part for left frequencies,\n\t\t\tproducing an output as long as Psd\n\t\t2 : replicates all Pds for lef frequencies as well, producing an output\n\t\t\ttwice as long as Psd\n\tReal : boolean\n\t\tIf True, the real part of the output is returned (default)\n\n\tReturns:\n\t---------------------\n\t\tAn array of the same length of Psd\n\t'
    if (Semiaxis == True):
        yHalf = PsdArray
        PsdArrayNew = np.hstack((yHalf[(- 1):0:(- 1)], yHalf))
        idelta = (len(PsdArrayNew) - N)
        if (idelta == 1):
            PsdArrayNew = PsdArrayNew[0:(- 1)]
        elif (idelta == 0):
            pass
        else:
            print(('Error!  len(PsdArrayNew) - len(PsdArray) = %0d' % idelta))
    y = np.fft.fftshift(PsdArrayNew)
    r = ((2 * np.pi) * np.random.rand(len(PsdArrayNew)))
    f = np.fft.ifft((y * np.exp((1j * r))))
    if Real:
        return np.real(f)
    else:
        return f
Generates a noise pattern whose Power Spectral density is given by Psd.

Parameters
---------------------
Psd :  1d array
        Contains the numeric Psd (treated as evenly spaced array)

Semiaxis :
        0 : does nothing
        1 : halvens Pds, then replicates the halven part for left frequencies,
                producing an output as long as Psd
        2 : replicates all Pds for lef frequencies as well, producing an output
                twice as long as Psd
Real : boolean
        If True, the real part of the output is returned (default)

Returns:
---------------------
        An array of the same length of Psd
def PsdArray2Noise_1d(PsdArray, N, Semiaxis=True, Real=True):
    '\n\tGenerates a noise pattern whose Power Spectral density is given by Psd.\n\n\tParameters\n\t---------------------\n\tPsd :  1d array\n\t\tContains the numeric Psd (treated as evenly spaced array)\n\n\tSemiaxis :\n\t\t0 : does nothing\n\t\t1 : halvens Pds, then replicates the halven part for left frequencies,\n\t\t\tproducing an output as long as Psd\n\t\t2 : replicates all Pds for lef frequencies as well, producing an output\n\t\t\ttwice as long as Psd\n\tReal : boolean\n\t\tIf True, the real part of the output is returned (default)\n\n\tReturns:\n\t---------------------\n\t\tAn array of the same length of Psd\n\t'
    if (Semiaxis == True):
        yHalf = PsdArray
        PsdArrayNew = np.hstack((yHalf[(- 1):0:(- 1)], yHalf))
        idelta = (len(PsdArrayNew) - N)
        if (idelta == 1):
            PsdArrayNew = PsdArrayNew[0:(- 1)]
        elif (idelta == 0):
            pass
        else:
            print(('Error!  len(PsdArrayNew) - len(PsdArray) = %0d' % idelta))
    y = np.fft.fftshift(PsdArrayNew)
    r = ((2 * np.pi) * np.random.rand(len(PsdArrayNew)))
    f = np.fft.ifft((y * np.exp((1j * r))))
    if Real:
        return np.real(f)
    else:
        return f