def test_geometry_inputs(self): ''' Tests the geometry definitions ''' simple_point = Point(2.0, 3.0) simple_point_array = np.array([2.0, 3.0]) # Using nhlib.geo.polygon.Polygon class as input self.point_source.create_geometry(simple_point, 0.0, 30.0) # Check that geometry is an instance of nhlib.geo.polygon.Polygon self.assertTrue(isinstance(self.point_source.geometry, Point)) self.assertAlmostEqual(self.point_source.geometry.longitude, 2.0) self.assertAlmostEqual(self.point_source.geometry.latitude, 3.0) self.assertAlmostEqual(self.point_source.geometry.depth, 0.0) self.assertAlmostEqual(0.0, self.point_source.upper_depth) self.assertAlmostEqual(30.0, self.point_source.lower_depth) self.point_source = mtkPointSource('101', 'A Point Source') # Using numpy array as input self.point_source.create_geometry(simple_point_array, 0.0, 30.0) self.assertTrue(isinstance(self.point_source.geometry, Point)) self.assertAlmostEqual(self.point_source.geometry.longitude, 2.0) self.assertAlmostEqual(self.point_source.geometry.latitude, 3.0) self.assertAlmostEqual(self.point_source.geometry.depth, 0.0) self.assertAlmostEqual(0.0, self.point_source.upper_depth) self.assertAlmostEqual(30.0, self.point_source.lower_depth) # For any other input type - check ValueError is raised self.point_source = mtkPointSource('101', 'A Point Source') with self.assertRaises(ValueError) as ver: self.point_source.create_geometry('a bad input', 0.0, 30.0) self.assertEqual(ver.exception.message, 'Unrecognised or unsupported geometry definition')
def test_create_oq_hazardlib_point_source(self): """ Tests the function to create a point source model """ self.point_source = mtkPointSource('001', 'A Point Source', trt='Active Shallow Crust', geometry = Point(10., 10.), upper_depth = 0., lower_depth = 20., mag_scale_rel=None, rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=5.0, max_mag=8.0), nodal_plane_dist=None, hypo_depth_dist=None) test_source = self.point_source.create_oqhazardlib_source(TOM, 2.0, True) self.assertIsInstance(test_source, PointSource) self.assertIsInstance(test_source.mfd, TruncatedGRMFD) self.assertAlmostEqual(test_source.mfd.b_val, 1.0) self.assertIsInstance(test_source.nodal_plane_distribution, PMF) self.assertIsInstance(test_source.hypocenter_distribution, PMF) self.assertIsInstance(test_source.magnitude_scaling_relationship, WC1994)
def test_create_oqnmrl_point_source(self): ''' Tests the conversion of a point source to an instance of the :class: oqnrmllib.models.PointSource ''' # Define a complete source self.point_source = mtkPointSource('001', 'A Point Source', trt='Active Shallow Crust', geometry = Point(10., 10.), upper_depth = 0., lower_depth = 20., mag_scale_rel=None, rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=5.0, max_mag=8.0), nodal_plane_dist=None, hypo_depth_dist=None) expected_source = models.PointSource( '001', 'A Point Source', geometry=models.PointGeometry('POINT(10.0 10.0)', 0., 20.), mag_scale_rel='WC1994', rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=5.0, max_mag=8.0), nodal_plane_dist=None, hypo_depth_dist=None) test_source = self.point_source.create_oqnrml_source(use_defaults=True) self.assertTrue(isinstance(test_source, models.PointSource)) self.assertEqual(test_source.id, expected_source.id) self.assertEqual(test_source.name, expected_source.name) self.assertDictEqual(test_source.geometry.__dict__, expected_source.geometry.__dict__) self.assertAlmostEqual(test_source.mfd.b_val, expected_source.mfd.b_val)
def test_create_oq_hazardlib_point_source(self): """ Tests the function to create a point source model """ mfd1 = TruncatedGRMFD(5.0, 8.0, 0.1, 3.0, 1.0) self.point_source = mtkPointSource('001', 'A Point Source', trt='Active Shallow Crust', geometry = Point(10., 10.), upper_depth = 0., lower_depth = 20., mag_scale_rel=None, rupt_aspect_ratio=1.0, mfd=mfd1, nodal_plane_dist=None, hypo_depth_dist=None) test_source = self.point_source.create_oqhazardlib_source(TOM, 2.0, True) self.assertIsInstance(test_source, PointSource) self.assertIsInstance(test_source.mfd, TruncatedGRMFD) self.assertAlmostEqual(test_source.mfd.b_val, 1.0) self.assertIsInstance(test_source.nodal_plane_distribution, PMF) self.assertIsInstance(test_source.hypocenter_distribution, PMF) self.assertIsInstance(test_source.magnitude_scaling_relationship, WC1994)
def parse_point_source_node(node, mfd_spacing=0.1): """ Returns an "areaSource" node into an instance of the :class: hmtk.sources.area.mtkAreaSource """ assert "pointSource" in node.tag pnt_taglist = get_taglist(node) # Get metadata point_id, name, trt = (node.attrib["id"], node.attrib["name"], node.attrib["tectonicRegion"]) assert point_id # Defensive validation! # Process geometry location, upper_depth, lower_depth = node_to_point_geometry( node.nodes[pnt_taglist.index("pointGeometry")]) # Process scaling relation msr = node_to_scalerel(node.nodes[pnt_taglist.index("magScaleRel")]) # Process aspect ratio aspect = float_(node.nodes[pnt_taglist.index("ruptAspectRatio")].text) # Process MFD mfd = node_to_mfd(node, pnt_taglist) # Process nodal planes npds = node_to_nodal_planes( node.nodes[pnt_taglist.index("nodalPlaneDist")]) # Process hypocentral depths hdds = node_to_hdd(node.nodes[pnt_taglist.index("hypoDepthDist")]) return mtkPointSource(point_id, name, trt, geometry=location, upper_depth=upper_depth, lower_depth=lower_depth, mag_scale_rel=msr, rupt_aspect_ratio=aspect, mfd=mfd, nodal_plane_dist=npds, hypo_depth_dist=hdds)
def test_select_events_within_cell(self): ''' Tests the selection of events within a cell centred on the point ''' self.point_source = mtkPointSource('101', 'A Point Source') simple_point = Point(4.5, 4.5) self.point_source.create_geometry(simple_point, 0., 30.) self.catalogue = Catalogue() self.catalogue.data['eventID'] = np.arange(0, 7, 1) self.catalogue.data['longitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['latitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['depth'] = np.ones(7, dtype=float) selector0 = CatalogueSelector(self.catalogue) # Simple case - 200 km by 200 km cell centred on point self.point_source.select_catalogue_within_cell(selector0, 100.) np.testing.assert_array_almost_equal( np.array([4., 4.5, 5.]), self.point_source.catalogue.data['longitude']) np.testing.assert_array_almost_equal( np.array([4., 4.5, 5.]), self.point_source.catalogue.data['latitude']) np.testing.assert_array_almost_equal( np.array([1., 1., 1.]), self.point_source.catalogue.data['depth'])
def test_select_events_in_circular_distance(self): """ Basic test of method to select events within a distance of the point """ self.point_source = mtkPointSource("101", "A Point Source") simple_point = Point(4.5, 4.5) self.catalogue.data["eventID"] = np.arange(0, 7, 1) self.catalogue.data["longitude"] = np.arange(4.0, 7.5, 0.5) self.catalogue.data["latitude"] = np.arange(4.0, 7.5, 0.5) self.catalogue.data["depth"] = np.ones(7, dtype=float) # Simple Case - 100 km epicentral distance selector0 = CatalogueSelector(self.catalogue) self.point_source.create_geometry(simple_point, 0.0, 30.0) self.point_source.select_catalogue_within_distance(selector0, 100.0, "epicentral") np.testing.assert_array_almost_equal(np.array([0, 1, 2]), self.point_source.catalogue.data["eventID"]) np.testing.assert_array_almost_equal(np.array([4.0, 4.5, 5.0]), self.point_source.catalogue.data["longitude"]) np.testing.assert_array_almost_equal(np.array([4.0, 4.5, 5.0]), self.point_source.catalogue.data["latitude"]) np.testing.assert_array_almost_equal(np.array([1.0, 1.0, 1.0]), self.point_source.catalogue.data["depth"]) # Simple case - 100 km hypocentral distance (hypocentre at 70 km) self.point_source.select_catalogue_within_distance(selector0, 100.0, "hypocentral", 70.0) np.testing.assert_array_almost_equal(np.array([1]), self.point_source.catalogue.data["eventID"]) np.testing.assert_array_almost_equal(np.array([4.5]), self.point_source.catalogue.data["longitude"]) np.testing.assert_array_almost_equal(np.array([4.5]), self.point_source.catalogue.data["latitude"]) np.testing.assert_array_almost_equal(np.array([1.0]), self.point_source.catalogue.data["depth"])
def test_select_catalogue(self): ''' Tests the select_catalogue function - essentially a wrapper to the two selection functions ''' self.point_source = mtkPointSource('101', 'A Point Source') simple_point = Point(4.5, 4.5) self.point_source.create_geometry(simple_point, 0., 30.) # Bad case - no events in catalogue self.catalogue = Catalogue() selector0 = CatalogueSelector(self.catalogue) with self.assertRaises(ValueError) as ver: self.point_source.select_catalogue(selector0, 100.) self.assertEqual(ver.exception.message, 'No events found in catalogue!') # Create a catalogue self.catalogue = Catalogue() self.catalogue.data['eventID'] = np.arange(0, 7, 1) self.catalogue.data['longitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['latitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['depth'] = np.ones(7, dtype=float) selector0 = CatalogueSelector(self.catalogue) # To ensure that square function is called - compare against direct instance # First implementation - compare select within distance self.point_source.select_catalogue_within_distance(selector0, 100., 'epicentral') expected_catalogue = deepcopy(self.point_source.catalogue) self.point_source.catalogue = None # Reset catalogue self.point_source.select_catalogue(selector0, 100., 'circle') np.testing.assert_array_equal( self.point_source.catalogue.data['eventID'], expected_catalogue.data['eventID']) # Second implementation - compare select within cell expected_catalogue = None self.point_source.select_catalogue_within_cell(selector0, 150.) expected_catalogue = deepcopy(self.point_source.catalogue) self.point_source.catalogue = None # Reset catalogue self.point_source.select_catalogue(selector0, 150., 'square') np.testing.assert_array_equal( self.point_source.catalogue.data['eventID'], expected_catalogue.data['eventID']) # Finally ensure error is raised when input is neither 'circle' nor 'square' with self.assertRaises(ValueError) as ver: self.point_source.select_catalogue(selector0, 100., 'bad input') self.assertEqual(ver.exception.message, 'Unrecognised selection type for point source!')
def test_core_instantiation(self): ''' Simple test to ensure the class is correctly instantiated ''' self.source_model = mtkSourceModel('101', 'Model Name') self.assertEqual(self.source_model.id, '101') self.assertEqual(self.source_model.name, 'Model Name') # No sources on input self.assertEqual(self.source_model.get_number_sources(), 0) # Input correctly good_model = [mtkPointSource('101', 'Point 1'), mtkPointSource('102', 'Point 2')] self.source_model = mtkSourceModel('1001', 'Good Model', good_model) self.assertEqual(self.source_model.get_number_sources(), 2) # Input incorrectly - source not as list with self.assertRaises(ValueError) as ver: self.source_model = mtkSourceModel('1002', 'Bad Model', mtkPointSource('103', 'Point 3')) self.assertEqual(ver.exception.message, 'Sources must be input as list!')
def test_select_events_in_circular_distance(self): ''' Basic test of method to select events within a distance of the point ''' self.point_source = mtkPointSource('101', 'A Point Source') simple_point = Point(4.5, 4.5) self.catalogue.data['eventID'] = np.arange(0, 7, 1) self.catalogue.data['longitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['latitude'] = np.arange(4.0, 7.5, 0.5) self.catalogue.data['depth'] = np.ones(7, dtype=float) # Simple Case - 100 km epicentral distance selector0 = CatalogueSelector(self.catalogue) self.point_source.create_geometry(simple_point, 0., 30.) self.point_source.select_catalogue_within_distance(selector0, 100., 'epicentral') np.testing.assert_array_almost_equal( np.array([0, 1, 2]), self.point_source.catalogue.data['eventID']) np.testing.assert_array_almost_equal( np.array([4., 4.5, 5.]), self.point_source.catalogue.data['longitude']) np.testing.assert_array_almost_equal( np.array([4., 4.5, 5.]), self.point_source.catalogue.data['latitude']) np.testing.assert_array_almost_equal( np.array([1., 1., 1.]), self.point_source.catalogue.data['depth']) # Simple case - 100 km hypocentral distance (hypocentre at 70 km) self.point_source.select_catalogue_within_distance(selector0, 100., 'hypocentral', 70.) np.testing.assert_array_almost_equal( np.array([1]), self.point_source.catalogue.data['eventID']) np.testing.assert_array_almost_equal( np.array([4.5]), self.point_source.catalogue.data['longitude']) np.testing.assert_array_almost_equal( np.array([4.5]), self.point_source.catalogue.data['latitude']) np.testing.assert_array_almost_equal( np.array([1.]), self.point_source.catalogue.data['depth'])
def test_create_oqnmrl_point_source(self): ''' Tests the conversion of a point source to an instance of the :class: oqnrmllib.models.PointSource ''' # Define a complete source self.point_source = mtkPointSource('001', 'A Point Source', trt='Active Shallow Crust', geometry=Point(10., 10.), upper_depth=0., lower_depth=20., mag_scale_rel=None, rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=5.0, max_mag=8.0), nodal_plane_dist=None, hypo_depth_dist=None) expected_source = models.PointSource('001', 'A Point Source', geometry=models.PointGeometry( 'POINT(10.0 10.0)', 0., 20.), mag_scale_rel='WC1994', rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=5.0, max_mag=8.0), nodal_plane_dist=None, hypo_depth_dist=None) test_source = self.point_source.create_oqnrml_source(use_defaults=True) self.assertTrue(isinstance(test_source, models.PointSource)) self.assertEqual(test_source.id, expected_source.id) self.assertEqual(test_source.name, expected_source.name) self.assertDictEqual(test_source.geometry.__dict__, expected_source.geometry.__dict__) self.assertAlmostEqual(test_source.mfd.b_val, expected_source.mfd.b_val)
def _parse_point(cls, src_elem): """ :param src_elem: :class:`lxml.etree._Element` instance representing a source. :returns: Fully populated :class:`openquake.nrmllib.models.PointSource` object. """ # Instantiate mtkPointSource class with identifier and name point = mtkPointSource(src_elem.get('id'), src_elem.get('name')) print 'Point Source - ID: %s, name: %s' % (point.id, point.name) # Set common attributes cls._set_common_attrs(point, src_elem) # Define the geometry [gml_pos] = _xpath(src_elem, './/gml:pos') coords = gml_pos.text.split() input_point = Point(float(coords[0]), float(coords[1])) if _xpath(src_elem, './/nrml:upperSeismoDepth')[0].text: upper_seismo_depth = float( _xpath(src_elem, './/nrml:upperSeismoDepth')[0].text) else: upper_seismo_depth = None if _xpath(src_elem, './/nrml:lowerSeismoDepth')[0].text: lower_seismo_depth = float( _xpath(src_elem, './/nrml:lowerSeismoDepth')[0].text) else: lower_seismo_depth = None point.create_geometry(input_point, upper_seismo_depth, lower_seismo_depth) point.mfd = cls._parse_mfd(src_elem) point.nodal_plane_dist = cls._parse_nodal_plane_dist(src_elem) point.hypo_depth_dist = cls._parse_hypo_depth_dist(src_elem) return point
def test_select_events_within_cell(self): """ Tests the selection of events within a cell centred on the point """ self.point_source = mtkPointSource("101", "A Point Source") simple_point = Point(4.5, 4.5) self.point_source.create_geometry(simple_point, 0.0, 30.0) self.catalogue = Catalogue() self.catalogue.data["eventID"] = np.arange(0, 7, 1) self.catalogue.data["longitude"] = np.arange(4.0, 7.5, 0.5) self.catalogue.data["latitude"] = np.arange(4.0, 7.5, 0.5) self.catalogue.data["depth"] = np.ones(7, dtype=float) selector0 = CatalogueSelector(self.catalogue) # Simple case - 200 km by 200 km cell centred on point self.point_source.select_catalogue_within_cell(selector0, 100.0) np.testing.assert_array_almost_equal(np.array([4.0, 4.5, 5.0]), self.point_source.catalogue.data["longitude"]) np.testing.assert_array_almost_equal(np.array([4.0, 4.5, 5.0]), self.point_source.catalogue.data["latitude"]) np.testing.assert_array_almost_equal(np.array([1.0, 1.0, 1.0]), self.point_source.catalogue.data["depth"])
from openquake.nrmllib import models from openquake.hazardlib import geo from hmtk.sources import source_model, point_source from hmtk.sources.point_source import mtkPointSource from decimal import Decimal p = mtkPointSource(identifier = '001', name = 'A Point Source', trt='Stable Continental Crust', geometry = geo.point.Point(10., 10.), upper_depth = 0., lower_depth = 30., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=2.5, max_mag=7.0), nodal_plane_dist=None, hypo_depth_dist=None) s = source_model.mtkSourceModel(identifier="09", name = "nick smoothed", sources = [p]) s.serialise_to_nrml(filename = "smoothed_model.xml", use_defaults = True) #
# Convert rate to a value?? #aval = rate aval = np.log10(rate) + bval * config["mmin"] #print rate, aval mfd = TruncatedGRMFD(min_mag, max_mag, 0.1, aval, bval) hypo_depth_dist = PMF([(1.0, 10.0)]) nodal_plane_dist = PMF([(0.25, NodalPlane(0, 30, 90)), (0.25, NodalPlane(90, 30, 90)), (0.25, NodalPlane(180, 30, 90)), (0.25, NodalPlane(270, 30, 90))]) point_source = mtkPointSource(identifier, name, geometry=point, mfd=mfd, mag_scale_rel='WC1994', rupt_aspect_ratio=1.5, upper_depth=0.1, lower_depth=20.0, trt='Non_cratonic', nodal_plane_dist=nodal_plane_dist, hypo_depth_dist=hypo_depth_dist) source_list.append(point_source) # i+=1 # if j==1000: # break source_model = mtkSourceModel(identifier=0, name='Helmstetter_K4', sources=source_list) source_model.serialise_to_nrml( ('source_model_smoothed_adaptive_K%i_0.1.xml' % smoother.config['k']))
sources = [] filename = "../data_output/test_smoothing.csv" r = [l for l in csv.reader(open(filename), delimiter=',', quotechar='"')] #smooth = np.genfromtxt("../data_output/hmtk_bsb2013_decluster_woo_rates.csv", delimiter=",",skip_header=True) for i, line in enumerate(r[1:]): rates = line[5].split(" ") #print rates p = mtkPointSource(identifier = i, name = "%s"%i, trt='Stable Continental Crust', geometry = geo.point.Point(float(line[0]), float(line[1])), upper_depth = 0., lower_depth = 30., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.IncrementalMFD(min_mag=float(line[3]), bin_width=float(line[4]), occur_rates=rates), nodal_plane_dist=None, hypo_depth_dist=None) #print p sources.append(p) s = source_model.mtkSourceModel(identifier="33", name = "PSHAB-Woo Discrete MFD", sources = sources) s.serialise_to_nrml(filename = "../woo/test_source_model_pshab_woo_incremental.xml",
sources = [] filename = "../data_output/stationary_rate_bsb2013.csv" r = [l for l in csv.reader(open(filename), delimiter=',', quotechar='"')] #smooth = np.genfromtxt("../data_output/hmtk_bsb2013_decluster_woo_rates.csv", delimiter=",",skip_header=True) for i, line in enumerate(r[1:]): rate = line[2].strip #print rates p = mtkPointSource(identifier = i, name = "%s"%i, trt='Stable Continental Crust', geometry = geo.point.Point(float(line[0]), float(line[1])), upper_depth = 0., lower_depth = 30., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.TGRMFD(min_mag=m0, max_mag=7.0, a_val=np.log10(float(line[2])*m0) + 1.0*m0, b_val=1.0), nodal_plane_dist=None, hypo_depth_dist=None) #print p sources.append(p) s = source_model.mtkSourceModel(identifier="04", name = "PSHAB-Helmstetter2012", sources = sources) s.serialise_to_nrml(filename = "../helmstetter2012/source_model_pshab_helmstetter2012.xml",
_a = np.log10(float(line[2])*m_min) + 1.*m_min #_a = float(line[2]) #_a = np.log10(sum(r[5])*m_min) + b_value*m_min #_a = sum(r[5]) l = [line[0], line[1], _a ] o.append(l) #print l p = mtkPointSource(identifier = i, name = "%s"%i, trt='Stable Continental Crust', geometry = geo.point.Point(line[0], line[1]), upper_depth = 0., lower_depth = 20., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.TGRMFD(min_mag=m_min, max_mag=m_max, a_val= _a , b_val=1.0), nodal_plane_dist=None, hypo_depth_dist=None) sources.append(p) s = source_model.mtkSourceModel(identifier="04", name = "PSHAB-Smoothed Helmstetter2012", sources = sources) s.serialise_to_nrml(filename = "helmstetter2012/source_model_pshab_helmstetter2012.xml", use_defaults = True)
from openquake.nrmllib import models from openquake.hazardlib import geo from hmtk.sources import source_model, point_source from hmtk.sources.point_source import mtkPointSource from decimal import Decimal p = mtkPointSource( identifier='001', name='A Point Source', trt='Stable Continental Crust', geometry=geo.point.Point(10., 10.), upper_depth=0., lower_depth=30., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.TGRMFD(a_val=3., b_val=1.0, min_mag=2.5, max_mag=7.0), nodal_plane_dist=None, hypo_depth_dist=None) s = source_model.mtkSourceModel(identifier="09", name="nick smoothed", sources=[p]) s.serialise_to_nrml(filename="smoothed_model.xml", use_defaults=True) # # # Define a complete source # area_geom = polygon.Polygon([point.Point(10., 10.), # point.Point(12., 10.),
depth = zone_dep # print max_mag, trt, depth point = Point(lons[j], lats[j], depth) # Openquake geometry Point mfd = TruncatedGRMFD(min_mag, max_mag, 0.1, a_vals[j], b_vals[j]) hypo_depth_dist = PMF([(1.0, depth)]) nodal_plane_dist = PMF([(0.3, NodalPlane(0, 30, 90)), (0.2, NodalPlane(90, 30, 90)), (0.3, NodalPlane(180, 30, 90)), (0.2, NodalPlane(270, 30, 90))]) point_source = mtkPointSource(identifier, name, geometry=point, mfd=mfd, mag_scale_rel='Leonard2014_SCR', rupt_aspect_ratio=1.0, upper_depth=0.1, lower_depth=20.0, trt=trt, nodal_plane_dist=nodal_plane_dist, hypo_depth_dist=hypo_depth_dist) source_list.append(point_source) source_model = mtkSourceModel(identifier=0, name='Hall2007', sources=source_list) print 'Writing to NRML' outbase = 'Hall2007' source_model_filename = outbase + '_source_model.xml' source_model.serialise_to_nrml(source_model_filename) source_models.append(source_model)
def setUp(self): warnings.simplefilter("ignore") # Suppress warnings during test self.catalogue = Catalogue() self.point_source = mtkPointSource('101', 'A Point Source')
_a = np.log10(float(line[2]) * m_min) + 1. * m_min #_a = float(line[2]) #_a = np.log10(sum(r[5])*m_min) + b_value*m_min #_a = sum(r[5]) l = [line[0], line[1], _a] o.append(l) #print l p = mtkPointSource( identifier=i, name="%s" % i, trt='Stable Continental Crust', geometry=geo.point.Point(line[0], line[1]), upper_depth=0., lower_depth=20., mag_scale_rel="WC1994", # default rupt_aspect_ratio=1.0, mfd=models.TGRMFD(min_mag=m_min, max_mag=m_max, a_val=_a, b_val=1.0), nodal_plane_dist=None, hypo_depth_dist=None) sources.append(p) s = source_model.mtkSourceModel(identifier="04", name="PSHAB-Smoothed Helmstetter2012", sources=sources) s.serialise_to_nrml(