def __init__(self, recurrence_model_seq, generation_min_mag, event_type, name): """ recurrence_model_seq: sequence of RecurrenceModel() generation_min_mag - The minimum event generation specified by the user #FIXME DSG-EQRM This class needs comments. And where are it's methods? recurrence_functions might have 1. """ self.recurrence_models = recurrence_model_seq weights_corrected = parse_in_parameters.check_sum_1_normalise( asarray([rm.raw_weight for rm in self.recurrence_models]), "All recurrence model weights in a zone must sum to 1.0") for rm, wc in zip(self.recurrence_models, weights_corrected): rm.weight = wc self.actual_min_mag_generation = max(generation_min_mag, min(m.min_magnitude for m in self.recurrence_models)) self.event_type = event_type self.name = name super(Source, self).__init__(name)
def set_atten_models_and_weights(self, atten_models, atten_model_weights): """Add attenuation model and weight attribute lists. atten_models list of ground motion models atten_weights list of ground motion model weights Also ensure that the sum of weights is 1.0. """ self.atten_models = atten_models self.atten_model_weights = parse_in_parameters.check_sum_1_normalise( atten_model_weights)
def __init__(self, filename, event_type, fault_type, branch_list, scaling_dict): """Construct an object from event group data. filename name of file we are reading (for debug) event_type a string describing the event type fault_type a string describing the fault type branch_list a list of dictionaries {'model': '...', 'weight': '0.5'} scaling_dict a dictionary {'scaling_rule': '...', 'scaling_fault_type': '...'} The constructed object will have the following attributes: .event_type - event type string .fault_type - fault type string .branch_models - list of branch models .branch_weights - list of branch wrights .scaling_dict - event scaling information """ self.event_type = event_type self.fault_type = fault_type self.branch_models = [] self.branch_weights = [] for b in branch_list: self.branch_models.append(b['model']) weight = float(b['weight']) self.branch_weights.append(weight) self.branch_weights = asarray(self.branch_weights) msg = ("XML file %s: weights for event group '%s' should sum " "to 1.0, got %.1f" % (filename, event_type, sum(self.branch_weights))) self.branch_weights = parse_in_parameters.check_sum_1_normalise( self.branch_weights, msg) try: _ = scaling_dict['scaling_rule'] except KeyError: msg = ("XML file %s: missing 'scaling_rule' attribute" " in event group '%s'" % (filename, event_type)) raise Exception(msg) self.scaling_dict = scaling_dict