Example #1
0
def fourier_intens_from_cube(cube, **kwargs):
    """
    Executes fourier transformation of cube, averaging by sphere
    :param cube: cube itself
    :param signal_length:
    :param kwargs:
    :return:
    """
    cube /= np.max(np.abs(cube))
    cube -= np.average(cube)
    npoints = len(cube)
    lenqs, intens = fourier_base(cube, **kwargs)
    signal_length = kwargs.get("sizelat", 1.)
    lenqs /= signal_length
    #####
    intens *= lenqs**2
    #####
    intens /= np.max(intens)
    flag = kwargs.get("interp", True)
    if flag:
        lenqs_n = np.linspace(0., np.max(lenqs), len(cube))
        intens_n = np.interp(lenqs_n, xp=lenqs, fp=intens)
        lenqs = lenqs_n
        intens = intens_n
    return lenqs, intens

    """
Example #2
0
def test_by_sin(npoints=100):
    s = lambda x, y, z: np.sin(2*np.pi*4*r(x,y,z))
    sizelat = 4
    l = sizelat/2
    r = lambda x, y, z: np.sqrt((x-l)**2 + (y-l)**2 + (z-l)**2)

    cube = cube_lattice(lattice_num=npoints, flambda=s, sizelat=sizelat)
    plt.imshow(cube[npoints/2, :,:])
    plt.colorbar()
    plt.show()
    cube -= np.average(cube)

    peakmax = 10.
    lenqs2, intens_mod = straight_intensity(cube, peakmax=peakmax, sizelat=sizelat)
    intens_mod /= lenqs2**2
    plt.plot(lenqs2, intens_mod,'--b')
    plt.plot(lenqs2, intens_mod,'bo')

    plt.title("ФП в точках, ячеек:{}".format(sizelat))
    plt.ylabel("I, a.u.")
    plt.xlabel("q, a.u.")
    plt.show()
    output(name="test3", pic_path=".", lenqs=lenqs2, intens_exp=intens_mod,
           intens_mod=intens_mod, error=0., xaxis=np.array([0.,9.]))

    from Fourier import fourier_base
    lenqs_f, intens_f = fourier_base(cube)
    lenqs_f /= sizelat
    plt.plot(lenqs_f, intens_f/np.max(intens_f),'-r')
    plt.title("Полное ФП, ячеек:{}".format(sizelat))

    plt.ylabel("I, a.u.")
    plt.xlabel("q, a.u.")
    plt.show()