def test_gauss2d_norm(): """Test 2d gaussian """ p = np.array([0., 0., 1., -3., 0., 0.3, 0.3, 1., 3., 0., 0.3, 0.3]) a, b = np.linspace(-10, 10, 1001), np.linspace(-10, 10, 1001) q = np.meshgrid(a, b, sparse=True) y = functions.gaussian2d(p, q) integ = simps(simps(y, b), a) assert (abs(integ - 2.) < 1e-5)
def build_3d_data(): """Builds 3D data object """ p = np.array([0, 0, 1, 0, 0, 0.1]) x, y = np.linspace(-1, 1, 81), np.linspace(-1, 1, 81) X, Y = np.meshgrid(x, y) z = functions.gaussian2d(p, (X, Y)) mon = 1e5 tim = 15 output = Data(Q=np.vstack((item.ravel() for item in np.meshgrid(x, y, 0., 0., 300.))).T, detector=z.ravel(), monitor=np.full(X.ravel().shape, mon, dtype=float), time=np.full(X.ravel().shape, tim, dtype=float)) return output