def build_rupture_from_file(rupture_file, simple_mesh_spacing=1.0,
        complex_mesh_spacing=1.0):
    """
    Parses a rupture from the OpenQuake nrml 4.0 format and parses it to
    an instance of :class: openquake.hazardlib.source.rupture.Rupture
    """
    rup_node, = read_nodes(rupture_file, lambda el: 'Rupture' in el.tag,
                           nodefactory['sourceModel'])
    conv = RuptureConverter(simple_mesh_spacing,
                            complex_mesh_spacing)
    return conv.convert_node(rup_node)
예제 #2
0
 def test_planar(self):
     fh, self.path = tempfile.mkstemp(suffix='.hdf5')
     os.close(fh)
     sids = numpy.array([0], numpy.uint32)
     events = numpy.array([(0, 1, 1, 0)], calc.event_dt)
     [rup_node] = nrml.read(planar)
     conv = RuptureConverter(1.0, 1.0)
     rup = conv.convert_node(rup_node)
     rup.seed = 0
     ebr1 = calc.EBRupture(rup, sids, events, '*', 0, 0)
     with hdf5.File(self.path, 'w') as f:
         f['ebr'] = ebr1
     with hdf5.File(self.path, 'r') as f:
         ebr2 = f['ebr']
     [s1] = ebr1.rupture.surface.surfaces
     [s2] = ebr2.rupture.surface.surfaces
     self.assertEqual(s1.__class__.__name__, s2.__class__.__name__)