Example #1
0
    def sites_to_compute(self):
        """Return the sites used to trigger the computation on the
        hazard subsystem.

        If the SITES parameter is specified, the computation is triggered
        only on the sites specified in that parameter, otherwise
        the region is used.

        If the COMPUTE_HAZARD_AT_ASSETS_LOCATIONS parameter is specified,
        the hazard computation is triggered only on sites defined in the risk
        exposure file and located inside the region of interest.
        """

        if self.sites:
            return self.sites

        if jobconf.RISK_SECTION in self.sections and self.has(jobconf.COMPUTE_HAZARD_AT_ASSETS):

            print "COMPUTE_HAZARD_AT_ASSETS_LOCATIONS selected, " "computing hazard on exposure sites..."

            exposure.store_exposure_assets(self._job_id, self._base_path)
            self.sites = exposure.read_sites_from_exposure(self)
        elif self.has(jobconf.SITES):

            coords = self._extract_coords(jobconf.SITES)
            sites = []

            for coord in coords:
                sites.append(shapes.Site(coord[0], coord[1]))

            self.sites = sites
        else:
            self.sites = self._sites_for_region()

        return self.sites
    def partition(self):
        """Split the sites to compute in blocks and store
        them in the underlying KVS system."""

        self.job_ctxt.blocks_keys = []  # pylint: disable=W0201
        sites = exposure_input.read_sites_from_exposure(self.job_ctxt)

        block_count = 0

        for block in split_into_blocks(self.job_ctxt.job_id, sites):
            self.job_ctxt.blocks_keys.append(block.block_id)
            block.to_kvs()

            block_count += 1

        LOG.info("Job has partitioned %s sites into %s blocks",
                 len(sites), block_count)
Example #3
0
    def partition(self):
        """Split the sites to compute in blocks and store
        them in the underlying KVS system."""

        self.job_ctxt.blocks_keys = []  # pylint: disable=W0201
        sites = exposure_input.read_sites_from_exposure(self.job_ctxt)

        block_count = 0

        for block in split_into_blocks(self.job_ctxt.job_id, sites):
            self.job_ctxt.blocks_keys.append(block.block_id)
            block.to_kvs()

            block_count += 1

        LOG.info("Job has partitioned %s sites into %s blocks", len(sites),
                 block_count)
Example #4
0
    def test_read_sites_from_exposure(self):
        # Test reading site data from an exposure file using
        # :py:function:`openquake.risk.read_sites_from_exposure`.
        job_cfg = helpers.testdata_path('simplecase/config.gem')

        test_job = helpers.job_from_file(job_cfg)
        calc = core.EventBasedRiskCalculator(test_job)
        calc.store_exposure_assets()

        expected_sites = set([
            shapes.Site(-118.077721, 33.852034),
            shapes.Site(-118.067592, 33.855398),
            shapes.Site(-118.186739, 33.779013)])

        actual_sites = set(read_sites_from_exposure(test_job))

        self.assertEqual(expected_sites, actual_sites)
Example #5
0
    def sites_to_compute(self):
        """Return the sites used to trigger the computation on the
        hazard subsystem.

        If the SITES parameter is specified, the computation is triggered
        only on the sites specified in that parameter, otherwise
        the region is used.

        If the COMPUTE_HAZARD_AT_ASSETS_LOCATIONS parameter is specified,
        the hazard computation is triggered only on sites defined in the risk
        exposure file and located inside the region of interest.
        """

        if self.sites:
            return self.sites

        if jobconf.RISK_SECTION in self.sections \
                and self.has(jobconf.COMPUTE_HAZARD_AT_ASSETS):

            print "COMPUTE_HAZARD_AT_ASSETS_LOCATIONS selected, " \
                "computing hazard on exposure sites..."

            exposure.store_exposure_assets(self._job_id, self._base_path)
            self.sites = exposure.read_sites_from_exposure(self)
        elif self.has(jobconf.SITES):

            coords = self._extract_coords(jobconf.SITES)
            sites = []

            for coord in coords:
                sites.append(shapes.Site(coord[0], coord[1]))

            self.sites = sites
        else:
            self.sites = self._sites_for_region()

        return self.sites