def log_sample(x, y, base=2):
    ind = np.array(range(x.size))
    xl = x[(np.mod(np.log(ind) / np.log(base), 1)) == 0]
    yl = y[(np.mod(np.log(ind) / np.log(base), 1)) == 0]

    return (xl, yl)


if __name__ == '__main__':
    print("generating")
    N = 8
    gen_H = np.float64(0.1)
    contour_H = np.float64(0.7)
    z2d = fract.fbm2D(gen_H, N)
    z2d = fract.cut_profile(z2d, contour_H)

    imm = np.copy(z2d)
    imm[imm == 0.0] = np.nan
    plt.imshow(imm, interpolation="None")
    plt.show()

    freqs, powers = fract.fourier_1(z2d, images=False, corr=False)

    freq_exp, c = fract.linear_log_fit(freqs[1:], powers[1:])
    detect_H = fract.freq_exp_to_H(freq_exp)

    freqs = freqs[2:]
    powers = powers[2:]
    sigmas = powers
Exemplo n.º 2
0
# don't overwrite...
results = [ [] for h in hs]

means = np.zeros(hs.shape)
stdevs = np.zeros(hs.shape)


for H_i, H in enumerate(hs):
    gen_params = fract.save_fbm2D_exact_generator_params(H,N)
    print(H)

    for j in range(0,stat_n//2):
        print("    ",j)
        z2d1, z2d2 = fract.fbm2D_exact_from_generator(*gen_params)
        z2d1 = fract.cut_profile(z2d1, contour_H)
        z2d2 = fract.cut_profile(z2d2, contour_H)
        res1 = 0
        res2 = 0
        try:
            detect_H1 = fract.dfa_H(z2d1, data=False)
            print("        ",detect_H1)
        except Exception as ex:
            res1 = np.nan
            print("Exception ", ex)

        try:
            detect_H2 = fract.dfa_H(z2d2, data=False)
            # print("        ",res2)
        except Exception as ex:
            res2 = np.nan
Exemplo n.º 3
0
#     r_out = np.arange(0.0, np.float64(autocorr_size), 1.0)
#     autocorr_out = np.empty_like(r_out)

#     libautocorr.autocorr(z2d.ravel(), xwid, ywid, autocorr_out, autocorr_size)

#     return r_out, autocorr_out

# if __name__ == "__main__":
#     z2d = fract.fbm2D_spectral(H=0.6, N=9)
#     z2d = fract.cut_profile(z2d, 0.99)

#     res = autocorr_1(z2d)

z2d = fract.fbm2D_spectral(H=0.6, N=8)
z2d = fract.cut_profile(z2d, 0.99)

xwid, ywid = z2d.shape
autocorr_size = min(xwid, ywid) // 2

r_out = np.arange(0.0, np.float64(autocorr_size), 1.0)
autocorr_out = np.zeros(r_out.shape, dtype=float)
count_out = np.zeros(r_out.shape, dtype=int)

libautocorr.autocorr(z2d.ravel(), xwid, ywid, autocorr_out, count_out,
                     autocorr_size)

autocorr_out = autocorr_out * 10000 / count_out

plt.scatter(r_out, autocorr_out)