Ejemplo n.º 1
0
    def read_inputs(self):
        """
        Read risk data and sources if any
        """
        oq = self.oqparam
        self._read_risk_data()
        self.check_overflow()  # check if self.sitecol is too large
        if getattr(self, 'sitecol', None):
            # can be None for the ruptures-only calculator
            with hdf5.File(self.datastore.tempname, 'w') as tmp:
                tmp['sitecol'] = self.sitecol
        if ('source_model_logic_tree' in oq.inputs
                and oq.hazard_calculation_id is None):
            full_lt = readinput.get_full_lt(oq)
            with self.monitor('composite source model', measuremem=True):
                self.csm = csm = readinput.get_composite_source_model(
                    oq, full_lt, self.datastore.hdf5)
                srcs = [src for sg in csm.src_groups for src in sg]
                if not srcs:
                    raise RuntimeError('All sources were discarded!?')
                logging.info('Checking the sources bounding box')
                sids = self.src_filter().within_bbox(srcs)
                if len(sids) == 0:
                    raise RuntimeError('All sources were discarded!?')
                if oq.disagg_by_src and len(srcs) > 1000:
                    j = oq.inputs['job_ini']
                    raise InvalidFile(
                        '%s: disagg_by_src can be set only if there are <=1000'
                        ' sources, but %d were found in the model' %
                        (j, len(srcs)))
                self.full_lt = csm.full_lt
        self.init()  # do this at the end of pre-execute

        if not oq.hazard_calculation_id:
            self.gzip_inputs()
Ejemplo n.º 2
0
def print_full_lt(fname):
    """
    Parse the composite source model and
    prints information about its composition and the full logic tree
    """
    oqparam = readinput.get_oqparam(fname)
    full_lt = readinput.get_full_lt(oqparam)
    print(full_lt)
    print('See http://docs.openquake.org/oq-engine/stable/'
          'effective-realizations.html for an explanation')
Ejemplo n.º 3
0
    def read_inputs(self):
        """
        Read risk data and sources if any
        """
        oq = self.oqparam
        self._read_risk_data()
        self.check_overflow()  # check if self.sitecol is too large
        if getattr(self, 'sitecol', None):
            # can be None for the ruptures-only calculator
            with hdf5.File(self.datastore.tempname, 'w') as tmp:
                tmp['sitecol'] = self.sitecol
        elif (oq.calculation_mode == 'disaggregation'
              and oq.max_sites_disagg < len(self.sitecol)):
            raise ValueError('Please set max_sites_disagg=%d in %s' %
                             (len(self.sitecol), oq.inputs['job_ini']))
        elif oq.disagg_by_src and len(self.sitecol) > oq.max_sites_disagg:
            raise ValueError(
                'There are too many sites to use disagg_by_src=true')
        if ('source_model_logic_tree' in oq.inputs
                and oq.hazard_calculation_id is None):
            full_lt = readinput.get_full_lt(oq)
            with self.monitor('composite source model', measuremem=True):
                self.csm = csm = readinput.get_composite_source_model(
                    oq, full_lt, self.datastore.hdf5)
                srcs = [src for sg in csm.src_groups for src in sg]
                if not srcs:
                    raise RuntimeError('All sources were discarded!?')
                logging.info('Checking the sources bounding box')
                sids = self.src_filter().within_bbox(srcs)
                if len(sids) == 0:
                    raise RuntimeError('All sources were discarded!?')
                self.full_lt = csm.full_lt
        self.init()  # do this at the end of pre-execute

        if (not oq.hazard_calculation_id
                and oq.calculation_mode != 'preclassical'
                and not oq.save_disk_space):
            self.gzip_inputs()