def build_geometry(pos_list): area_source = AreaSource() area_source.area_boundary = AREA_BOUNDARY( "fake", [POINT(pos_list[i], pos_list[i + 1]) for i in xrange(0, len(pos_list), 2)] ) return area_source
def test_read_smodel(self): asource = AreaSource() asource.nrml_id = "n1" asource.source_model_id = "sm1" asource.area_source_id = "src03" asource.name = "Quito" asource.tectonic_region = "Active Shallow Crust" area_boundary = [-122.5, 37.5, -121.5, 37.5, -121.5, 38.5, -122.5, 38.5] asource.area_boundary = AREA_BOUNDARY("urn:ogc:def:crs:EPSG::4326", [POINT(area_boundary[i], area_boundary[i + 1]) for i in xrange(0, len(area_boundary), 2)]) truncated_gutenberg_richter = TRUNCATED_GUTEN_RICHTER( 5.0, 0.8, 5.0, 7.0, "ML") strike = 0.0 dip = 90.0 rake = 0.0 asource.rupture_rate_model = RUPTURE_RATE_MODEL( truncated_gutenberg_richter, strike, dip, rake) magnitude = MAGNITUDE("ML", [6.0, 6.5, 7.0]) depth = [5000.0, 3000.0, 0.0] asource.rupture_depth_dist = RUPTURE_DEPTH_DISTRIB(magnitude, depth) asource.hypocentral_depth = 5000.0 read_source_model(self.context_jobs) self.assertEqual(1, len(self.context_jobs.sm_definitions)) self.assertEqual(asource, self.context_jobs.sm_definitions[0])
def build_geometry(pos_list): area_source = AreaSource() area_source.area_boundary = AREA_BOUNDARY('fake', [ POINT(pos_list[i], pos_list[i + 1]) for i in xrange(0, len(pos_list), 2) ]) return area_source
def test_a_null_catalog_apply_no_filtering(self): eq_catalog = np.array([[2000, 1, 2, -0.25, 0.25]]) null_filter = NullCatalogFilter() self.assertTrue( np.array_equal(eq_catalog, null_filter.filter_eqs(AreaSource(), eq_catalog)))
def create_area_source(): asource = AreaSource() asource.nrml_id = "n1" asource.source_model_id = "sm1" asource.area_source_id = "src03" asource.name = "Quito" asource.tectonic_region = "Active Shallow Crust" area_boundary = [-122.5, 37.5, -121.5, 37.5, -121.5, 38.5, -122.5, 38.5] asource.area_boundary = AREA_BOUNDARY("urn:ogc:def:crs:EPSG::4326", [ POINT(area_boundary[i], area_boundary[i + 1]) for i in xrange(0, len(area_boundary), 2) ]) truncated_gutenberg_richter = TRUNCATED_GUTEN_RICHTER( 5.0, 0.8, 5.0, 7.0, "ML") strike = 0.0 dip = 90.0 rake = 0.0 asource.rupture_rate_model = RUPTURE_RATE_MODEL( truncated_gutenberg_richter, strike, dip, rake) magnitude = MAGNITUDE("ML", [6.0, 6.5, 7.0]) depth = [5000.0, 3000.0, 0.0] asource.rupture_depth_dist = RUPTURE_DEPTH_DISTRIB(magnitude, depth) asource.hypocentral_depth = 5000.0 return asource
def _parse_area_source(as_elem): """ Creates an AreaSource object by extracting data contained in an area source element. :param as_elem: area source element :type as_elem: lxml.etree._Element :returns: area source object :rtype: py:class::AreaSource """ area_source = AreaSource() area_source.nrml_id = as_elem.getparent().getparent().get( nrml_xml.GML_ID) area_source.source_model_id = as_elem.getparent().get( nrml_xml.GML_ID) area_source.area_source_id = as_elem.get( nrml_xml.GML_ID) area_source.name = as_elem.find( nrml_xml.GML_NAME).text area_source.tectonic_region = as_elem.find( nrml_xml.TECTONIC_REGION).text area_source.area_boundary = _parse_area_boundary( as_elem.find(nrml_xml.AREA_BOUNDARY)) area_source.rupture_rate_model = _parse_rupture_rate_model( as_elem.find(nrml_xml.RUPTURE_RATE_MODEL)) area_source.rupture_depth_dist = _parse_rupture_depth_distrib( as_elem.find(nrml_xml.RUPTURE_DEPTH_DISTRIB)) area_source.hypocentral_depth = float(as_elem.find( nrml_xml.HYPOCENTRAL_DEPTH).text) as_elem.clear() return area_source