def _parse_processing_data(self, wfid, metadata): """ Parses the information for each component """ if metadata["Type of Filter"]: filter_params1 = { 'Type': FILTER_TYPE[metadata["Type of Filter"]], 'Order': None, 'Passes': get_positive_int(metadata['npass']), 'NRoll': get_positive_int(metadata['nroll']), 'High-Cut': get_positive_float(metadata["LP-H1 (Hz)"]), 'Low-Cut': get_positive_float(metadata["HP-H1 (Hz)"])} filter_params2 = { 'Type': FILTER_TYPE[metadata["Type of Filter"]], 'Order': None, 'Passes': get_positive_int(metadata['npass']), 'NRoll': get_positive_int(metadata['nroll']), 'High-Cut': get_positive_float(metadata["LP-H2 (Hz)"]), 'Low-Cut': get_positive_float(metadata["HP-H2 (Hz)"])} else: filter_params1, filter_params2 = None, None intensity_measures = { # All m - convert to cm 'PGA': None, 'PGV': None, 'PGD': None } luf1 = get_float(metadata["Lowest Usable Freq - H1 (Hz)"]) if luf1 and luf1 > 0.0: lup1 = 1. / luf1 else: lup1 = None luf2 = get_float(metadata["Lowest Usable Freq - H2 (Hz)"]) if luf2 and luf2 > 0.0: lup2 = 1. / luf2 else: lup2 = None xcomp = Component(wfid, "1", ims=intensity_measures, longest_period=lup1, waveform_filter=filter_params1, units=metadata["Unit (cm/s/s; m/s/s; g)"]) ycomp = Component(wfid, "2", ims=intensity_measures, longest_period=lup2, waveform_filter=filter_params2, units=metadata["Unit (cm/s/s; m/s/s; g)"]) luf3 = get_float(metadata["Lowest Usable Freq - V (Hz)"]) if luf3 and luf3 > 0.0: filter_params3 = { 'Type': FILTER_TYPE[metadata["Type of Filter"]], 'Order': None, 'Passes': get_int(metadata['npass']), 'NRoll': get_int(metadata['nroll']), 'High-Cut': get_float(metadata["LP-V (Hz)"]), 'Low-Cut': get_float(metadata["HP-V (Hz)"])} lup3 = 1. / luf3 zcomp = Component(wfid, "V", ims=intensity_measures, longest_period=lup3, waveform_filter=filter_params3, units=metadata["Unit (cm/s/s; m/s/s; g)"]) return xcomp, ycomp, zcomp else: return xcomp, ycomp, None
def _parse_event_data(self, metadata): """ Read in the distance related metadata and return an instance of the :class: smtk.sm_database.Earthquake """ data_fields = ['Month', 'Day', 'Hour', 'Minute', 'Second'] for f in data_fields: metadata[f] = metadata[f].zfill(2) # Date and Time year, month, day, hour, minute, second = self._validate_datetime( metadata) #year = get_int(metadata["Year"]) #month = get_int(metadata["Month"]) #day = get_int(metadata["Day"]) #hour = get_int(metadata["Hour"]) #minute = get_int(metadata["Minute"]) #second = get_int(metadata["Second"]) eq_datetime = datetime(year, month, day, hour, minute, second) # Event ID and Name eq_id = metadata["EQID"] eq_name = metadata["Earthquake Name"] # Focal Mechanism focal_mechanism = self._get_focal_mechanism(eq_id, eq_name, metadata) focal_mechanism.scalar_moment = get_float(metadata["Mo (dyne.cm)"]) *\ 1E-7 # Read magnitude pref_mag = Magnitude(get_float(metadata["Magnitude"]), metadata["Magnitude type"], sigma=get_float(metadata["Magnitude uncertainty"])) # Create Earthquake Class eqk = Earthquake(eq_id, eq_name, eq_datetime, get_float(metadata["Epicenter Longitude (deg; positive E)"]), get_float(metadata["Epicenter Latitude (deg; positive N)"]), get_float(metadata["Hypocenter Depth (km)"]), pref_mag, focal_mechanism, metadata["Country"]) # hypocenter location f1 = get_float(metadata[ "Along-strike Hypocenter location " + "on the fault (fraction between 0 and 1)"]) f2 = get_float(metadata[ "Along-width Hypocenter location " + "on the fault (fraction between 0 and 1)"]) if f1 is None or f2 is None: hypo_loc = (0.5, 0.7) else: hypo_loc = (f1, f2) eqk.tectonic_region = metadata["Tectonic environment (Crustal; Inslab; Interface; Stable; Geothermal; Volcanic; Oceanic_crust)"] if (eqk.tectonic_region == "Stable" or eqk.tectonic_region == "Crustal" or eqk.tectonic_region == "Oceanic_crust"): msr=WC1994() elif eqk.tectonic_region == "Inslab": msr=StrasserIntraslab() elif eqk.tectonic_region == "Interface": msr=StrasserInterface() # Warning rake set to 0.0 in scaling relationship - applies only # to WC1994 area = msr.get_median_area(pref_mag.value, 0.0) aspect_ratio = 1.5 width_model = np.sqrt(area / aspect_ratio) length_model = aspect_ratio * width_model ztor_model = eqk.depth - width_model / 2. if ztor_model < 0: ztor_model = 0.0 length = get_positive_float(metadata["Fault Rupture Length (km)"]) if length is None: length = length_model width = get_positive_float(metadata["Fault Rupture Width (km)"]) if width is None: width = width_model ztor = get_float(metadata["Depth to Top Of Fault Rupture Model"]) if ztor is None: ztor=ztor_model # Rupture eqk.rupture = Rupture(eq_id, eq_name, pref_mag, length, width, ztor, hypo_loc=hypo_loc) # get_float(metadata["Fault Rupture Length (km)"]), # get_float(metadata["Fault Rupture Width (km)"]), # get_float(metadata["Depth to Top Of Fault Rupture Model"]), # hypo_loc=hypo_loc) eqk.rupture.get_area() return eqk