Example #1
0
 def test_duplicate_id(self):
     parser = SourceModelParser(s.SourceConverter(
         investigation_time=50.,
         rupture_mesh_spacing=1,
         complex_fault_mesh_spacing=1,
         width_of_mfd_bin=0.1,
         area_source_discretization=10,
     ))
     with self.assertRaises(nrml.DuplicatedID):
         parser.parse_groups(DUPLICATE_ID_SRC_MODEL)
Example #2
0
 def test_is_writeable(self):
     parser = SourceModelParser(SourceConverter(50., 1., 10, 0.1, 10.))
     groups = map(copy.deepcopy, parser.parse_groups(ALT_MFDS))
     # there are a SimpleFaultSource and a CharacteristicFaultSource
     fd, fname = tempfile.mkstemp(suffix='.xml')
     with os.fdopen(fd, 'wb'):
         write_source_model(fname, groups, 'Test Source Model')
Example #3
0
 def test(self):
     mod = mock.Mock(
         reference_vs30_value=760,
         reference_vs30_type='measured',
         reference_depth_to_1pt0km_per_sec=100.,
         reference_depth_to_2pt5km_per_sec=5.0,
         reference_backarc=False)
     sitecol = site.SiteCollection.from_points([102.32], [-2.9107], mod)
     parser = SourceModelParser(s.SourceConverter(
         investigation_time=50.,
         rupture_mesh_spacing=1,  # km
         complex_fault_mesh_spacing=1,  # km
         width_of_mfd_bin=1.,  # for Truncated GR MFDs
         area_source_discretization=1.,  # km
     ))
     [[src]] = parser.parse_groups(self.bad_source)
     with self.assertRaises(AttributeError) as ctx, context(src):
         max_dist = 250
         # NB: with a distance of 200 km the error does not happen
         src.filter_sites_by_distance_to_source(max_dist, sitecol)
     self.assertIn('An error occurred with source id=61',
                   str(ctx.exception))