def pre_execute(self): """ Read the site collection and initialize GmfComputer and seeds """ oq = self.oqparam cinfo = source.CompositionInfo.fake(readinput.get_gsim_lt(oq)) self.datastore['csm_info'] = cinfo if 'rupture_model' not in oq.inputs: logging.warn('There is no rupture_model, the calculator will just ' 'import data without performing any calculation') super().pre_execute() return self.rup = readinput.get_rupture(oq) self.gsims = readinput.get_gsims(oq) R = len(self.gsims) self.cmaker = ContextMaker(self.gsims, oq.maximum_distance, {'filter_distance': oq.filter_distance}) super().pre_execute() self.datastore['oqparam'] = oq self.rlzs_assoc = cinfo.get_rlzs_assoc() rlzs_by_gsim = self.rlzs_assoc.get_rlzs_by_gsim(0) E = oq.number_of_ground_motion_fields n_occ = numpy.array([E]) ebr = EBRupture(self.rup, 0, 0, self.sitecol.sids, n_occ) events = numpy.zeros(E * R, events_dt) for rlz, eids in ebr.get_eids_by_rlz(rlzs_by_gsim).items(): events[rlz * E:rlz * E + E]['eid'] = eids events[rlz * E:rlz * E + E]['rlz'] = rlz self.datastore['events'] = events rupser = calc.RuptureSerializer(self.datastore) rupser.save(get_rup_array([ebr])) rupser.close() self.computer = GmfComputer(ebr, self.sitecol, oq.imtls, self.cmaker, oq.truncation_level, oq.correl_model)
def get_eid_rlz(self, monitor=None): """ :returns: a composite array with the associations eid->rlz """ eid_rlz = [] for rup in self.rup_array: ebr = EBRupture(mock.Mock(serial=rup['serial']), rup['srcidx'], self.grp_id, rup['n_occ'], self.samples) for rlz, eids in ebr.get_eids_by_rlz(self.rlzs_by_gsim).items(): for eid in eids: eid_rlz.append((eid, rlz)) return numpy.array(eid_rlz, [('eid', U64), ('rlz', U16)])
def get_eid_rlz(self): """ :returns: a composite array with the associations eid->rlz """ eid_rlz = [] for rup in self.proxies: ebr = EBRupture(mock.Mock(rup_id=rup['serial']), rup['source_id'], self.grp_id, rup['n_occ'], self.samples) for rlz_id, eids in ebr.get_eids_by_rlz(self.rlzs_by_gsim).items(): for eid in eids: eid_rlz.append((eid + rup['e0'], rup['id'], rlz_id)) return numpy.array(eid_rlz, events_dt)
def get_eid_rlz(self): """ :returns: a composite array with the associations eid->rlz """ eid_rlz = [] for e0, rup in zip(self.e0, self.rup_array): rup_id = rup['rup_id'] ebr = EBRupture(mock.Mock(rup_id=rup_id), rup['srcidx'], self.grp_id, rup['n_occ'], self.samples) for rlz_id, eids in ebr.get_eids_by_rlz(self.rlzs_by_gsim).items(): for eid in eids: eid_rlz.append((eid + e0, rup_id, rlz_id)) return numpy.array(eid_rlz, events_dt)
def get_eid_rlz(self, proxies, rlzs_by_gsim): """ :returns: a composite array with the associations eid->rlz """ eid_rlz = [] for rup in proxies: ebr = EBRupture(Mock(rup_id=rup['seed']), rup['source_id'], rup['trt_smr'], rup['n_occ'], e0=rup['e0']) ebr.scenario = 'scenario' in self.oqparam.calculation_mode for rlz_id, eids in ebr.get_eids_by_rlz(rlzs_by_gsim).items(): for eid in eids: eid_rlz.append((eid, rup['id'], rlz_id)) return numpy.array(eid_rlz, events_dt)
def pre_execute(self): """ Read the site collection and initialize GmfComputer and seeds """ oq = self.oqparam cinfo = logictree.FullLogicTree.fake(readinput.get_gsim_lt(oq)) self.realizations = cinfo.get_realizations() self.datastore['full_lt'] = cinfo if 'rupture_model' not in oq.inputs: logging.warning( 'There is no rupture_model, the calculator will just ' 'import data without performing any calculation') super().pre_execute() return self.rup = readinput.get_rupture(oq) self.gsims = readinput.get_gsims(oq) R = len(self.gsims) self.cmaker = ContextMaker( '*', self.gsims, { 'maximum_distance': oq.maximum_distance, 'filter_distance': oq.filter_distance }) super().pre_execute() self.datastore['oqparam'] = oq self.store_rlz_info({}) rlzs_by_gsim = cinfo.get_rlzs_by_gsim(0) E = oq.number_of_ground_motion_fields n_occ = numpy.array([E]) ebr = EBRupture(self.rup, 0, 0, n_occ) ebr.e0 = 0 events = numpy.zeros(E * R, events_dt) for rlz, eids in ebr.get_eids_by_rlz(rlzs_by_gsim).items(): events[rlz * E:rlz * E + E]['id'] = eids events[rlz * E:rlz * E + E]['rlz_id'] = rlz self.datastore['events'] = self.events = events rupser = calc.RuptureSerializer(self.datastore) rup_array = get_rup_array([ebr], self.src_filter()) if len(rup_array) == 0: maxdist = oq.maximum_distance(self.rup.tectonic_region_type, self.rup.mag) raise RuntimeError('There are no sites within the maximum_distance' ' of %s km from the rupture' % maxdist) rupser.save(rup_array) rupser.close() self.computer = GmfComputer(ebr, self.sitecol, oq.imtls, self.cmaker, oq.truncation_level, oq.correl_model, self.amplifier) M32 = (numpy.float32, len(self.oqparam.imtls)) self.sig_eps_dt = [('eid', numpy.uint64), ('sig', M32), ('eps', M32)]