Ejemplo n.º 1
0
def iFT(A):
    """
    Inverse Fourier transform
    :param A:  1D numpy.array
    :return:
    """
    A = np.array(A)
    minus_one = (-1)**np.arange(A.size)
    result = np.fft.ifft(minus_one * A)
    result *= minus_one
    result *= np.exp(1j * np.pi * A.size / 2)
    return result
Ejemplo n.º 2
0
def FT(A):
    """
    Fourier transform
    :param A:  1D numpy.array
    :return:
    """
    #test
    A = np.array(A)
    minus_one = (-1)**np.arange(A.size)
    result = np.fft.fft(minus_one * A)
    result *= minus_one
    result *= np.exp(-1j * np.pi * A.size / 2)
    return result
    #     spectra.append(np.abs(FT(pulse[k,:]*blackman(steps)))**2)
    spectra=np.array(spectra)
    buffer = 3
    lincut = int((params['t_final'] * params['omega0']) / (2 * np.pi)) + buffer
    cutspectra=spectra[:,int(spectra[0,:].size/2)+lincut:int(spectra[0,:].size/2)+lincut+cutoffomega.size]
    linspectra=spectra[:,int(spectra[0,:].size/2):int(spectra[0,:].size/2)+linomega.size]
    cutspectra[cutspectra < 1e-9] = 0.

    cutspectrahigh=spectrahigh[:,int(spectrahigh[0,:].size/2)+lincut:int(spectrahigh[0,:].size/2)+lincut+cutoffomegahigh.size]
    linspectrahigh=spectrahigh[:,int(spectrahigh[0,:].size/2):int(spectrahigh[0,:].size/2)+linomegahigh.size]
    cutspectrahigh[cutspectrahigh < 1e-9] = 0.

    inomega = params['omega0'] * (np.arange(encode[:, 0].size) + 1) / encode[:, 0].size
    print(inomega.size)
    encodewave = np.array(
        [[0.04 * np.real(np.exp(1j * w * t)) * np.sin(np.pi * t / params['t_final']) ** 2 for w in inomega] for
         t in times])
    timefield = np.dot(encodewave, encode)
    timefield=np.transpose(timefield)


    encodewavehigh = np.array(
        [[0.04 * np.real(np.exp(1j * w * t)) * np.sin(np.pi * t / params['t_final']) ** 2 for w in inomega] for
         t in times])
    timefieldhigh = np.dot(encodewavehigh, encode)
    timefieldhigh=np.transpose(timefieldhigh)
    # analysis(pulse, pulse_parameters)
    # analysis(linspectra, lin_parameters)
    # # # analysis(cutspectra, high_parameters)

    fscorepulse.append(fscore(pulse, pulse_parameters))