class TestSimpleGeometry(unittest.TestCase): ''' Tests the :class: hmtk.fault.fault_geometries.SimpleFaultGeometry ''' def setUp(self): ''' Create a simple fault of known length and downdip width ''' # Creates a trace ~60 km long made of 3 points x0 = Point(30., 30., 0.) x1 = x0.point_at(30., 0., 30.) x2 = x1.point_at(30., 0., 60.) # Total length is 60 km self.trace = Line([x0, x1, x2]) self.dip = 90. # Simple Vertical Strike-Slip fault # Total downdip width = 20. km self.upper_depth = 0. self.lower_depth = 20. self.fault = None def test_simple_fault_instantiation(self): ''' Test the instantiation of the fault and the calculation of the length ''' expected_keys = [ 'trace', 'downdip_width', 'area', 'surface', 'upper_depth', 'length', 'surface_width', 'lower_depth', 'dip', 'typology' ] self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertListEqual(self.fault.__dict__.keys(), expected_keys) self.assertAlmostEqual(self.fault.length, 60., 5) self.assertEqual(self.fault.typology, 'Simple') self.assertTrue( isinstance(self.fault.surface, simple_fault.SimpleFaultSurface)) def test_simple_get_area_vertical(self): ''' Tests the area calculation for a vertical fault ''' # Case 1 - Vertical fault self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(1200., self.fault.get_area(), 5) self.assertAlmostEqual(20., self.fault.downdip_width, 5) self.assertAlmostEqual(0., self.fault.surface_width, 5) def test_simple_get_area_dipping(self): ''' Tests the area calculation for a dipping fault ''' self.dip = 30. self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(2400., self.fault.get_area(), 5) self.assertAlmostEqual(40., self.fault.downdip_width, 5)
def test_simple_get_area_dipping(self): ''' Tests the area calculation for a dipping fault ''' self.dip = 30. self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(2400., self.fault.get_area(), 5) self.assertAlmostEqual(40., self.fault.downdip_width, 5)
class TestSimpleGeometry(unittest.TestCase): ''' Tests the :class: hmtk.fault.fault_geometries.SimpleFaultGeometry ''' def setUp(self): ''' Create a simple fault of known length and downdip width ''' # Creates a trace ~60 km long made of 3 points x0 = Point(30., 30., 0.) x1 = x0.point_at(30., 0., 30.) x2 = x1.point_at(30., 0., 60.) # Total length is 60 km self.trace = Line([x0, x1, x2]) self.dip = 90. # Simple Vertical Strike-Slip fault # Total downdip width = 20. km self.upper_depth = 0. self.lower_depth = 20. self.fault = None def test_simple_fault_instantiation(self): ''' Test the instantiation of the fault and the calculation of the length ''' expected_keys = ['trace', 'downdip_width', 'area', 'surface', 'upper_depth', 'length', 'surface_width', 'lower_depth', 'dip', 'typology'] self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertListEqual(self.fault.__dict__.keys(), expected_keys) self.assertAlmostEqual(self.fault.length, 60., 5) self.assertEqual(self.fault.typology, 'Simple') self.assertTrue(isinstance(self.fault.surface, simple_fault.SimpleFaultSurface)) def test_simple_get_area_vertical(self): ''' Tests the area calculation for a vertical fault ''' # Case 1 - Vertical fault self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(1200., self.fault.get_area(), 5) self.assertAlmostEqual(20., self.fault.downdip_width, 5) self.assertAlmostEqual(0., self.fault.surface_width, 5) def test_simple_get_area_dipping(self): ''' Tests the area calculation for a dipping fault ''' self.dip = 30. self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(2400., self.fault.get_area(), 5) self.assertAlmostEqual(40., self.fault.downdip_width, 5)
def test_simple_get_area_vertical(self): ''' Tests the area calculation for a vertical fault ''' # Case 1 - Vertical fault self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertAlmostEqual(1200., self.fault.get_area(), 5) self.assertAlmostEqual(20., self.fault.downdip_width, 5) self.assertAlmostEqual(0., self.fault.surface_width, 5)
def test_simple_fault_instantiation(self): ''' Test the instantiation of the fault and the calculation of the length ''' expected_keys = ['trace', 'downdip_width', 'area', 'surface', 'upper_depth', 'length', 'surface_width', 'lower_depth', 'dip', 'typology'] self.fault = SimpleFaultGeometry(self.trace, self.dip, self.upper_depth, self.lower_depth) self.assertListEqual(self.fault.__dict__.keys(), expected_keys) self.assertAlmostEqual(self.fault.length, 60., 5) self.assertEqual(self.fault.typology, 'Simple') self.assertTrue(isinstance(self.fault.surface, simple_fault.SimpleFaultSurface))