def test_recurrence_mle_algorithm(self):
        context = create_context('config_recurrence_mle.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        sm = context.sm_definitions[0]

        self.assertAlmostEqual(
            sm.rupture_rate_model.truncated_gutenberg_richter.b_value,
            0.595256,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.recurrence_sigb,
            0.024816,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.rupture_rate_model.truncated_gutenberg_richter.a_value,
            158.109066,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.recurrence_siga_m,
            49.997286,
            self.decimal_places)
    def test_recurrence_weichert_algorithm(self):
        context = create_context('config_recurrence_weichert.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        sm = context.sm_definitions[0]

        self.assertAlmostEqual(
            sm.rupture_rate_model.truncated_gutenberg_richter.b_value,
            0.569790,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.recurrence_sigb,
            0.041210,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.rupture_rate_model.truncated_gutenberg_richter.a_value,
            132.051268,
            self.decimal_places)

        self.assertAlmostEqual(
            sm.recurrence_siga_m,
            7.701386,
            self.decimal_places)
Esempio n. 3
0
    def setUp(self):
        self.context_prep = Context()
        self.context_noprep = Context()

        self.config_prep = {
            'eq_catalog_file': 'tests/data/completeness_input_test.csv',
            'source_model_file': 'tests/data/area_source_model_processing.xml',
            'result_file': 'tests/data/output.xml',
            'apply_processing_jobs': True,
            'pprocessing_result_file': 'tests/data/preprocessed_catalogue.csv',
            'completeness_table_file': 'tests/data/completeness_table.csv',
            'preprocessing_jobs': None,

            'Afteran': {
                'time_dist_windows': 'Uhrhammer',
                'time_window': 60.0
            },
            'GardnerKnopoff': {
                'time_dist_windows': 'GardnerKnopoff',
                'foreshock_time_window': 0.5
            },

            'Stepp': {'increment_lock': True,
                'magnitude_windows': 0.2,
                'sensitivity': 0.1,
                'time_window': 1
            },

            'processing_jobs': ['Recurrence'],
            'Recurrence': {'magnitude_window': 0.5,
                'recurrence_algorithm': None,
                'reference_magnitude': 2.0,
                'time_window': 1.0
            }
        }

        self.config_noprep = {
            'eq_catalog_file': 'tests/data/preprocessed_catalogue.csv',
            'source_model_file': 'tests/data/area_source_model_processing.xml',
            'result_file': 'tests/data/output.xml',
            'apply_processing_jobs': True,
            'completeness_table_file': 'tests/data/completeness_table.csv',
            'preprocessing_jobs': None,
            'processing_jobs': ['Recurrence'],
            'Recurrence': {'magnitude_window': 0.5,
                'recurrence_algorithm': None,
                'reference_magnitude': 2.0,
                'time_window': 1.0
            }
        }

        self.wnoprep = create_workflow(self.config_noprep)
    def test_gardner_knopoff(self):
        context = create_context('config_gardner_knopoff.yml')
        workflow = create_workflow(context.config)
        run(workflow, context)

        expected_vcl = np.array([0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,
            0, 0, 0, 3, 3])

        self.assertTrue(np.array_equal(self.expected_vmain_shock,
                context.working_catalog))
        self.assertTrue(np.array_equal(expected_vcl, context.vcl))
        self.assertTrue(np.array_equal(self.expected_flag_vector,
                context.flag_vector))
    def test_gardner_knopoff(self):
        context = create_context('config_gardner_knopoff.yml')
        workflow = create_workflow(context.config)
        run(workflow, context)

        expected_vcl = np.array(
            [0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 3])

        self.assertTrue(
            np.array_equal(self.expected_vmain_shock, context.working_catalog))
        self.assertTrue(np.array_equal(expected_vcl, context.vcl))
        self.assertTrue(
            np.array_equal(self.expected_flag_vector, context.flag_vector))
    def test_maximum_magnitude_kijko_npg(self):
        context = create_context('config_maxmag_kijko_npg.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        sm = context.sm_definitions[0]

        self.assertAlmostEqual(6.44392,
            sm.rupture_rate_model.truncated_gutenberg_richter.max_magnitude,
            self.decimal_places)

        self.assertAlmostEqual(0.10922, sm.max_mag_sigma, self.decimal_places)
    def test_maximum_magnitude_cum_moment(self):
        # It depends on a random seed so precision is relaxed
        self.decimal_places = 1
        context = create_context('config_maxmag_cum_moment.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        sm = context.sm_definitions[0]

        self.assertAlmostEqual(6.6,
            sm.rupture_rate_model.truncated_gutenberg_richter.max_magnitude,
            self.decimal_places)

        self.assertAlmostEqual(0.05, sm.max_mag_sigma, self.decimal_places)
    def test_stepp(self):
        context = create_context('config_stepp.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        filtered_eq_events = np.array(
            [[1994., 4.0], [1994., 4.1], [1994., 4.2], [1994., 4.3],
             [1994., 4.4], [1964., 4.5], [1964., 4.6], [1964., 4.7],
             [1964., 4.8], [1964., 4.9], [1964., 5.0], [1964., 5.1],
             [1964., 5.2], [1964., 5.3], [1964., 5.4], [1919., 5.5],
             [1919., 5.6], [1919., 5.7], [1919., 5.8], [1919., 5.9],
             [1919., 6.0], [1919., 6.1], [1919., 6.2], [1919., 6.3],
             [1919., 6.4], [1919., 6.5], [1919., 6.6], [1919., 6.7],
             [1919., 6.8], [1919., 6.9], [1919., 7.0], [1919., 7.1],
             [1919., 7.2], [1919., 7.3]])

        self.assertTrue(
            np.allclose(filtered_eq_events, context.completeness_table))
    def test_stepp(self):
        context = create_context('config_stepp.yml')

        workflow = create_workflow(context.config)

        run(workflow, context)

        filtered_eq_events = np.array([
                    [1994., 4.0], [1994., 4.1], [1994., 4.2],
                    [1994., 4.3], [1994., 4.4], [1964., 4.5],
                    [1964., 4.6], [1964., 4.7], [1964., 4.8],
                    [1964., 4.9], [1964., 5.0], [1964., 5.1],
                    [1964., 5.2], [1964., 5.3], [1964., 5.4],
                    [1919., 5.5], [1919., 5.6], [1919., 5.7],
                    [1919., 5.8], [1919., 5.9], [1919., 6.0],
                    [1919., 6.1], [1919., 6.2], [1919., 6.3],
                    [1919., 6.4], [1919., 6.5], [1919., 6.6],
                    [1919., 6.7], [1919., 6.8], [1919., 6.9],
                    [1919., 7.0], [1919., 7.1], [1919., 7.2],
                    [1919., 7.3]])

        self.assertTrue(np.allclose(filtered_eq_events,
                context.completeness_table))
Esempio n. 10
0
 def execute(self, config_prep):
     wprep = create_workflow(config_prep)
     self.run_config(wprep, self.wnoprep)