Beispiel #1
0
    def setUp(self):
        # simple logic tree with 3 realizations
        #    ___/ b11 (w=.2)
        #  _/   \ b12 (w=.2)
        #   \____ b02 (w=.6)
        self.bs0 = bs0 = lt.BranchSet('abGRAbsolute')
        bs0.branches = [
            lt.Branch('bs0', 'b01', .4, (4.6, 1.1)),
            lt.Branch('bs0', 'b02', .6, (4.4, 0.9))
        ]

        self.bs1 = bs1 = lt.BranchSet('maxMagGRAbsolute')
        bs1.branches = [
            lt.Branch('bs1', 'b11', .5, 7.0),
            lt.Branch('bs1', 'b12', .5, 7.6)
        ]
        bs0.branches[0].bset = bs1

        # setup sitecol, srcfilter, gsims, imtls
        sitecol = site.SiteCollection(
            [site.Site(Point(0, 0), numpy.array([760.]))])
        self.srcfilter = calc.filters.SourceFilter(sitecol, {'default': 200})
        self.gsims = [valid.gsim('ToroEtAl2002')]
        self.imtls = DictArray({'PGA': valid.logscale(.01, 1, 5)})
        self.sg = sourceconverter.SourceGroup(ps.tectonic_region_type, [ps])
Beispiel #2
0
    def test(self):
        # simple logic tree with 5 realizations
        #        __/ AAA
        #    bs1/  \ AAB
        #   /   \__/ ABA
        # bs0      \ ABB
        #   \_______
        #            B..
        bs0 = lt.BranchSet('abGRAbsolute')
        bs0.branches = [
            lt.Branch('bs0', 'A', .4, (4.6, 1.1)),
            lt.Branch('bs0', 'B', .6, (4.4, 0.9))
        ]

        bs1 = lt.BranchSet('maxMagGRAbsolute',
                           filters={'applyToBranches': 'A'})
        bs1.branches = [
            lt.Branch('bs1', 'A', .5, 7.0),
            lt.Branch('bs1', 'B', .5, 7.6)
        ]

        bs2 = lt.BranchSet('applyToTRT', filters={'applyToBranches': 'A B'})
        bs2.branches = [
            lt.Branch('bs2', 'A', .3, 'A'),
            lt.Branch('bs2', 'B', .7, 'B')
        ]
        for branch in bs1.branches:
            branch.bset = bs2
        clt = lt.CompositeLogicTree([bs0, bs1, bs2])
        self.assertEqual(clt.get_all_paths(),
                         ['AAA', 'AAB', 'ABA', 'ABB', 'B..'])
        self.assertEqual(clt.basepaths,
                         ['A**', 'B**', '*A*', '*B*', '**A', '**B'])