Exemplo n.º 1
0
    def test_good_input(self):
        """

        """
        self.site_array = np.array(
                [[1.0, 30.0, 35.0, 500.0, 1.0, 1.0, 100.0, 0.],
                 [2.0, 31.0, 36.0, 200.0, 0.0, 5.0, 500.0, 0.],
                 [3.0, 32.0, 37.0, 900.0, 1.0, 1.0, 200.0, 1.]])
        output = haz.site_array_to_collection(self.site_array)
        self.assertTrue(isinstance(output, SiteCollection))
        self.assertEqual(output.total_sites, 3)
        for iloc in range(0, output.total_sites):
            #pnt = Point(self.site_array[iloc, 1], self.site_array[iloc, 2])
            self.assertEqual(output.sids[iloc], iloc + 1)
            self.assertAlmostEqual(output.lons[iloc],
                                   self.site_array[iloc, 1])
            self.assertAlmostEqual(output.lats[iloc],
                                   self.site_array[iloc, 2])
            self.assertAlmostEqual(output._vs30[iloc],
                                   self.site_array[iloc, 3])
            self.assertEqual(output._vs30measured[iloc],
                             self.site_array[iloc, 4].astype(bool))
            self.assertAlmostEqual(output._z1pt0[iloc],
                                   self.site_array[iloc, 5])
            self.assertAlmostEqual(output._z2pt5[iloc],
                                   self.site_array[iloc, 6])
            self.assertEqual(output._backarc[iloc],
                             self.site_array[iloc, 7].astype(bool))
Exemplo n.º 2
0
    def test_good_input(self):
        """

        """
        self.site_array = np.array(
            [[1.0, 30.0, 35.0, 500.0, 1.0, 1.0, 100.0, 0.],
             [2.0, 31.0, 36.0, 200.0, 0.0, 5.0, 500.0, 0.],
             [3.0, 32.0, 37.0, 900.0, 1.0, 1.0, 200.0, 1.]])
        output = haz.site_array_to_collection(self.site_array)
        self.assertTrue(isinstance(output, SiteCollection))
        self.assertEqual(output.total_sites, 3)
        for iloc in range(0, output.total_sites):
            #pnt = Point(self.site_array[iloc, 1], self.site_array[iloc, 2])
            self.assertEqual(output.sids[iloc], iloc + 1)
            self.assertAlmostEqual(output.lons[iloc], self.site_array[iloc, 1])
            self.assertAlmostEqual(output.lats[iloc], self.site_array[iloc, 2])
            self.assertAlmostEqual(output._vs30[iloc], self.site_array[iloc,
                                                                       3])
            self.assertEqual(output._vs30measured[iloc],
                             self.site_array[iloc, 4].astype(bool))
            self.assertAlmostEqual(output._z1pt0[iloc], self.site_array[iloc,
                                                                        5])
            self.assertAlmostEqual(output._z2pt5[iloc], self.site_array[iloc,
                                                                        6])
            self.assertEqual(output._backarc[iloc],
                             self.site_array[iloc, 7].astype(bool))
Exemplo n.º 3
0
 def test_bad_input(self):
     """
     Tests that an error is raised when the input array does not have 7
     columns
     """
     self.site_array = np.array([[30.0, 35.0, 500.0, 1.0, 1.0, 100.0],
                                 [31.0, 36.0, 200.0, 0.0, 5.0, 500.0],
                                 [32.0, 37.0, 900.0, 1.0, 1.0, 200.0]])
     with self.assertRaises(ValueError) as ae:
          _ = haz.site_array_to_collection(self.site_array)
          self.assertEqual(ae.exception.message,
                           'Site array incorrectly formatted!')
Exemplo n.º 4
0
 def test_bad_input(self):
     """
     Tests that an error is raised when the input array does not have 7
     columns
     """
     self.site_array = np.array([[30.0, 35.0, 500.0, 1.0, 1.0, 100.0],
                                 [31.0, 36.0, 200.0, 0.0, 5.0, 500.0],
                                 [32.0, 37.0, 900.0, 1.0, 1.0, 200.0]])
     with self.assertRaises(ValueError) as ae:
         _ = haz.site_array_to_collection(self.site_array)
         self.assertEqual(ae.exception.message,
                          'Site array incorrectly formatted!')