Exemple #1
0
    def test_get_adjustment_factor(self):
        '''
        Tests the function that should return an input adjustment factor if
        the magnitude is from a "complete" event - and a zero otherwise
        '''
        # Good case - when event is in the first completeness period
        comp_table = np.array([[1990., 4.0], [1960., 4.5], [1900., 5.5]])
        self.catalogue.data['magnitude'] = np.array([4.5, 5.7])
        comp_table = utils.get_even_magnitude_completeness(
            comp_table, self.catalogue)[0]

        tfact = 0.5
        self.assertAlmostEqual(
            tfact,
            _get_adjustment(4.2, 1995., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Good case - when event is in a previous completeness period
        self.assertAlmostEqual(
            tfact,
            _get_adjustment(4.7, 1985., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Bad case - below minimum completeness in file
        self.assertFalse(
            _get_adjustment(3.8, 1990., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Bad case - below an earlier completeness threshold
        self.assertFalse(
            _get_adjustment(4.8, 1950., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Good case when only one completeness period is needed
        comp_table = np.array([[1960., 4.5]])
        self.assertAlmostEqual(
            1.0,
            _get_adjustment(5.0, 1990., comp_table[0, 1], comp_table[:, 0],
                            tfact))
        # Bad case when only one completeness period is needed
        self.assertFalse(
            _get_adjustment(4.0, 1990., comp_table[0, 1], comp_table[:, 0],
                            tfact))
    def test_get_adjustment_factor(self):
        '''
        Tests the function that should return an input adjustment factor if
        the magnitude is from a "complete" event - and a zero otherwise
        '''
        # Good case - when event is in the first completeness period
        comp_table = np.array([[1990., 4.0],
                               [1960., 4.5],
                               [1900., 5.5]])
        self.catalogue.data['magnitude'] = np.array([4.5, 5.7])
        comp_table = utils.get_even_magnitude_completeness(comp_table,
                                                           self.catalogue)[0]

        tfact = 0.5
        self.assertAlmostEqual(tfact,
            _get_adjustment(4.2, 1995., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Good case - when event is in a previous completeness period
        self.assertAlmostEqual(tfact,
            _get_adjustment(4.7, 1985., comp_table[0, 1], comp_table[:, 0],
                            tfact))

        # Bad case - below minimum completeness in file
        self.assertFalse(_get_adjustment(3.8, 1990., comp_table[0, 1],
                                         comp_table[:, 0], tfact))

        # Bad case - below an earlier completeness threshold
        self.assertFalse(_get_adjustment(4.8, 1950., comp_table[0, 1],
                                         comp_table[:, 0], tfact))

        # Good case when only one completeness period is needed
        comp_table = np.array([[1960., 4.5]])
        self.assertAlmostEqual(1.0,
            _get_adjustment(5.0, 1990., comp_table[0, 1], comp_table[:, 0],
                            tfact))
        # Bad case when only one completeness period is needed
        self.assertFalse(_get_adjustment(4.0, 1990., comp_table[0, 1],
                                         comp_table[:, 0], tfact))