コード例 #1
0
 def test_missing_value_no_default(self):
     # Tests the case when the attribute is missing and the use_defaults
     # option is not selected. Should raise ValueError
     with self.assertRaises(ValueError) as ae:
         conv.mag_scale_rel_to_hazardlib('rubbish')
     self.assertEqual(str(ae.exception),
                      'Magnitude scaling relation rubbish not supported!')
コード例 #2
0
 def test_missing_value_no_default(self):
     # Tests the case when the attribute is missing and the use_defaults
     # option is not selected. Should raise ValueError
     with self.assertRaises(ValueError) as ae:
         conv.mag_scale_rel_to_hazardlib('rubbish')
     self.assertEqual(str(ae.exception),
                      'Magnitude scaling relation rubbish not supported!')
コード例 #3
0
ファイル: simple_fault_source.py プロジェクト: nackerley/hmtk
 def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
     """
     Returns an instance of the :class:
     openquake.hazardlib.source.simple_fault.SimpleFaultSource
     :param tom:
          Temporal occurrance model
     :param float mesh_spacing:
          Mesh spacing
     
     """
     if not self.mfd:
         raise ValueError("Cannot write to hazardlib without MFD")
     return SimpleFaultSource(
         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.fault_trace,
         self.dip,
         self.rake)
コード例 #4
0
ファイル: point_source.py プロジェクト: g-weatherill/hmtk
    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))
コード例 #5
0
ファイル: area_source.py プロジェクト: g-weatherill/hmtk
 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)
コード例 #6
0
ファイル: area_source.py プロジェクト: francescovisini/hmtk
 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)
コード例 #7
0
 def test_missing_value_with_default(self):
     """
     Tests the case when the attibute is missing but the use_defaults
     option is selected
     """
     self.assertIsInstance(
         conv.mag_scale_rel_to_hazardlib(None, use_default=True), WC1994)
コード例 #8
0
 def test_missing_value_with_default(self):
     """
     Tests the case when the attibute is missing but the use_defaults
     option is selected
     """
     self.assertIsInstance(
         conv.mag_scale_rel_to_hazardlib(None, use_default=True),
         WC1994)
コード例 #9
0
 def test_missing_value_no_default(self):
     '''
     Tests the case when the attribute is missing and the use_defaults
     option is not selected. Should raise ValueError
     '''
     with self.assertRaises(ValueError) as ae:
         _ = conv.mag_scale_rel_to_hazardlib('rubbish')
         self.assertEqual(ae.exception.message,
                          'Magnitude Scaling Relation rubbish Defined!')
コード例 #10
0
 def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
     """
     Creates an instance of the source model as :class:
     openquake.hazardlib.source.complex_fault.ComplexFaultSource
     """
     if not self.mfd:
         raise ValueError("Cannot write to hazardlib without MFD")
     return ComplexFaultSource(
         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.fault_edges, self.rake)
コード例 #11
0
 def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
     """
     Creates an instance of the source model as :class:
     openquake.hazardlib.source.complex_fault.ComplexFaultSource
     """
     return ComplexFaultSource(
         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.fault_edges,
         self.rake)
コード例 #12
0
 def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
     """
     Returns an instance of the :class:
     openquake.hazardlib.source.simple_fault.SimpleFaultSource
     :param tom:
          Temporal occurrance model
     :param float mesh_spacing:
          Mesh spacing
     
     """
     if not self.mfd:
         raise ValueError("Cannot write to hazardlib without MFD")
     return SimpleFaultSource(
         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.fault_trace, self.dip, self.rake)
コード例 #13
0
 def create_oqhazardlib_source(self, tom, mesh_spacing, use_defaults=False):
     """
     Creates an instance of the source model as :class:
     openquake.hazardlib.source.complex_fault.ComplexFaultSource
     """
     if not self.mfd:
         raise ValueError("Cannot write to hazardlib without MFD")
     return ComplexFaultSource(
         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.fault_edges,
         self.rake)
コード例 #14
0
ファイル: point_source.py プロジェクト: lcui24/hmtk
    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))
コード例 #15
0
 def test_valid_msr_in_str_format(self):
     """
     Tests the case when the input is already in hazardlib format
     """
     self.assertIsInstance(conv.mag_scale_rel_to_hazardlib('WC1994'),
                           WC1994)
コード例 #16
0
 def test_valid_msr_in_str_format(self):
     """
     Tests the case when the input is already in hazardlib format
     """
     self.assertIsInstance(conv.mag_scale_rel_to_hazardlib('WC1994'),
                           WC1994)