def test_doubles(self): x = np.arange(1, 11, 1, dtype=np.double) z = np.array( (41.2, 40.2, 39.7, 39.2, 40.1, 38.3, 39.1, 40.0, 41.1, 40.3), dtype=np.double) bins = np.arange(1, 11, 1, dtype=np.double) gamma, bin_centres = variogram.estimate_unstructured(z, bins, x) self.assertAlmostEqual(gamma[0], .4917, places=4)
def test_mixed(self): x = np.arange(1, 11, 1, dtype=np.double) z = np.array( (41.2, 40.2, 39.7, 39.2, 40.1, 38.3, 39.1, 40.0, 41.1, 40.3), dtype=np.double) bins = np.arange(1, 11, 1, dtype=int) gamma, bin_centres = variogram.estimate_unstructured(z, bins, x) self.assertAlmostEqual(gamma[0], .4917, places=4) x = np.arange(1, 5, 1, dtype=np.double) z = np.array((10, 20, 30, 40), dtype=LONGTYPE) bins = np.arange(1, 11, 1, dtype=int) gamma, bin_centres = variogram.estimate_unstructured(z, bins, x) self.assertAlmostEqual(gamma[0], 50., places=4) x = np.arange(1, 5, 1, dtype=np.double) z = np.array((10, 20, 30, 40), dtype=LONGTYPE) bins = np.arange(1, 11, 1, dtype=np.double) gamma, bin_centres = variogram.estimate_unstructured(z, bins, x) self.assertAlmostEqual(gamma[0], 50., places=4)
def test_sampling_1d(self): x = np.linspace(0., 100., 21000) rng = np.random.RandomState(1479373475) field = rng.rand(len(x)) bins = np.arange(0, 100, 10) gamma, bin_centres = variogram.estimate_unstructured( field, bins, x, sampling_size=5000) var = 1. / 12. self.assertAlmostEqual(gamma[0], var, places=2) self.assertAlmostEqual(gamma[len(gamma) // 2], var, places=2) self.assertAlmostEqual(gamma[-1], var, places=2)
def test_uncorrelated_2d(self): x_c = np.linspace(0., 100., 60) y_c = np.linspace(0., 100., 60) x, y = np.meshgrid(x_c, y_c) x = np.reshape(x, len(x_c) * len(y_c)) y = np.reshape(y, len(x_c) * len(y_c)) rng = np.random.RandomState(1479373475) field = rng.rand(len(x)) bins = np.arange(0, 100, 10) gamma, bin_centres = variogram.estimate_unstructured(field, bins, x, y) var = 1. / 12. self.assertAlmostEqual(gamma[0], var, places=2) self.assertAlmostEqual(gamma[len(gamma) // 2], var, places=2) self.assertAlmostEqual(gamma[-1], var, places=2)
def test_np_int(self): x = np.arange(1, 5, 1, dtype=np.int) z = np.array((10, 20, 30, 40), dtype=np.int) bins = np.arange(1, 11, 1, dtype=np.int) gamma, bin_centres = variogram.estimate_unstructured(z, bins, x) self.assertAlmostEqual(gamma[0], 50., places=4)