import numpy as np import matplotlib.pyplot as plt import fract %matplotlib tk N = 10 hs = [0.25, 0.75] for H in hs: z = fract.fbm2D_midpoint(H,N) plt.imshow(z) # plt.title(r"H = %g, %i x %i points"%(H, 2**N, 2**N)) plt.savefig(("midpoint%g.png"%H), bbox_inches='tight' ) plt.show()
field1 = field1[0:n_cut, 0:m_cut] field2 = field2[0:n_cut, 0:m_cut] else: n_cut = int(n / (np.sqrt(2) * 2)) m_cut = int(m / (np.sqrt(2) * 2)) field1 = field1[0:n_cut, 0:m_cut] field2 = field2[0:n_cut, 0:m_cut] return (field1, field2) # gen_params = fbm2D_exact(0.7, 512) # f1, f2 = fbm2D_exact_from_generator(*gen_params) # plt.imshow(f1) # plt.imshow(f2) exact_image = fbm2D_exact(H=0.7, n_out=2**9) plt.figure() plt.imshow((exact_image)) plt.title("exact image") plt.show() midpoint_image = fract.fbm2D_midpoint(H=0.7, N=9) plt.figure() plt.imshow((midpoint_image)) plt.title("midpoint image") plt.show()
def pow_law(x, a, b): return a * np.power(x, b) # return a * x**(b) def pow_law_jacobian(x, a, b): return b * a * x**(b - 1) if __name__ == '__main__': print("generating") N = 10 gen_H = np.float64(0.8) z2d = fract.fbm2D_midpoint(gen_H, N) plt.imshow(z2d, interpolation="None") plt.show() detect_H, freq_exp, c, freqs, powers = profile_fourier_from_z2d( z2d, images=False, corr=True) freqs = freqs[2:] powers = powers[2:] sigmas = powers popt, pcov = scipy.optimize.curve_fit(pow_law, freqs, powers, sigma=sigmas,