def gen_gaussian_tt(ampl, mu_x, mu_y, sigma, x, y): '''Generate a Gaussian function on a twisted torus.''' dim = Pair2D(x.shape[1], x.shape[0]) first = Pair2D(mu_x, mu_y) second = Pair2D(x.ravel(), y.ravel()) dist = twisted_torus_distance(first, second, dim) g = ampl * np.exp(-dist ** 2 / (2 * sigma ** 2)) return np.reshape(g, (dim.y, dim.x))
def gen_gaussian_tt(ampl, mu_x, mu_y, sigma, x, y): '''Generate a Gaussian function on a twisted torus.''' dim = Pair2D(x.shape[1], x.shape[0]) first = Pair2D(mu_x, mu_y) second = Pair2D(x.ravel(), y.ravel()) dist = twisted_torus_distance(first, second, dim) g = ampl * np.exp(-dist**2 / (2 * sigma**2)) return np.reshape(g, (dim.y, dim.x))
def test_reference_imp(self): # Basic test NX, NY = 53, 53 a = Pair2D(0, 0) dim = Pair2D(1., 1.) shift = .7 for x_shift in [0, shift]: for y_shift in [0, shift]: for nx in np.arange(1, NX+1): for ny in np.arange(1, NY+1): X, Y = np.meshgrid(np.linspace(0, 1, nx), np.linspace(0, 1, ny)) X += x_shift Y += y_shift others = Pair2D(X.flatten(), Y.flatten()) np.testing.assert_allclose( self.remapTwistedTorus(a, others, dim), twisted_torus_distance(a, others, dim), rtol=1e-10, atol=0)
def test_reference_imp(self): # Basic test NX, NY = 53, 53 a = Pair2D(0, 0) dim = Pair2D(1., 1.) shift = .7 for x_shift in [0, shift]: for y_shift in [0, shift]: for nx in np.arange(1, NX + 1): for ny in np.arange(1, NY + 1): X, Y = np.meshgrid(np.linspace(0, 1, nx), np.linspace(0, 1, ny)) X += x_shift Y += y_shift others = Pair2D(X.flatten(), Y.flatten()) np.testing.assert_allclose( self.remapTwistedTorus(a, others, dim), twisted_torus_distance(a, others, dim), rtol=1e-10, atol=0)