Example #1
0
 def pre_execute(self):
     """
     Read the site collection and initialize GmfComputer, etags and seeds
     """
     super(ScenarioCalculator, self).pre_execute()
     trunc_level = self.oqparam.truncation_level
     correl_model = readinput.get_correl_model(self.oqparam)
     n_gmfs = self.oqparam.number_of_ground_motion_fields
     rupture = readinput.get_rupture(self.oqparam)
     self.gsims = readinput.get_gsims(self.oqparam)
     self.rlzs_assoc = readinput.get_rlzs_assoc(self.oqparam)
     maxdist = self.oqparam.maximum_distance['default']
     with self.monitor('filtering sites', autoflush=True):
         self.sitecol = filters.filter_sites_by_distance_to_rupture(
             rupture, maxdist, self.sitecol)
     if self.sitecol is None:
         raise RuntimeError(
             'All sites were filtered out! maximum_distance=%s km' %
             maxdist)
     self.etags = numpy.array(
         sorted(['scenario-%010d' % i for i in range(n_gmfs)]),
         (bytes, 100))
     self.computer = GmfComputer(
         rupture, self.sitecol, self.oqparam.imtls, self.gsims,
         trunc_level, correl_model)
Example #2
0
    def pre_execute(self):
        """
        Read the site collection and initialize GmfComputer, tags and seeds
        """
        super(ScenarioCalculator, self).pre_execute()
        trunc_level = self.oqparam.truncation_level
        correl_model = readinput.get_correl_model(self.oqparam)
        n_gmfs = self.oqparam.number_of_ground_motion_fields
        rupture = readinput.get_rupture(self.oqparam)
        self.gsims = readinput.get_gsims(self.oqparam)
        self.rlzs_assoc = readinput.get_rlzs_assoc(self.oqparam)

        # filter the sites
        self.sitecol = filters.filter_sites_by_distance_to_rupture(
            rupture, self.oqparam.maximum_distance, self.sitecol)
        if self.sitecol is None:
            raise RuntimeError('All sites were filtered out! '
                               'maximum_distance=%s km' %
                               self.oqparam.maximum_distance)
        self.tags = numpy.array(
            sorted(['scenario-%010d' % i for i in range(n_gmfs)]),
            (bytes, 100))
        self.computer = GmfComputer(rupture, self.sitecol, self.oqparam.imtls,
                                    self.gsims, trunc_level, correl_model)
        rnd = random.Random(self.oqparam.random_seed)
        self.tag_seed_pairs = [(tag, rnd.randint(0, calc.MAX_INT))
                               for tag in self.tags]
        self.sescollection = [{
            tag: Rupture(tag, seed, rupture)
            for tag, seed in self.tag_seed_pairs
        }]
Example #3
0
    def pre_execute(self):
        """
        Read the site collection and initialize GmfComputer, tags and seeds
        """
        super(ScenarioCalculator, self).pre_execute()
        trunc_level = self.oqparam.truncation_level
        correl_model = readinput.get_correl_model(self.oqparam)
        n_gmfs = self.oqparam.number_of_ground_motion_fields
        rupture = readinput.get_rupture(self.oqparam)
        self.gsims = readinput.get_gsims(self.oqparam)
        self.rlzs_assoc = readinput.get_rlzs_assoc(self.oqparam)

        # filter the sites
        self.sitecol = filters.filter_sites_by_distance_to_rupture(
            rupture, self.oqparam.maximum_distance, self.sitecol)
        if self.sitecol is None:
            raise RuntimeError(
                'All sites were filtered out! '
                'maximum_distance=%s km' % self.oqparam.maximum_distance)
        self.tags = numpy.array(
            sorted(['scenario-%010d' % i for i in range(n_gmfs)]),
            (bytes, 100))
        self.computer = GmfComputer(
            rupture, self.sitecol, self.oqparam.imtls, self.gsims,
            trunc_level, correl_model)
        rnd = random.Random(self.oqparam.random_seed)
        self.tag_seed_pairs = [(tag, rnd.randint(0, calc.MAX_INT))
                               for tag in self.tags]
        self.sescollection = [{tag: Rupture(tag, seed, rupture)
                               for tag, seed in self.tag_seed_pairs}]
    def test_get_rlzs_assoc(self):
        two_trts = general.writetmp("""\
<?xml version='1.0' encoding='utf-8'?>
<nrml xmlns:gml="http://www.opengis.net/gml"
      xmlns="http://openquake.org/xmlns/nrml/0.4">
    <logicTree logicTreeID='lt1'>
        <logicTreeBranchingLevel branchingLevelID="bl1">
            <logicTreeBranchSet uncertaintyType="gmpeModel" branchSetID="bs1"
                    applyToTectonicRegionType="Active Shallow Crust">

                <logicTreeBranch branchID="b1">
                    <uncertaintyModel>BooreAtkinson2008</uncertaintyModel>
                    <uncertaintyWeight>0.75</uncertaintyWeight>
                </logicTreeBranch>
                <logicTreeBranch branchID="b2">
                    <uncertaintyModel>ChiouYoungs2008</uncertaintyModel>
                    <uncertaintyWeight>0.25</uncertaintyWeight>
                </logicTreeBranch>

            </logicTreeBranchSet>
        </logicTreeBranchingLevel>

        <logicTreeBranchingLevel branchingLevelID="bl2">
            <logicTreeBranchSet uncertaintyType="gmpeModel" branchSetID="bs2"
                    applyToTectonicRegionType="Active Deep Crust">

                <logicTreeBranch branchID="b1">
                    <uncertaintyModel>BooreAtkinson2008</uncertaintyModel>
                    <uncertaintyWeight>0.75</uncertaintyWeight>
                </logicTreeBranch>

                <logicTreeBranch branchID="b2">
                    <uncertaintyModel>ChiouYoungs2008</uncertaintyModel>
                    <uncertaintyWeight>0.25</uncertaintyWeight>
                </logicTreeBranch>

            </logicTreeBranchSet>
        </logicTreeBranchingLevel>
    </logicTree>
</nrml>""")
        oqparam = mock.Mock()
        oqparam.base_path = '/'
        oqparam.inputs = dict(gsim_logic_tree=two_trts)
        with self.assertRaises(readinput.InvalidFile) as ctx:
            readinput.get_rlzs_assoc(oqparam)
        self.assertIn('must contain a single tectonic region type',
                      str(ctx.exception))
Example #5
0
 def pre_execute(self):
     """
     Read the site collection and initialize GmfComputer, etags and seeds
     """
     super(ScenarioCalculator, self).pre_execute()
     trunc_level = self.oqparam.truncation_level
     correl_model = readinput.get_correl_model(self.oqparam)
     n_gmfs = self.oqparam.number_of_ground_motion_fields
     rupture = readinput.get_rupture(self.oqparam)
     self.gsims = readinput.get_gsims(self.oqparam)
     self.rlzs_assoc = readinput.get_rlzs_assoc(self.oqparam)
     maxdist = self.oqparam.maximum_distance['default']
     with self.monitor('filtering sites', autoflush=True):
         self.sitecol = filters.filter_sites_by_distance_to_rupture(
             rupture, maxdist, self.sitecol)
     if self.sitecol is None:
         raise RuntimeError(
             'All sites were filtered out! maximum_distance=%s km' %
             maxdist)
     self.etags = numpy.array(
         sorted(['scenario-%010d' % i for i in range(n_gmfs)]),
         (bytes, 100))
     self.computer = GmfComputer(rupture, self.sitecol, self.oqparam.imtls,
                                 self.gsims, trunc_level, correl_model)