def compute_expand_gmfa(self, monitor): """ :returns: an array R x N where N is the number of sites and R is the number of ruptures. """ from openquake.calculators.event_based import make_gmfs gst = make_gmfs(self.ses_ruptures, self.sitecol, self.imts, self.gsims, self.trunc_level, self.correl_model, monitor) gmf_dt = gsim_imt_dt(self.gsims, self.imts) N = len(self.sitecol.complete) E = len(self.eids) gmfa = numpy.zeros((E, N), gmf_dt) start = 0 for sesrup in self.ses_ruptures: array = gst[sesrup.serial].gmfa n = len(array) # number of seeds if sesrup.indices is not None: expanded_array = numpy.zeros((n, N), array.dtype) expanded_array[:, sesrup.indices] = array gmfa[start:start + n] = expanded_array else: gmfa[start:start + n] = array start += n return gmfa # array E x N
def __init__(self, rupture, sites, imts, gsims, truncation_level=None, correlation_model=None): assert sites and imts, (sites, imts) self.rupture = rupture self.sites = sites self.imts = list(map(from_string, imts)) self.gsims = gsims self.truncation_level = truncation_level self.correlation_model = correlation_model self.ctx = ContextMaker(gsims).make_contexts(sites, rupture) self.gmf_dt = gsim_imt_dt(gsims, imts)
def pre_execute(self): """ Read the precomputed ruptures (or compute them on the fly) and prepare some empty files in the export directory to store the gmfs (if any). If there were pre-existing files, they will be erased. """ super(EventBasedCalculator, self).pre_execute() self.sesruptures = [] gsims_by_col = self.rlzs_assoc.get_gsims_by_col() self.datasets = [] for col_id, sescol in enumerate(self.datastore['sescollection']): gmf_dt = gsim_imt_dt(gsims_by_col[col_id], self.oqparam.imtls) for tag, sesrup in sorted(sescol.iteritems()): sesrup = sescol[tag] self.sesruptures.append(sesrup) self.datasets.append( self.datastore.create_dset('gmfs/col%02d' % col_id, gmf_dt))
def pre_execute(self): """ Read the precomputed ruptures (or compute them on the fly) and prepare some empty files in the export directory to store the gmfs (if any). If there were pre-existing files, they will be erased. """ super(EventBasedCalculator, self).pre_execute() self.sesruptures = [] gsims_by_col = self.rlzs_assoc.get_gsims_by_col() self.datasets = {} for col_id, sescol in enumerate(self.datastore['sescollection']): gmf_dt = gsim_imt_dt(gsims_by_col[col_id], self.oqparam.imtls) for tag, sesrup in sorted(sescol.items()): sesrup = sescol[tag] self.sesruptures.append(sesrup) if self.oqparam.ground_motion_fields and sescol: self.datasets[col_id] = self.datastore.create_dset( 'gmfs/col%02d' % col_id, gmf_dt)
def compute_expand_gmfs(self): """ :returns: an array R x N where N is the number of sites and R is the number of ruptures. """ from openquake.commonlib.calculators.event_based import make_gmfs gmfs = make_gmfs(self.ses_ruptures, self.sitecol, self.imts, self.gsims, self.trunc_level, self.correl_model, DummyMonitor()) gmf_dt = gsim_imt_dt(self.gsims, self.imts) N = len(self.sitecol.complete) R = len(gmfs) gmfa = numpy.zeros((R, N), gmf_dt) for i, sesrup, gmf in zip(range(R), self.ses_ruptures, gmfs): expanded_gmf = numpy.zeros(N, gmf_dt) expanded_gmf[sesrup.indices] = gmf gmfa[i] = expanded_gmf return gmfa # array R x N
def compute_expand_gmfs(self): """ :returns: an array R x N where N is the number of sites and R is the number of ruptures. """ from openquake.commonlib.calculators.event_based import make_gmfs gmfs = make_gmfs( self.ses_ruptures, self.sitecol, self.imts, self.gsims, self.trunc_level, self.correl_model, DummyMonitor()) gmf_dt = gsim_imt_dt(self.gsims, self.imts) N = len(self.sitecol.complete) R = len(gmfs) gmfa = numpy.zeros((R, N), gmf_dt) for i, sesrup, gmf in zip(range(R), self.ses_ruptures, gmfs): expanded_gmf = numpy.zeros(N, gmf_dt) expanded_gmf[sesrup.indices] = gmf gmfa[i] = expanded_gmf return gmfa # array R x N
def compute_expand_gmfs(self): """ :returns: an array R x N where N is the number of sites and R is the number of ruptures. """ from openquake.commonlib.calculators.event_based import make_gmf_by_tag gmf_by_tag = make_gmf_by_tag( self.ses_ruptures, self.sitecol, self.imts, self.gsims, self.trunc_level, self.correl_model, DummyMonitor()) gmf_dt = gsim_imt_dt(self.gsims, self.imts) n = len(self.sitecol.complete) gmfs = numpy.zeros((len(gmf_by_tag), n), gmf_dt) for r, tag in enumerate(sorted(gmf_by_tag)): gmfa = gmf_by_tag[tag] expanded_gmf = numpy.zeros(n, gmf_dt) expanded_gmf[gmfa['idx']] = gmfa gmfs[r] = expanded_gmf return gmfs # array R x N