def pre_execute(self): """ Read the site collection and initialize GmfComputer and seeds """ super(ScenarioCalculator, self).pre_execute() oq = self.oqparam gsim_lt = readinput.get_gsim_lt(oq) cinfo = source.CompositionInfo.fake(gsim_lt) self.datastore['csm_info'] = cinfo self.datastore['oqparam'] = oq self.rlzs_assoc = cinfo.get_rlzs_assoc() if 'rupture_model' not in oq.inputs: logging.warn('There is no rupture_model, the calculator will just ' 'import data without performing any calculation') return ebr, self.sitecol = readinput.get_rupture_sitecol(oq, self.sitecol) self.gsims = readinput.get_gsims(oq) self.datastore['events'] = ebr.events rupser = calc.RuptureSerializer(self.datastore) rupser.save([ebr]) rupser.close() trunc_level = oq.truncation_level correl_model = oq.get_correl_model() self.computer = GmfComputer(ebr, self.sitecol, oq.imtls, ContextMaker(self.gsims), trunc_level, correl_model)
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) 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() E = oq.number_of_ground_motion_fields events = numpy.zeros(E, readinput.stored_event_dt) events['eid'] = numpy.arange(E) ebr = EBRupture(self.rup, 0, self.sitecol.sids, events) self.datastore['events'] = ebr.events rupser = calc.RuptureSerializer(self.datastore) rupser.save([ebr]) rupser.close() self.computer = GmfComputer(ebr, self.sitecol, oq.imtls, self.cmaker, oq.truncation_level, oq.correl_model)
def init(self): """ Set the random seed passed to the SourceManager and the minimum_intensity dictionary. """ oq = self.oqparam self.min_iml = self.get_min_iml(oq) self.rupser = calc.RuptureSerializer(self.datastore)
def init(self): self.rupser = calc.RuptureSerializer(self.datastore) if self.oqparam.hazard_calculation_id is None: self.csm_info = self.process_csm() else: self.datastore.parent = datastore.read( self.oqparam.hazard_calculation_id) self.csm_info = self.datastore.parent['csm_info']
def init(self): """ Set the random seed passed to the SourceManager and the minimum_intensity dictionary. """ oq = self.oqparam self.min_iml = calc.fix_minimum_intensity(oq.minimum_intensity, oq.imtls) self.rupser = calc.RuptureSerializer(self.datastore) self.csm_info = self.datastore['csm_info']
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)]
def pre_execute(self): """ parse the logic tree and source model input """ logging.warn('%s is still experimental', self.__class__.__name__) oq = self.oqparam self.read_risk_data() # read the site collection self.csm = get_composite_source_model(oq) self.csm.src_filter = SourceFilter(self.sitecol, oq.maximum_distance) logging.info('Found %d source model logic tree branches', len(self.csm.source_models)) self.datastore['csm_info'] = self.csm_info = self.csm.info self.rlzs_assoc = self.csm_info.get_rlzs_assoc() self.infos = [] self.eid = collections.Counter() # sm_id -> event_id self.sm_by_grp = self.csm_info.get_sm_by_grp() if not self.oqparam.imtls: raise ValueError('Missing intensity_measure_types!') self.rupser = calc.RuptureSerializer(self.datastore)
def pre_execute(self): """ Read the site collection and initialize GmfComputer and seeds """ super(ScenarioCalculator, self).pre_execute() oq = self.oqparam trunc_level = oq.truncation_level correl_model = oq.get_correl_model() ebr, self.sitecol = readinput.get_rupture_sitecol(oq, self.sitecol) self.gsims = readinput.get_gsims(oq) self.datastore['events'] = ebr.events rupser = calc.RuptureSerializer(self.datastore) rupser.save([ebr]) rupser.close() self.computer = GmfComputer(ebr, self.sitecol, oq.imtls, self.gsims, trunc_level, correl_model) gsim_lt = readinput.get_gsim_lt(oq) cinfo = source.CompositionInfo.fake(gsim_lt) self.datastore['csm_info'] = cinfo self.rlzs_assoc = cinfo.get_rlzs_assoc()
def pre_execute(self): """ Read the site collection and initialize GmfComputer and seeds """ super(ScenarioCalculator, self).pre_execute() oq = self.oqparam trunc_level = oq.truncation_level correl_model = oq.get_correl_model() rup = readinput.get_rupture(oq) rup.seed = self.oqparam.random_seed self.gsims = readinput.get_gsims(oq) maxdist = oq.maximum_distance['default'] with self.monitor('filtering sites', autoflush=True): self.sitecol = filters.filter_sites_by_distance_to_rupture( rup, maxdist, self.sitecol) if self.sitecol is None: raise RuntimeError( 'All sites were filtered out! maximum_distance=%s km' % maxdist) # eid, ses, occ, sample events = numpy.zeros(oq.number_of_ground_motion_fields, calc.stored_event_dt) events['eid'] = numpy.arange(oq.number_of_ground_motion_fields) self.datastore['events/grp-00'] = events rupture = calc.EBRupture(rup, self.sitecol.sids, events, 0, 0) rupture.sidx = 0 rupture.eidx1 = 0 rupture.eidx2 = len(events) rupser = calc.RuptureSerializer(self.datastore) rupser.save([rupture], 0) rupser.close() self.computer = GmfComputer(rupture, self.sitecol, oq.imtls, self.gsims, trunc_level, correl_model) gsim_lt = readinput.get_gsim_lt(oq) cinfo = source.CompositionInfo.fake(gsim_lt) self.datastore['csm_info'] = cinfo self.rlzs_assoc = cinfo.get_rlzs_assoc()
def init(self): """ Set the random seed passed to the SourceManager and the minimum_intensity dictionary. """ self.rupser = calc.RuptureSerializer(self.datastore)
def init(self): if hasattr(self, 'csm'): self.check_floating_spinning() if not self.datastore.parent: self.rupser = calc.RuptureSerializer(self.datastore) self.srcfilter = self.src_filter(self.datastore.tempname)
def init(self): if hasattr(self, 'csm'): self.check_floating_spinning() self.rupser = calc.RuptureSerializer(self.datastore) self.rlzs_by_gsim_grp = self.csm_info.get_rlzs_by_gsim_grp() self.samples_by_grp = self.csm_info.get_samples_by_grp()
def init(self): if hasattr(self, 'csm'): self.check_floating_spinning() self.rupser = calc.RuptureSerializer(self.datastore)
def init(self): self.rupser = calc.RuptureSerializer(self.datastore) self.rlzs_by_gsim_grp = self.csm_info.get_rlzs_by_gsim_grp() self.samples_by_grp = self.csm_info.get_samples_by_grp()