Ejemplo n.º 1
0
    def test_input_with_different_imls_to_imts(self):
        """
        If the number of IMTs and the number of IMLs is different (and IMLs
        is not 1) then the function cannot be mapped. Raise an error.
        """
        self.imt_list = ['PGA', 'PGV', 'SA(0.2)'] # 3 IMTs
        self.imls = [[0.005, 0.1, 0.5, 1.0], [1.0, 10.0, 50.0, 100.0]] # 2 IMLs

        with self.assertRaises(ValueError) as ae:
            _ = haz._check_imts_imls(self.imt_list, self.imls)
            self.assertEqual(
                ae.exception.message,
                'Number of IML sets must be 1 or equal to number of IMTs')
Ejemplo n.º 2
0
    def test_input_with_different_imls_to_imts(self):
        """
        If the number of IMTs and the number of IMLs is different (and IMLs
        is not 1) then the function cannot be mapped. Raise an error.
        """
        self.imt_list = ['PGA', 'PGV', 'SA(0.2)']  # 3 IMTs
        self.imls = [[0.005, 0.1, 0.5, 1.0], [1.0, 10.0, 50.0,
                                              100.0]]  # 2 IMLs

        with self.assertRaises(ValueError) as ae:
            _ = haz._check_imts_imls(self.imt_list, self.imls)
            self.assertEqual(
                ae.exception.message,
                'Number of IML sets must be 1 or equal to number of IMTs')
Ejemplo n.º 3
0
 def test_input_with_single_iml(self):
     """
     Checks that when a single IML is input, with multiple IMTs, then the
     same IML is used for all IMTS
     """
     self.imt_list = ['PGA', 'SA(0.2)']
     self.imls = [[0.005, 0.1, 0.5, 1.0]]
     output_imts = haz._check_imts_imls(self.imt_list, self.imls)
     #expected_keys = [PGA(), SA(period=0.2, damping=5.0)]
     expected_keys = ['PGA', 'SA(0.2)']
     self.assertListEqual(output_imts.keys(), expected_keys)
     for iloc, iml in enumerate(self.imls[0]):
         self.assertAlmostEqual(output_imts['PGA'][iloc], iml)
         self.assertAlmostEqual(output_imts['SA(0.2)'][iloc], iml)
Ejemplo n.º 4
0
 def test_input_with_same_imls_imts(self):
     """
     Checks that when the number of imls in the iml list is equal to the
     number of IMTs then the two are mapped correctly
     """
     self.imt_list = ['PGA', 'PGV']
     self.imls = [[0.005, 0.1, 0.5, 1.0], [1.0, 10.0, 50.0, 100.0]]
     output_imts = haz._check_imts_imls(self.imt_list, self.imls)
     expected_keys = ['PGA', 'PGV']
     self.assertListEqual(output_imts.keys(), expected_keys)
     for iloc in range(0, 4):
         self.assertAlmostEqual(output_imts['PGA'][iloc],
                                self.imls[0][iloc])
         self.assertAlmostEqual(output_imts['PGV'][iloc],
                                self.imls[1][iloc])
Ejemplo n.º 5
0
 def test_input_with_single_iml(self):
     """
     Checks that when a single IML is input, with multiple IMTs, then the
     same IML is used for all IMTS
     """
     self.imt_list = ['PGA', 'SA(0.2)']
     self.imls = [[0.005, 0.1, 0.5, 1.0]]
     output_imts = haz._check_imts_imls(self.imt_list, self.imls)
     expected_keys = [PGA(), SA(period=0.2, damping=5.0)]
     self.assertListEqual(output_imts.keys(), expected_keys)
     for iloc, iml in enumerate(self.imls[0]):
         self.assertAlmostEqual(output_imts[PGA()][iloc], iml)
         self.assertAlmostEqual(
             output_imts[SA(period=0.2, damping=5.0)][iloc],
             iml)
Ejemplo n.º 6
0
 def test_input_with_same_imls_imts(self):
     """
     Checks that when the number of imls in the iml list is equal to the
     number of IMTs then the two are mapped correctly
     """
     self.imt_list = ['PGA', 'PGV']
     self.imls = [[0.005, 0.1, 0.5, 1.0], [1.0, 10.0, 50.0, 100.0]]
     output_imts = haz._check_imts_imls(self.imt_list, self.imls)
     expected_keys = ['PGA', 'PGV']
     self.assertListEqual(output_imts.keys(), expected_keys)
     for iloc in range(0, 4):
         self.assertAlmostEqual(output_imts['PGA'][iloc],
                                self.imls[0][iloc])
         self.assertAlmostEqual(output_imts['PGV'][iloc],
                                self.imls[1][iloc])