示例#1
0
 def setUp(self):
     d = os.path.dirname(os.path.dirname(__file__))
     source_model = os.path.join(d, 'source_model/multi-point-source.xml')
     [self.sources] = nrml.parse(
         source_model,
         SourceConverter(investigation_time=50., rupture_mesh_spacing=2.))
     self.site = Site(Point(0.1, 0.1), 800, True, z1pt0=100., z2pt5=1.)
     self.imt = PGA()
     self.iml = 0.1
     self.truncation_level = 1
     self.trt = 'Stable Continental Crust'
     self.gsims = {self.trt: Campbell2003()}
示例#2
0
 def test(self):
     # mutually exclusive ruptures
     d = os.path.dirname(os.path.dirname(__file__))
     tmps = 'nonparametric-source-mutex-ruptures.xml'
     source_model = os.path.join(d, 'source_model', tmps)
     groups = nrml.to_python(source_model, SourceConverter(
         investigation_time=50., rupture_mesh_spacing=2.))
     site = Site(Point(143.5, 39.5), 800, z1pt0=100., z2pt5=1.)
     sitecol = SiteCollection([site])
     imtls = DictArray({'PGA': [0.01, 0.1, 0.2, 0.5]})
     gsim_by_trt = {'Some TRT': Campbell2003()}
     hcurves = calc_hazard_curves(groups, sitecol, imtls, gsim_by_trt)
     # expected results obtained with an ipython notebook
     expected = [4.3998728e-01, 1.1011728e-01, 7.5495312e-03, 8.5812844e-06]
     npt.assert_almost_equal(hcurves['PGA'][0], expected)
    def test(self):
        d = os.path.dirname(os.path.dirname(__file__))
        source_model = os.path.join(d, 'source_model/multi-point-source.xml')
        groups = nrml.to_python(source_model, SourceConverter(
            investigation_time=50., rupture_mesh_spacing=2.))
        site = Site(Point(0.1, 0.1), 800, True, z1pt0=100., z2pt5=1.)
        sitecol = SiteCollection([site])
        imtls = DictArray({'PGA': [0.01, 0.02, 0.04, 0.08, 0.16]})
        gsim_by_trt = {'Stable Continental Crust': Campbell2003()}
        hcurves = calc_hazard_curves(groups, sitecol, imtls, gsim_by_trt)
        expected = [0.99999778, 0.9084039, 0.148975348,
                    0.0036909656, 2.76326e-05]
        npt.assert_almost_equal(hcurves['PGA'][0], expected)

        # splitting in point sources
        [[mps1, mps2]] = groups
        psources = list(mps1) + list(mps2)
        hcurves = calc_hazard_curves(psources, sitecol, imtls, gsim_by_trt)
        npt.assert_almost_equal(hcurves['PGA'][0], expected)