def get_eids_by_rlz(self, rlzs_by_gsim): """ :param n_occ: number of occurrences :params rlzs_by_gsim: a dictionary gsims -> rlzs array :param samples: number of samples in current source group :returns: a dictionary rlz index -> eids array """ j = 0 dic = {} if self.samples == 1: # full enumeration or akin to it for rlzs in rlzs_by_gsim.values(): for rlz in rlzs: dic[rlz] = numpy.arange(j, j + self.n_occ, dtype=U64) + ( TWO32 * U64(self.serial)) j += self.n_occ else: # associated eids to the realizations rlzs = numpy.concatenate(list(rlzs_by_gsim.values())) assert len(rlzs) == self.samples, (len(rlzs), self.samples) histo = general.random_histogram( self.n_occ, self.samples, self.serial) for rlz, n in zip(rlzs, histo): dic[rlz] = numpy.arange(j, j + n, dtype=U64) + ( TWO32 * U64(self.serial)) j += n return dic
def get_eids_by_rlz(self, rlzs_by_gsim): """ :params rlzs_by_gsim: a dictionary gsims -> rlzs array :returns: a dictionary rlz index -> eids array """ j = 0 dic = {} rlzs = numpy.concatenate(list(rlzs_by_gsim.values())) histo = general.random_histogram(self.n_occ, len(rlzs), self.rup_id) for rlz, n in zip(rlzs, histo): dic[rlz] = numpy.arange(j, j + n, dtype=U32) + self.e0 j += n return dic
def get_eids_by_rlz(self, rlzs_by_gsim): """ :params rlzs_by_gsim: a dictionary gsims -> rlzs array :returns: a dictionary rlz index -> eids array """ dic = {} rlzs = numpy.concatenate(list(rlzs_by_gsim.values())) if self.scenario: all_eids = numpy.arange(self.n_occ, dtype=U32) + self.e0 splits = numpy.array_split(all_eids, len(rlzs)) for rlz_id, eids in zip(rlzs, splits): dic[rlz_id] = eids else: j = 0 histo = general.random_histogram( self.n_occ, len(rlzs), self.rup_id) for rlz, n in zip(rlzs, histo): dic[rlz] = numpy.arange(j, j + n, dtype=U32) + self.e0 j += n return dic
def get_eids_by_rlz(self, rlzs_by_gsim, offset=0): """ :params rlzs_by_gsim: a dictionary gsims -> rlzs array :param offset: offset used in the calculation of the event ID :returns: a dictionary rlz index -> eids array """ j = 0 dic = {} if self.samples == 1: # full enumeration or akin to it for rlzs in rlzs_by_gsim.values(): for rlz in rlzs: dic[rlz] = numpy.arange(j, j + self.n_occ, dtype=U32) + offset j += self.n_occ else: # associated eids to the realizations rlzs = numpy.concatenate(list(rlzs_by_gsim.values())) assert len(rlzs) == self.samples, (len(rlzs), self.samples) histo = general.random_histogram(self.n_occ, self.samples, self.rup_id) for rlz, n in zip(rlzs, histo): dic[rlz] = numpy.arange(j, j + n, dtype=U32) + offset j += n return dic