Example #1
0
 def setUp(self):
     '''
     '''
     self.fault = None
     self.regionalisation = None
     self.msr = [(WC1994(), 1.0)]
     self.msr_sigma = [(-1.5, 0.15), (0.0, 0.7), (1.5, 0.15)]
     self.shear_mod = [(30.0, 0.8), (35.0, 0.2)]
     self.dlr = [(1.25E-5, 1.0)]
     self.config = [{}]
     self.slip = [(10.0, 1.0)]
     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.
     self.upper_depth = 0.
     self.lower_depth = 20.
     self.simple_fault = SimpleFaultGeometry(self.trace, self.dip,
                                             self.upper_depth,
                                             self.lower_depth)
     # Creates a trace ~60 km long made of 3 points
     upper_edge = Line([x0, x1, x2])
     lower_edge = Line([
         x0.point_at(40., 20., 130.),
         x1.point_at(42., 25., 130.),
         x2.point_at(41., 22., 130.)
     ])
     self.complex_fault = ComplexFaultGeometry([upper_edge, lower_edge],
                                               2.0)
    def read_fault_geometry(self, geo_dict, mesh_spacing=1.0):
        '''
        Creates the fault geometry from the parameters specified in the
        dictionary.

        :param dict geo_dict:
            Sub-dictionary of main fault dictionary containing only
            the geometry attributes
        :param float mesh_spacing:
            Fault mesh spacing (km)
        :returns:
            Instance of SimpleFaultGeometry or ComplexFaultGeometry, depending
            on typology
        '''
        if geo_dict['Fault_Typology'] == 'Simple':
            # Simple fault geometry
            raw_trace = geo_dict['Fault_Trace']
            trace = Line([
                Point(raw_trace[ival], raw_trace[ival + 1])
                for ival in range(0, len(raw_trace), 2)
            ])
            geometry = SimpleFaultGeometry(trace, geo_dict['Dip'],
                                           geo_dict['Upper_Depth'],
                                           geo_dict['Lower_Depth'],
                                           mesh_spacing)

        elif geo_dict['Fault_Typology'] == 'Complex':
            # Complex Fault Typology
            trace = []
            for raw_trace in geo_dict['Fault_Trace']:
                fault_edge = Line([
                    Point(raw_trace[ival], raw_trace[ival + 1],
                          raw_trace[ival + 2])
                    for ival in range(0, len(raw_trace), 3)
                ])
                trace.append(fault_edge)
            geometry = ComplexFaultGeometry(trace, mesh_spacing)
        else:
            raise ValueError('Unrecognised or unsupported fault geometry!')
        return geometry
Example #3
0
    def test_build_fault_model(self):
        # Tests the constuction of a fault model with two faults (1 simple,
        # 1 complex) each with two mfd rates - should produce four sources
        self.model = mtkActiveFaultModel('001', 'A Fault Model', faults=[])
        x0 = Point(30., 30., 0.)
        x1 = x0.point_at(30., 0., 30.)
        x2 = x1.point_at(30., 0., 60.)
        # Total length is 60 km
        trace = Line([x0, x1, x2])
        simple_fault = SimpleFaultGeometry(trace, 90., 0., 20.)
        # Creates a trace ~60 km long made of 3 points
        upper_edge = Line([x0, x1, x2])
        lower_edge = Line([
            x0.point_at(40., 20., 130.),
            x1.point_at(42., 25., 130.),
            x2.point_at(41., 22., 130.)
        ])
        complex_fault = ComplexFaultGeometry([upper_edge, lower_edge], 2.0)
        config = [{
            'MFD_spacing': 0.1,
            'Maximum_Magnitude': 7.0,
            'Maximum_Uncertainty': None,
            'Model_Name': 'Characteristic',
            'Model_Weight': 0.5,
            'Sigma': 0.1,
            'Lower_Bound': -1.,
            'Upper_Bound': 1.
        }, {
            'MFD_spacing': 0.1,
            'Maximum_Magnitude': 7.5,
            'Maximum_Uncertainty': None,
            'Model_Name': 'Characteristic',
            'Model_Weight': 0.5,
            'Sigma': 0.1,
            'Lower_Bound': -1.,
            'Upper_Bound': 1.
        }]
        fault1 = mtkActiveFault('001',
                                'Simple Fault 1',
                                simple_fault, [(10.0, 1.0)],
                                -90.,
                                None,
                                aspect_ratio=1.0,
                                scale_rel=[(WC1994(), 1.0)],
                                shear_modulus=[(30.0, 1.0)],
                                disp_length_ratio=[(1E-5, 1.0)])
        fault1.generate_config_set(config)
        fault2 = mtkActiveFault('002',
                                'Complex Fault 1',
                                complex_fault, [(10.0, 1.0)],
                                -90.,
                                None,
                                aspect_ratio=1.0,
                                scale_rel=[(WC1994(), 1.0)],
                                shear_modulus=[(30.0, 1.0)],
                                disp_length_ratio=[(1E-5, 1.0)])
        fault2.generate_config_set(config)
        self.model.faults = [fault1, fault2]

        # Generate source model
        self.model.build_fault_model()
        self.assertEqual(len(self.model.source_model.sources), 4)
        # First source should be an instance of a mtkSimpleFaultSource
        model1 = self.model.source_model.sources[0]
        self.assertTrue(isinstance(model1, mtkSimpleFaultSource))
        self.assertEqual(model1.id, '001_1')
        self.assertAlmostEqual(model1.mfd.min_mag, 6.9)
        np.testing.assert_array_almost_equal(
            np.log10(np.array(model1.mfd.occurrence_rates)),
            np.array([-2.95320041, -2.54583708, -2.953200413]))

        # Second source should be an instance of a mtkSimpleFaultSource
        model2 = self.model.source_model.sources[1]
        self.assertTrue(isinstance(model2, mtkSimpleFaultSource))
        self.assertEqual(model2.id, '001_2')
        self.assertAlmostEqual(model2.mfd.min_mag, 7.4)
        np.testing.assert_array_almost_equal(
            np.log10(np.array(model2.mfd.occurrence_rates)),
            np.array([-3.70320041, -3.29583708, -3.70320041]))

        # Third source should be an instance of a mtkComplexFaultSource
        model3 = self.model.source_model.sources[2]
        self.assertTrue(isinstance(model3, mtkComplexFaultSource))
        self.assertEqual(model3.id, '002_1')
        self.assertAlmostEqual(model3.mfd.min_mag, 6.9)
        np.testing.assert_array_almost_equal(
            np.log10(np.array(model3.mfd.occurrence_rates)),
            np.array([-2.59033387, -2.18297054, -2.59033387]))

        # Fourth source should be an instance of a mtkComplexFaultSource
        model4 = self.model.source_model.sources[3]
        self.assertTrue(isinstance(model4, mtkComplexFaultSource))
        self.assertEqual(model4.id, '002_2')
        self.assertAlmostEqual(model4.mfd.min_mag, 7.4)
        np.testing.assert_array_almost_equal(
            np.log10(np.array(model4.mfd.occurrence_rates)),
            np.array([-3.34033387, -2.93297054, -3.34033387]))