def test_retreival_tables_good_no_interp(self):
     """
     Tests the retreival of the IML tables for 'good' conditions without
     applying magnitude interpolations
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     # PGA
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGA(), "IMLs"),
         np.array([2., 1., 0.5]))
     # PGV
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGV(), "IMLs"),
         np.array([20., 10., 5.]), 5)
     # SA(1.0)
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.SA(1.0), "IMLs"),
         np.array([2.0, 1., 0.5]))
     # Also for standard deviations
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGA(), "Total"),
         0.5 * np.ones(3))
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.SA(1.0), "Total"),
         0.8 * np.ones(3))
 def test_retreival_tables_good_no_interp(self):
     """
     Tests the retreival of the IML tables for 'good' conditions without
     applying magnitude interpolations
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     # PGA
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGA(), "IMLs"),
         np.array([2., 1., 0.5]))
     # PGV
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGV(), "IMLs"),
         np.array([20., 10., 5.]),
         5)
     # SA(1.0)
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.SA(1.0), "IMLs"),
         np.array([2.0, 1., 0.5]))
     # Also for standard deviations
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.PGA(), "Total"),
         0.5 * np.ones(3))
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.0, imt_module.SA(1.0), "Total"),
         0.8 * np.ones(3))
 def test_retreival_tables_outside_period_range(self):
     """
     Tests that an error is raised when inputting a period value
     outside the supported range
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     with self.assertRaises(ValueError) as ve:
         gsim._return_tables(6.0, imt_module.SA(2.5), "IMLs")
     self.assertEqual(
         str(ve.exception),
         "Spectral period 2.500 outside of valid range (0.100 to 2.000)")
 def test_retreival_tables_outside_mag_range(self):
     """
     Tests that an error is raised when inputting a magnitude value
     outside the supported range
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     with self.assertRaises(ValueError) as ve:
         gsim._return_tables(7.5, imt_module.PGA(), "IMLs")
     self.assertEqual(
         str(ve.exception),
         "Magnitude 7.50 outside of supported range (5.00 to 7.00)")
 def test_retreival_tables_outside_period_range(self):
     """
     Tests that an error is raised when inputting a period value
     outside the supported range
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     with self.assertRaises(ValueError) as ve:
         gsim._return_tables(6.0, imt_module.SA(2.5), "IMLs")
     self.assertEqual(
         str(ve.exception),
         "Spectral period 2.500 outside of valid range (0.100 to 2.000)")
 def test_retreival_tables_outside_mag_range(self):
     """
     Tests that an error is raised when inputting a magnitude value
     outside the supported range
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     with self.assertRaises(ValueError) as ve:
         gsim._return_tables(7.5, imt_module.PGA(), "IMLs")
     self.assertEqual(
         str(ve.exception),
         "Magnitude 7.50 outside of supported range (5.00 to 7.00)")
 def test_retreival_tables_good_interp(self):
     """
     Tests the retreival of the IML tables for 'good' conditions with
     magnitude interpolations
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     expected_table_pgv = np.array([midpoint(20., 40.),
                                    midpoint(10., 20.),
                                    midpoint(5., 10.)])
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.5, imt_module.PGV(), "IMLs"),
         expected_table_pgv,
         5)
     expected_table_sa1 = np.array([midpoint(2., 4.),
                                    midpoint(1., 2.),
                                    midpoint(0.5, 1.)])
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.5, imt_module.SA(1.0), "IMLs"),
         expected_table_sa1)
Esempio n. 8
0
 def test_retreival_tables_good_interp(self):
     """
     Tests the retreival of the IML tables for 'good' conditions with
     magnitude interpolations
     """
     gsim = GMPETable(gmpe_table=self.TABLE_FILE)
     expected_table_pgv = np.array([midpoint(20., 40.),
                                    midpoint(10., 20.),
                                    midpoint(5., 10.)])
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.5, imt_module.PGV(), "IMLs"),
         expected_table_pgv,
         5)
     expected_table_sa1 = np.array([midpoint(2., 4.),
                                    midpoint(1., 2.),
                                    midpoint(0.5, 1.)])
     np.testing.assert_array_almost_equal(
         gsim._return_tables(6.5, imt_module.SA(1.0), "IMLs"),
         expected_table_sa1)