Example #1
0
    def create_oqnrml_source(self, use_defaults=False):
        '''
        Converts the complex source into an instance of the :class:
        openquake.nrmllib.models.ComplexFaultSource

        :param bool use_defaults:
            If set to True, will input default values of rupture aspect
            ratio and magnitude scaling relation where missing. If false,
            value errors will be raised if information is missing.
        '''
        if not isinstance(self.rake, float):
            raise ValueError('Cannot create complex source - rake is missing!')

        # Render complex geometry to linestrings
        complex_geometry = conv.complex_trace_to_wkt_linestring(
            self.fault_edges)

        return models.ComplexFaultSource(
            self.id,
            self.name,
            self.trt,
            complex_geometry,
            conv.render_mag_scale_rel(self.mag_scale_rel, use_defaults),
            conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
            conv.render_mfd(self.mfd),
            self.rake)
Example #2
0
    def create_oqnrml_source(self, use_defaults=False):
        '''
        Converts the complex source into an instance of the :class:
        openquake.nrmllib.models.ComplexFaultSource

        :param bool use_defaults:
            If set to True, will input default values of rupture aspect
            ratio and magnitude scaling relation where missing. If false,
            value errors will be raised if information is missing.
        '''
        if not isinstance(self.rake, float):
            raise ValueError('Cannot create complex source - rake is missing!')

        # Render complex geometry to linestrings
        complex_geometry = conv.complex_trace_to_wkt_linestring(
            self.fault_edges)

        return models.ComplexFaultSource(
            self.id,
            self.name,
            self.trt,
            complex_geometry,
            conv.render_mag_scale_rel(self.mag_scale_rel, use_defaults),
            conv.render_aspect_ratio(self.rupt_aspect_ratio, use_defaults),
            conv.render_mfd(self.mfd),
            self.rake)
 def test_complex_trace_to_wkt(self):
     '''
     Tests the conversion of a list of instances of the :class:
     openquake.hazardlib.geo.line.Line to :class:
     models.ComplexFaultGeometry
     '''
     model = conv.complex_trace_to_wkt_linestring(self.complex_edge)
     self.assertEqual(model.top_edge_wkt,
                      'LINESTRING (10.5 10.5 1.0, 11.35 11.45 2.0)')
     self.assertListEqual(model.int_edges,
                          ['LINESTRING (10.5 10.5 20.0, 11.35 11.45 21.0)'])
     self.assertEqual(model.bottom_edge_wkt,
                      'LINESTRING (10.5 10.5 40.0, 11.35 11.45 40.0)')
 def test_complex_trace_to_wkt(self):
     '''
     Tests the conversion of a list of instances of the :class:
     openquake.hazardlib.geo.line.Line to :class:
     models.ComplexFaultGeometry
     '''
     model = conv.complex_trace_to_wkt_linestring(self.complex_edge)
     self.assertEqual(model.top_edge_wkt,
                     'LINESTRING (10.5 10.5 1.0, 11.35 11.45 2.0)')
     self.assertListEqual(model.int_edges,
                          ['LINESTRING (10.5 10.5 20.0, 11.35 11.45 21.0)'])
     self.assertEqual(model.bottom_edge_wkt,
                     'LINESTRING (10.5 10.5 40.0, 11.35 11.45 40.0)')