def assignRecurrence(layer_fault, layer_fault_background=None, layer_background=None, catalog=None, catalog_time_span=None, b_value=None, mmin=atticivy.ATTICIVY_MMIN, m_threshold=FAULT_BACKGROUND_MAG_THRESHOLD, mindepth=eqcatalog.CUT_DEPTH_MIN, maxdepth=eqcatalog.CUT_DEPTH_MAX, ui_mode=True): """Compute recurrence parameters according to Bungum paper. Add activity rates, a/b values, and min/max seismic moment rate as attributes to fault polygon layer. Input: layer_fault QGis layer with fault zone features layer_fault_background QGis layer with fault background zone features layer_background QGis layer with background zone features (provides Mmax and Mc distribution) catalog Earthquake catalog as QuakePy object b_value b value to be used for computation """ if b_value is None and (layer_fault_background is None or \ layer_background is None or catalog is None): error_msg = \ "If no b value is given, the other parameters must not be None" raise RuntimeError, error_msg recurrence = computeRecurrence(layer_fault, layer_fault_background, layer_background, catalog, catalog_time_span, b_value, mmin, m_threshold, mindepth, maxdepth, ui_mode=ui_mode) attributes.writeLayerAttributes(layer_fault, features.FAULT_SOURCE_ATTRIBUTES_RECURRENCE_COMPUTE, recurrence)
def assignActivityAtticIvy(layer, catalog, mmin=ATTICIVY_MMIN, mindepth=eqcatalog.CUT_DEPTH_MIN, maxdepth=eqcatalog.CUT_DEPTH_MAX, ui_mode=True): """Compute activity with Roger Musson's AtticIvy code and assign a and b values to each area source zone. Input: layer QGis layer with area zone features catalog earthquake catalog as QuakePy object """ # get attribute indexes provider = layer.dataProvider() zone_attribute_map = utils.getAttributeIndex(provider, ZONE_ATTRIBUTES, create=False) mmax_name = features.AREA_SOURCE_ATTR_MMAX['name'] mmax_idx = zone_attribute_map[mmax_name][0] mcdist_name = features.AREA_SOURCE_ATTR_MCDIST['name'] mcdist_idx = zone_attribute_map[mcdist_name][0] fts = layer.selectedFeatures() polygons, vertices = utils.polygonsQGS2Shapely(fts) # get mmax and mcdist from layer zone attributes mmax = [] mcdist = [] for zone_idx, zone in enumerate(fts): try: mmax_value = float(zone[mmax_idx].toDouble()[0]) except KeyError: mmax_value = None error_msg = "AtticIvy: no Mmax value in zone %s" % zone_idx if ui_mode is True: QMessageBox.warning(None, "AtticIvy Error", error_msg) else: print error_msg try: mcdist_value = str(zone[mcdist_idx].toString()) except KeyError: mcdist_value = None error_msg = "AtticIvy: no Mc value in zone %s" % zone_idx if ui_mode is True: QMessageBox.warning(None, "AtticIvy Error", error_msg) else: print error_msg mmax.append(mmax_value) mcdist.append(mcdist_value) activity = computeActivityAtticIvy(polygons, mmax, mcdist, catalog, mmin, mindepth, maxdepth, ui_mode=ui_mode) attributes.writeLayerAttributes(layer, features.AREA_SOURCE_ATTRIBUTES_AB_RM, activity)
def assignRecurrence(layer_fault, layer_fault_background=None, layer_background=None, catalog=None, catalog_time_span=None, b_value=None, mmin=atticivy.ATTICIVY_MMIN, m_threshold=FAULT_BACKGROUND_MAG_THRESHOLD, mindepth=eqcatalog.CUT_DEPTH_MIN, maxdepth=eqcatalog.CUT_DEPTH_MAX, ui_mode=True): """Compute recurrence parameters according to Bungum paper. Add activity rates, a/b values, and min/max seismic moment rate as attributes to fault polygon layer. Input: layer_fault QGis layer with fault zone features layer_fault_background QGis layer with fault background zone features layer_background QGis layer with background zone features (provides Mmax and Mc distribution) catalog Earthquake catalog as QuakePy object b_value b value to be used for computation """ if b_value is None and (layer_fault_background is None or \ layer_background is None or catalog is None): error_msg = \ "If no b value is given, the other parameters must not be None" raise RuntimeError, error_msg recurrence = computeRecurrence(layer_fault, layer_fault_background, layer_background, catalog, catalog_time_span, b_value, mmin, m_threshold, mindepth, maxdepth, ui_mode=ui_mode) attributes.writeLayerAttributes( layer_fault, features.FAULT_SOURCE_ATTRIBUTES_RECURRENCE_COMPUTE, recurrence)