def test_example2(self): surf = read_asc(os.path.join(DATADIR, 'example2.txt')) self.assertEqual(surf.nb_grid_pts, (650, 650)) self.assertAlmostEqual(surf.physical_sizes[0], 0.0002404103) self.assertAlmostEqual(surf.physical_sizes[1], 0.0002404103) self.assertAlmostEqual(surf.rms_height(), 2.7722350402740072e-07) self.assertAlmostEqual(surf.rms_slope(), 0.35152685030417763) self.assertTrue(surf.is_uniform) self.assertEqual(surf.info['unit'], 'm')
def test_example3(self): surf = read_asc(os.path.join(DATADIR, 'example3.txt')) self.assertEqual(surf.nb_grid_pts, (256, 256)) self.assertAlmostEqual(surf.physical_sizes[0], 10e-6) self.assertAlmostEqual(surf.physical_sizes[1], 10e-6) self.assertAlmostEqual(surf.rms_height(), 3.5222918750198742e-08) self.assertAlmostEqual(surf.rms_slope(), 0.19235602282848963) self.assertTrue(surf.is_uniform) self.assertEqual(surf.info['unit'], 'm')
def test_example1(self): surf = read_asc(os.path.join(DATADIR, 'example1.txt')) self.assertTrue(isinstance(surf, Topography)) self.assertEqual(surf.nb_grid_pts, (1024, 1024)) self.assertAlmostEqual(surf.physical_sizes[0], 2000) self.assertAlmostEqual(surf.physical_sizes[1], 2000) self.assertAlmostEqual(surf.rms_height(), 17.22950485567042) self.assertAlmostEqual(surf.rms_slope(), 0.4560243831362324) self.assertTrue(surf.is_uniform) self.assertEqual(surf.info['unit'], 'nm')
def test_example4(self): surf = read_asc(os.path.join(DATADIR, 'example4.txt')) self.assertEqual(surf.nb_grid_pts, (75, 305)) self.assertAlmostEqual(surf.physical_sizes[0], 2.773965e-05) self.assertAlmostEqual(surf.physical_sizes[1], 0.00011280791) self.assertAlmostEqual(surf.rms_height(), 1.1745891510991089e-07) self.assertAlmostEqual(surf.rms_height(kind='Rq'), 1.1745891510991089e-07) self.assertAlmostEqual(surf.rms_slope(), 0.06776316911544318) self.assertTrue(surf.is_uniform) self.assertEqual(surf.info['unit'], 'm') # test setting the physical_sizes surf.physical_sizes = 1, 2 self.assertAlmostEqual(surf.physical_sizes[0], 1) self.assertAlmostEqual(surf.physical_sizes[1], 2)
def test_example5(self): surf = read_asc(os.path.join(DATADIR, 'example5.txt')) self.assertTrue(isinstance(surf, Topography)) self.assertEqual(surf.nb_grid_pts, (10, 10)) self.assertTrue(surf.physical_sizes is None) self.assertAlmostEqual(surf.rms_height(), 1.0) with self.assertRaises(ValueError): surf.rms_slope() self.assertTrue(surf.is_uniform) self.assertFalse('unit' in surf.info) # test setting the physical_sizes surf.physical_sizes = 1, 2 self.assertAlmostEqual(surf.physical_sizes[0], 1) self.assertAlmostEqual(surf.physical_sizes[1], 2) bw = surf.bandwidth() self.assertAlmostEqual(bw[0], 1.5 / 10) self.assertAlmostEqual(bw[1], 1.5) reader = AscReader(os.path.join(DATADIR, 'example5.txt')) self.assertTrue(reader.default_channel.physical_sizes is None)