def classical(group, src_filter, gsims, param, monitor=Monitor()): """ Compute the hazard curves for a set of sources belonging to the same tectonic region type for all the GSIMs associated to that TRT. The arguments are the same as in :func:`calc_hazard_curves`, except for ``gsims``, which is a list of GSIM instances. :returns: a dictionary with keys pmap, calc_times, rup_data, extra """ if not hasattr(src_filter, 'sitecol'): # do not filter src_filter = SourceFilter(src_filter, {}) # Get the parameters assigned to the group src_mutex = getattr(group, 'src_interdep', None) == 'mutex' cluster = getattr(group, 'cluster', None) trts = set() maxradius = 0 for src in group: if not src.num_ruptures: # src.num_ruptures may not be set, so it is set here src.num_ruptures = src.count_ruptures() # set the proper TOM in case of a cluster if cluster: src.temporal_occurrence_model = FatedTOM(time_span=1) trts.add(src.tectonic_region_type) if hasattr(src, 'radius'): # for prefiltered point sources maxradius = max(maxradius, src.radius) param['maximum_distance'] = src_filter.integration_distance [trt] = trts # there must be a single tectonic region type cmaker = ContextMaker(trt, gsims, param, monitor) try: cmaker.tom = group.temporal_occurrence_model except AttributeError: # got a list of sources, not a group time_span = param.get('investigation_time') # None for nonparametric cmaker.tom = PoissonTOM(time_span) if time_span else None if cluster: cmaker.tom = FatedTOM(time_span=1) pmap, rup_data, calc_times = PmapMaker(cmaker, src_filter, group).make() extra = {} extra['task_no'] = getattr(monitor, 'task_no', 0) extra['trt'] = trt extra['source_id'] = src.source_id extra['grp_id'] = src.grp_id extra['maxradius'] = maxradius group_probability = getattr(group, 'grp_probability', None) if src_mutex and group_probability: pmap *= group_probability if cluster: tom = getattr(group, 'temporal_occurrence_model') pmap = _cluster(param['imtls'], tom, gsims, pmap) return dict(pmap=pmap, calc_times=calc_times, rup_data=rup_data, extra=extra)
def calc_hazard_curve(site1, src, gsims_by_trt, oqparam): """ :param site1: site collection with a single site :param src: a seismic source object :param gsims_by_trt: a dictionary trt -> gsims :param oqparam: an object with attributes .maximum_distance, .imtls :returns: a ProbabilityCurve object """ assert len(site1) == 1, site1 trt = src.tectonic_region_type gsims = gsims_by_trt['*'] if '*' in gsims_by_trt else gsims_by_trt[trt] cmaker = ContextMaker(trt, gsims, vars(oqparam)) srcfilter = SourceFilter(site1, oqparam.maximum_distance) pmap, rup_data, calc_times, extra = PmapMaker(cmaker, srcfilter, [src]).make() return pmap[0] # pcurve with shape (L, G)
def calc_hazard_curve(site1, src, gsims, oqparam): """ :param site1: site collection with a single site :param src: a seismic source object :param gsims: a list of GSIM objects :param oqparam: an object with attributes .maximum_distance, .imtls :returns: a ProbabilityCurve object """ assert len(site1) == 1, site1 trt = src.tectonic_region_type cmaker = ContextMaker(trt, gsims, vars(oqparam)) srcfilter = SourceFilter(site1, oqparam.maximum_distance) pmap, rup_data, calc_times = PmapMaker(cmaker, srcfilter, [src]).make() if not pmap: # filtered away zero = numpy.zeros((oqparam.imtls.size, len(gsims))) return ProbabilityCurve(zero) return pmap[0] # pcurve with shape (L, G) on site 0
def calc_hazard_curve(site1, src, gsims, oqparam, monitor=Monitor()): """ :param site1: site collection with a single site :param src: a seismic source object :param gsims: a list of GSIM objects :param oqparam: an object with attributes .maximum_distance, .imtls :param monitor: a Monitor instance (optional) :returns: a ProbabilityCurve object """ assert len(site1) == 1, site1 trt = src.tectonic_region_type cmaker = ContextMaker(trt, gsims, vars(oqparam), monitor) cmaker.tom = src.temporal_occurrence_model srcfilter = SourceFilter(site1, oqparam.maximum_distance) pmap = PmapMaker(cmaker, srcfilter, [src]).make()['pmap'] if not pmap: # filtered away zero = numpy.zeros((oqparam.imtls.size, len(gsims))) return ProbabilityCurve(zero) return pmap[0] # pcurve with shape (L, G) on site 0
def classical(group, sitecol, cmaker): """ Compute the hazard curves for a set of sources belonging to the same tectonic region type for all the GSIMs associated to that TRT. The arguments are the same as in :func:`calc_hazard_curves`, except for ``gsims``, which is a list of GSIM instances. :returns: a dictionary with keys pmap, source_data, rup_data, extra """ src_filter = SourceFilter(sitecol, cmaker.maximum_distance) cluster = getattr(group, 'cluster', None) trts = set() for src in group: if not src.num_ruptures: # src.num_ruptures may not be set, so it is set here src.num_ruptures = src.count_ruptures() # set the proper TOM in case of a cluster if cluster: src.temporal_occurrence_model = FatedTOM(time_span=1) trts.add(src.tectonic_region_type) [trt] = trts # there must be a single tectonic region type if cmaker.trt != '*': assert trt == cmaker.trt, (trt, cmaker.trt) try: cmaker.tom = group.temporal_occurrence_model except AttributeError: # got a list of sources, not a group time_span = cmaker.investigation_time # None for nonparametric cmaker.tom = PoissonTOM(time_span) if time_span else None if cluster: cmaker.tom = FatedTOM(time_span=1) dic = PmapMaker(cmaker, src_filter, group).make() if cluster: tom = getattr(group, 'temporal_occurrence_model') dic['pmap'] = _cluster(cmaker.imtls, tom, cmaker.gsims, dic['pmap']) return dic