def test_kijko_npg_intfunc_simps(self): ''' Tests the integration function using Simpson's rule ''' # Simple test using test catalogue data - verified against # implementation in Kijko's own code # Get the largest 100 events from the catalogue idx = np.flipud(np.argsort(self.catalogue.data['magnitude'])) test_mag = self.catalogue.data['magnitude'][idx[:100]] h_fact = self.model.h_smooth(test_mag) mvals = _get_exponential_spaced_values( np.min(test_mag), np.max(test_mag), 51) self.assertAlmostEqual( 0.11026752, self.model._kijko_npg_intfunc_simps( mvals, test_mag, np.max(test_mag), h_fact, 100.))
def test_kijko_npg_intfunc_simps(self): ''' Tests the integration function using Simpson's rule ''' # Simple test using test catalogue data - verified against # implementation in Kijko's own code # Get the largest 100 events from the catalogue idx = np.flipud(np.argsort(self.catalogue.data['magnitude'])) test_mag = self.catalogue.data['magnitude'][idx[:100]] h_fact = self.model.h_smooth(test_mag) mvals = _get_exponential_spaced_values(np.min(test_mag), np.max(test_mag), 51) self.assertAlmostEqual( 0.11026752, self.model._kijko_npg_intfunc_simps(mvals, test_mag, np.max(test_mag), h_fact, 100.))
def test_get_exponential_values(self): # Tests the function to derive an exponentially spaced set of values. # Tested against Kijko implementation min_mag = 5.8 max_mag = 7.4 expected_output = np.array( [5.8, 5.87609089, 5.94679912, 6.01283617, 6.07478116, 6.13311177, 6.18822664, 6.24046187, 6.29010351, 6.33739696, 6.38255438, 6.42576041, 6.46717674, 6.50694576, 6.5451935, 6.58203209, 6.61756168, 6.65187211, 6.68504428, 6.71715129, 6.74825943, 6.77842898, 6.80771492, 6.83616754, 6.86383296, 6.89075356, 6.9169684, 6.94251354, 6.96742235, 6.99172576, 7.0154525, 7.0386293, 7.06128109, 7.08343111, 7.10510113, 7.1263115, 7.14708132, 7.16742851, 7.18736994, 7.20692147, 7.22609806, 7.24491382, 7.26338207, 7.28151542, 7.2993258, 7.31682451, 7.33402228, 7.35092928, 7.36755517, 7.38390916, 7.4]) np.testing.assert_almost_equal( expected_output, _get_exponential_spaced_values(min_mag, max_mag, 51))
def test_get_exponential_values(self): # Tests the function to derive an exponentially spaced set of values. # Tested against Kijko implementation min_mag = 5.8 max_mag = 7.4 expected_output = np.array([ 5.8, 5.87609089, 5.94679912, 6.01283617, 6.07478116, 6.13311177, 6.18822664, 6.24046187, 6.29010351, 6.33739696, 6.38255438, 6.42576041, 6.46717674, 6.50694576, 6.5451935, 6.58203209, 6.61756168, 6.65187211, 6.68504428, 6.71715129, 6.74825943, 6.77842898, 6.80771492, 6.83616754, 6.86383296, 6.89075356, 6.9169684, 6.94251354, 6.96742235, 6.99172576, 7.0154525, 7.0386293, 7.06128109, 7.08343111, 7.10510113, 7.1263115, 7.14708132, 7.16742851, 7.18736994, 7.20692147, 7.22609806, 7.24491382, 7.26338207, 7.28151542, 7.2993258, 7.31682451, 7.33402228, 7.35092928, 7.36755517, 7.38390916, 7.4 ]) np.testing.assert_almost_equal( expected_output, _get_exponential_spaced_values(min_mag, max_mag, 51))