def test_gaussian(): p, data = generate_gaussian() p0 = guess_gaussian(data) p1 = fit_gaussian(data, p0) print('p:', p) print('p0:', p0) print('p1:', p1)
def test_gaussian(self): from pycoldatom.functions.fitclassical import generate_gaussian, fit_gaussian, guess_gaussian, fit_gaussian_result p, data = generate_gaussian(p0=[1.0, 40, 60, 15, 10, 0.1]) # p, data = generate_gaussian(p0=[1.0, 4, 6, 5, 3, 0.1], size=(10, 10)) data = add_noise(data) # mask = np.random.random(data.shape)<0.1 mask = np.zeros_like(data) mask[30:50, 50:70] = 1 data = np.ma.array(data, mask=mask) p0 = guess_gaussian(data) p1 = fit_gaussian(data) # print('p:', p) # print('p0:', p0) # print('p1:', p1) result, err = fit_gaussian_result(data) # print(result) np.testing.assert_allclose(p, p1, rtol=1e-2)