def test_render_nodal_planes_null(self):
        # Tests the rendering of the nodal planes when no input is specified
        # and no defaults are permitted. Should raise ValueError

        with self.assertRaises(ValueError) as ae:
            conv.npd_to_pmf(None)
        self.assertEqual(str(ae.exception),
                         'Nodal Plane distribution not defined')
Esempio n. 2
0
    def test_render_nodal_planes_null(self):
        # Tests the rendering of the nodal planes when no input is specified
        # and no defaults are permitted. Should raise ValueError

        with self.assertRaises(ValueError) as ae:
            conv.npd_to_pmf(None)
        self.assertEqual(str(ae.exception),
                         'Nodal Plane distribution not defined')
Esempio n. 3
0
    def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
        """
        Converts the point source model into an instance of the :class:
        openquake.hazardlib.source.point_source.PointSource

        :param bool use_defaults:
            If set to true, will use put in default values for magitude
            scaling relation, rupture aspect ratio, nodal plane distribution
            or hypocentral depth distribution where missing. If set to False
            then value errors will be raised when information is missing.
        """
        if not self.mfd:
            raise ValueError("Cannot write to hazardlib without MFD")
        return PointSource(
            self.id,
            self.name,
            self.trt,
            self.mfd,
            mesh_spacing,
            conv.mag_scale_rel_to_hazardlib(self.mag_scale_rel, use_defaults),
            conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
            tom,
            self.upper_depth,
            self.lower_depth,
            self.geometry,
            conv.npd_to_pmf(self.nodal_plane_dist, use_defaults),
            conv.hdd_to_pmf(self.hypo_depth_dist, use_defaults))
Esempio n. 4
0
 def create_oqhazardlib_source(self,
                               tom,
                               mesh_spacing,
                               area_discretisation,
                               use_defaults=False):
     """
     Converts the source model into an instance of the :class:
     openquake.hazardlib.source.area.AreaSource
     
     :param tom:
         Temporal Occurrence model as instance of :class:
         openquake.hazardlib.tom.TOM
     :param float mesh_spacing:
         Mesh spacing
     """
     if not self.mfd:
         raise ValueError("Cannot write to hazardlib without MFD")
     return AreaSource(
         self.id, self.name, self.trt, self.mfd, mesh_spacing,
         conv.mag_scale_rel_to_hazardlib(self.mag_scale_rel, use_defaults),
         conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
         tom, self.upper_depth, self.lower_depth,
         conv.npd_to_pmf(self.nodal_plane_dist, use_defaults),
         conv.hdd_to_pmf(self.hypo_depth_dist,
                         use_defaults), self.geometry, area_discretisation)
Esempio n. 5
0
 def create_oqhazardlib_source(self, tom, mesh_spacing, area_discretisation,
         use_defaults=False):
     """
     Converts the source model into an instance of the :class:
     openquake.hazardlib.source.area.AreaSource
     
     :param tom:
         Temporal Occurrence model as instance of :class:
         openquake.hazardlib.tom.TOM
     :param float mesh_spacing:
         Mesh spacing
     """
     return AreaSource(
         self.id,
         self.name,
         self.trt,
         conv.mfd_to_hazardlib(self.mfd),
         mesh_spacing,
         conv.mag_scale_rel_to_hazardlib(self.mag_scale_rel, use_defaults),
         conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
         tom,
         self.upper_depth,
         self.lower_depth,
         conv.npd_to_pmf(self.nodal_plane_dist, use_defaults),
         conv.hdd_to_pmf(self.hypo_depth_dist, use_defaults),
         self.geometry,
         area_discretisation)
Esempio n. 6
0
    def test_default(self):
        # Tests the case when the default class is raised

        output = conv.npd_to_pmf(None, True)
        self.assertAlmostEqual(output.data[0][0], 1.0)
        self.assertAlmostEqual(output.data[0][1].strike, 0.)
        self.assertAlmostEqual(output.data[0][1].dip, 90.)
        self.assertAlmostEqual(output.data[0][1].rake, 0.)
    def test_default(self):
        # Tests the case when the default class is raised

        output = conv.npd_to_pmf(None, True)
        self.assertAlmostEqual(output.data[0][0], 1.0)
        self.assertAlmostEqual(output.data[0][1].strike, 0.)
        self.assertAlmostEqual(output.data[0][1].dip, 90.)
        self.assertAlmostEqual(output.data[0][1].rake, 0.)
Esempio n. 8
0
    def test_class_as_pmf(self):
        # Tests the case when a PMF is already input

        output = conv.npd_to_pmf(self.npd_as_pmf)
        self.assertAlmostEqual(output.data[0][0], 0.5)
        self.assertAlmostEqual(output.data[0][1].strike, 0.)
        self.assertAlmostEqual(output.data[0][1].dip, 90.)
        self.assertAlmostEqual(output.data[0][1].rake, 0.)
        self.assertAlmostEqual(output.data[1][0], 0.5)
        self.assertAlmostEqual(output.data[1][1].strike, 90.)
        self.assertAlmostEqual(output.data[1][1].dip, 90.)
        self.assertAlmostEqual(output.data[1][1].rake, 180.)
    def test_class_as_pmf(self):
        # Tests the case when a PMF is already input

        output = conv.npd_to_pmf(self.npd_as_pmf)
        self.assertAlmostEqual(output.data[0][0], 0.5)
        self.assertAlmostEqual(output.data[0][1].strike, 0.)
        self.assertAlmostEqual(output.data[0][1].dip, 90.)
        self.assertAlmostEqual(output.data[0][1].rake, 0.)
        self.assertAlmostEqual(output.data[1][0], 0.5)
        self.assertAlmostEqual(output.data[1][1].strike, 90.)
        self.assertAlmostEqual(output.data[1][1].dip, 90.)
        self.assertAlmostEqual(output.data[1][1].rake, 180.)
Esempio n. 10
0
    def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
        """
        Converts the point source model into an instance of the :class:
        openquake.hazardlib.source.point_source.PointSource

        :param bool use_defaults:
            If set to true, will use put in default values for magitude
            scaling relation, rupture aspect ratio, nodal plane distribution
            or hypocentral depth distribution where missing. If set to False
            then value errors will be raised when information is missing.
        """
        return PointSource(
            self.id, self.name, self.trt, conv.mfd_to_hazardlib(self.mfd),
            mesh_spacing,
            conv.mag_scale_rel_to_hazardlib(self.mag_scale_rel, use_defaults),
            conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
            tom, self.upper_depth, self.lower_depth, self.geometry,
            conv.npd_to_pmf(self.nodal_plane_dist, use_defaults),
            conv.hdd_to_pmf(self.hypo_depth_dist, use_defaults))