def _parse_component_data(self, wfid, proc_data):
        """
        Parses the information for each component
        """
        filter_params = {
            'Type': proc_data['comp_ordered.filter_type'],
            'Order': proc_data['comp_ordered.filter_order'],
            'Passes': get_int(
                proc_data['comp_ordered.filter_number_of_passes']),
            'NRoll': get_int(proc_data['comp_ordered.nroll']),
            'High-Cut': get_float(proc_data['comp_ordered.high_cut_freq']),
            'Low-Cut': get_float(proc_data['comp_ordered.low_cut_freq'])}

        intensity_measures = {
            # All m - convert to cm
            'PGA': get_float(proc_data['comp_ordered.pga']),
            'PGV': get_float(proc_data['comp_ordered.pgv']),
            'PGD': get_float(proc_data['comp_ordered.pgd'])
            }

        for imkey in intensity_measures.keys():
            if intensity_measures[imkey]:
                intensity_measures[imkey] = 100.0 * intensity_measures[imkey]
            
        comp = Component(wfid,
            proc_data['comp_ordered.orientation'],
            ims=intensity_measures,
            longest_period=None,
            waveform_filter=filter_params,
            baseline=proc_data['comp_ordered.baseline_correction'])
        return comp
示例#2
0
    def _parse_event_data(self, metadata):
        """
        Read in the distance related metadata and return an instance of the
        :class: smtk.sm_database.Earthquake

        """
        metadata["MODY"] = metadata["MODY"].zfill(4)
        metadata["HRMN"] = metadata["HRMN"].zfill(4)
        # Date and Time
        year = get_int(metadata["YEAR"])
        month = get_int(metadata["MODY"][:2])
        day = get_int(metadata["MODY"][2:])
        hour = get_int(metadata["HRMN"][:2])
        minute = get_int(metadata["HRMN"][2:])
        eq_datetime = datetime(year, month, day, hour, minute)
        # 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["Earthquake Magnitude"]),
                             metadata["Magnitude Type"],
                             sigma=get_float(metadata["Uncertainty"]))
        # Create Earthquake Class
        eqk = Earthquake(eq_id, eq_name, eq_datetime,
                         get_float(metadata["Hypocenter Longitude (deg)"]),
                         get_float(metadata["Hypocenter Latitude (deg)"]),
                         get_float(metadata["Hypocenter Depth (km)"]),
                         pref_mag, focal_mechanism, metadata["Country"])
        hypo_loc = (0.5, 0.7)  # Hypocentre Location
        msr = WC1994()
        # Warning rake set to 0.0 in scaling relationship
        area = msr.get_median_area(pref_mag.value, 0.0)
        aspect_ratio = 1.5  # Assumed Fixed
        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_float(metadata["Fault Rupture Length (km)"])
        if length is None:
            length = length_model
        width = get_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)
        #    get_float(metadata["Fault Rupture Length (km)"]),
        #    get_float(metadata["Fault Rupture Width (km)"]),
        #    get_float(metadata["Depth to Top Of Fault Rupture Model"]))
        eqk.rupture.get_area()
        return eqk
 def _parse_distance_data(self, metadata):
     """
     Parses the distance data
     """
     return RecordDistance(get_float(metadata['distance_repi']),
                           get_float(metadata['distance_rhyp']),
                           rjb = get_float(metadata['distance_rjb']),
                           rrup = get_float(metadata['distance_rrup']),
                           r_x = None,
                           flag = get_int(metadata['distance_flag']))
示例#4
0
    def _parse_processing_data(self, wfid, metadata):
        """
        Parses the information for each component
        """
        filter_params1 = {
            '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-H1 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H1 (Hz)"])
        }

        filter_params2 = {
            '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-H2 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H2 (Hz)"])
        }
        intensity_measures = {
            # All m - convert to cm
            'PGA': None,
            'PGV': None,
            'PGD': None
        }

        lup1 = 1. / get_float(metadata["Lowest Usable Freq - H1 (Hz)"])
        lup2 = 1. / get_float(metadata["Lowest Usable Freq - H2 (Hz)"])
        xcomp = Component(wfid,
                          "1",
                          ims=intensity_measures,
                          longest_period=lup1,
                          waveform_filter=filter_params1,
                          units=metadata["Unit"])
        ycomp = Component(wfid,
                          "2",
                          ims=intensity_measures,
                          longest_period=lup2,
                          waveform_filter=filter_params2,
                          units=metadata["Unit"])
        return xcomp, ycomp, None
    def _parse_processing_data(self, wfid, metadata):
        """
        Parses the information for each component
        """
        filter_params1 = {
            '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-H1 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H1 (Hz)"])}

        filter_params2 = {
            '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-H2 (Hz)"]),
            'Low-Cut': get_float(metadata["HP-H2 (Hz)"])}
        intensity_measures = {
            # All m - convert to cm
            'PGA': None,
            'PGV': None,
            'PGD': None
            }

        lup1 = 1. / get_float(metadata["Lowest Usable Freq - H1 (Hz)"])
        lup2 = 1. / get_float(metadata["Lowest Usable Freq - H2 (Hz)"])
        xcomp = Component(wfid, "1",
            ims=intensity_measures,
            longest_period=lup1,
            waveform_filter=filter_params1,
            units=metadata["Unit"])
        ycomp = Component(wfid, "2",
            ims=intensity_measures,
            longest_period=lup2,
            waveform_filter=filter_params2,
            units=metadata["Unit"]) 
        return xcomp, ycomp, None
示例#6
0
 def _validate_datetime(metadata):
     """
     SARA flatfile should be formatted correctly but other flatfiles
     are prone to bad datetime values - these will be overwritten
     """
     return (get_int(metadata["Year"]), get_int(metadata["Month"]),
             get_int(metadata["Day"]), get_int(metadata["Hour"]),
             get_int(metadata["Minute"]), get_int(metadata["Second"]))
 def _validate_datetime(metadata):
     """
     SARA flatfile should be formatted correctly but other flatfiles
     are prone to bad datetime values - these will be overwritten
     """
     return (get_int(metadata["Year"]), get_int(metadata["Month"]),
             get_int(metadata["Day"]), get_int(metadata["Hour"]),
             get_int(metadata["Minute"]), get_int(metadata["Second"]))
 def _parse_site_data(self, metadata):
     """
     Parse the site data
     """
     site = RecordSite(
         metadata['station.oid'],
         metadata['station.name'],
         metadata['station.code'],
         get_float(metadata['station.longitude']),
         get_float(metadata['station.latitude']),
         get_float(metadata['station.altitude']),
         vs30=get_float(metadata['station.vs30']),
         vs30_measured=get_int(metadata['station.vs30_measured']),
         network_code=metadata['station.agency.name'],
         country=metadata['station.country.name'])
     site.vs30_measured_type = metadata['station.vs30_measured_type']
     site.instrument_type = metadata['recording_type']
     site.digitiser = metadata['digitalizer']
     site.building_structure = metadata['station.building_struct.name']
     site.number_floors = get_int(metadata['station.number_of_floor'])
     site.floor = metadata['station.installed_on_floor']
     site.ec8 = metadata['station.ec8']
     return site
示例#9
0
    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
示例#10
0
    def _parse_event(self, metadata, file_str):
        """
        Parses the event metadata to return an instance of the :class:
        smtk.sm_database.Earthquake
        """

        months = {
            'ENERO': 1,
            'FEBRERO': 2,
            'MARZO': 3,
            'ABRIL': 4,
            'MAYO': 5,
            'JUNIO': 6,
            'JULIO': 7,
            'AGOSTO': 8,
            'SEPTIEMBRE': 9,
            'OCTUBURE': 10,
            'NOVIEMBRE': 11,
            'DICIEMBRE': 12
        }

        # Date and time
        try:  # UNAM DATES
            year, month, day = (
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[0]),
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[1]),
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[2]))
        except:  # CICESE DATES
            year, month, day = (
                get_int(metadata["FECHA DEL SISMO (GMT)"][-4:]),
                months[metadata["FECHA DEL SISMO (GMT)"].split()[2]],
                get_int(metadata["FECHA DEL SISMO (GMT)"][:2]))

        # Get event time, naming is not consistent (e.g. 07.1, 00, 17,1)
        for i in metadata:
            if 'HORA EPICENTRO (GMT)' in i:
                hour, minute, second = (
                    get_int(metadata[i].split(":")[0]),
                    get_int(metadata[i].split(":")[1]),
                    int(
                        float(metadata[i].split(":")[2].replace(
                            "0", "", 1).replace(",", "."))))

        try:
            eq_datetime = datetime(year, month, day, hour, minute, second)
        except:
            raise ValueError("Record %s is missing event time" % file_str)

        # Event ID - No EVID, so use the date and time of the event
        eq_id = str(eq_datetime).replace(" ", "_")

        # Event Name
        eq_name = None

        # Get magnitudes, below are the different types given in ASA files
        moment_mag = None
        surface_mag = None
        body_mag = None
        c_mag = None
        l_mag = None
        e_mag = None
        a_mag = None
        m_mag = None

        mag_list = []
        mag = metadata["MAGNITUD(ES)"].split("/")
        for i in range(0, len(mag)):
            if mag[i][0:2] == "":
                continue
            if mag[i][0:2] == "Mw":
                m_w = get_float(mag[i][3:])
                moment_mag = Magnitude(m_w, "Mw")
                mag_list.append(moment_mag)
            if mag[i][0:2] == "Ms":
                m_s = get_float(mag[i][3:])
                surface_mag = Magnitude(m_s, "Ms")
                mag_list.append(surface_mag)
            if mag[i][0:2] == "Mb":
                m_b = get_float(mag[i][3:])
                body_mag = Magnitude(m_b, "Mb")
                mag_list.append(body_mag)
            if mag[i][0:2] == "Mc":
                m = get_float(mag[i][3:])
                c_mag = Magnitude(m, "Mc")
                mag_list.append(c_mag)
            if mag[i][0:2] == "Ml":
                m = get_float(mag[i][3:])
                l_mag = Magnitude(m, "Ml")
                mag_list.append(l_mag)
            if mag[i][0:2] == "Me" or mag[i][0:2] == "ME":
                m = get_float(mag[i][3:])
                e_mag = Magnitude(m, "Me")
                mag_list.append(e_mag)
            if mag[i][0:2] == "Ma":
                m = get_float(mag[i][3:])
                a_mag = Magnitude(m, "Ma")
                mag_list.append(a_mag)
            if mag[i][0:2] == "M=":
                m = get_float(mag[i][2:])
                m_mag = Magnitude(m, "M")
                mag_list.append(m_mag)

        # magnitude hierarchy for defining pref_mag
        if moment_mag is not None:
            pref_mag = moment_mag
        elif surface_mag is not None:
            pref_mag = surface_mag
        elif body_mag is not None:
            pref_mag = body_mag
        elif c_mag is not None:
            pref_mag = c_mag
        elif l_mag is not None:
            pref_mag = l_mag
        elif e_mag is not None:
            pref_mag = e_mag
        elif a_mag is not None:
            pref_mag = a_mag
        elif m_mag is not None:
            pref_mag = m_mag
        else:
            raise ValueError("Record %s has no magnitude!" % file_str)

        # Get focal mechanism data (not given in ASA file)
        foc_mech = FocalMechanism(eq_id,
                                  eq_name,
                                  None,
                                  None,
                                  mechanism_type=None)

        # Get depths, naming is not consistent so allow for variation
        for i in metadata:
            if 'PROFUNDIDAD ' in i:
                # assume <5km = 5km
                evtdepth = get_float(re.sub('[ <>]', '', metadata[i]))
        if evtdepth is None:
            raise ValueError("Record %s is missing event depth" % file_str)

        # Build event
        eqk = Earthquake(
            eq_id, eq_name, eq_datetime,
            get_float(metadata["COORDENADAS DEL EPICENTRO"].split(" ")[3]),
            get_float(metadata["COORDENADAS DEL EPICENTRO"].split(" ")[0]),
            evtdepth, pref_mag, foc_mech)

        eqk.magnitude_list = mag_list

        return eqk
    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 = 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)

        evt_tectonic_region = metadata["Tectonic environment (Crustal; Inslab; Interface; Stable; Geothermal; Volcanic; Oceanic_crust)"]
        if evt_tectonic_region == "Stable" or evt_tectonic_region == "Crustal":
            msr=WC1994()
        elif evt_tectonic_region == "Inslab":
            msr=StrasserIntraslab()
        elif evt_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_float(metadata["Fault Rupture Length (km)"])
        if length is None:
            length = length_model
        width = get_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,
                              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
    def _parse_event_data(self, metadata):
        """
        Read in the distance related metadata and return an instance of the
        :class: smtk.sm_database.Earthquake

        """
        metadata["MODY"] = metadata["MODY"].zfill(4)
        metadata["HRMN"] = metadata["HRMN"].zfill(4)
        # Date and Time
        year = get_int(metadata["YEAR"])
        month = get_int(metadata["MODY"][:2])
        day = get_int(metadata["MODY"][2:])
        hour = get_int(metadata["HRMN"][:2])
        minute = get_int(metadata["HRMN"][2:])
        eq_datetime = datetime(year, month, day, hour, minute)
        # 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["Earthquake Magnitude"]),
                             metadata["Magnitude Type"],
                             sigma=get_float(metadata["Uncertainty"]))
        # Create Earthquake Class
        eqk = Earthquake(eq_id, eq_name, eq_datetime,
            get_float(metadata["Hypocenter Longitude (deg)"]),
            get_float(metadata["Hypocenter Latitude (deg)"]),
            get_float(metadata["Hypocenter Depth (km)"]),
            pref_mag,
            focal_mechanism,
            metadata["Country"])
        hypo_loc = (0.5, 0.7)   # Hypocentre Location
        msr=WC1994()
        # Warning rake set to 0.0 in scaling relationship
        area = msr.get_median_area(pref_mag.value,0.0)
        aspect_ratio = 1.5 # Assumed Fixed
        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_float(metadata["Fault Rupture Length (km)"])
        if length is None:
            length = length_model
        width = get_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)
        #    get_float(metadata["Fault Rupture Length (km)"]),
        #    get_float(metadata["Fault Rupture Width (km)"]),
        #    get_float(metadata["Depth to Top Of Fault Rupture Model"]))
        eqk.rupture.get_area()
        return eqk
    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(self, metadata, file_str):
        """
        Parses the event metadata to return an instance of the :class:
        smtk.sm_database.Earthquake. Coordinates in western hemisphere
        are returned as negative values.
        """

        months = {'ENERO': 1, 'FEBRERO': 2, 'MARZO': 3, 'ABRIL': 4, 'MAYO': 5,
                 'JUNIO': 6, 'JULIO': 7, 'AGOSTO': 8, 'SEPTIEMBRE': 9,
                 'OCTUBURE': 10, 'NOVIEMBRE': 11, 'DICIEMBRE': 12}

        months_abrev = {'ENE': 1, 'FEB': 2, 'MAR': 3, 'ABR': 4, 'MAY': 5,
                 'JUN': 6, 'JUL': 7, 'AGO': 8, 'SEP': 9,
                 'OCT': 10, 'NOV': 11, 'DIC': 12}

        # Date and time
        if 'CICESE' in metadata["INSTITUCION RESPONSABLE"]:
            year, month, day = (
                get_int(metadata["FECHA DEL SISMO (GMT)"][-4:]),
                months[metadata["FECHA DEL SISMO (GMT)"].split()[2]],
                get_int(metadata["FECHA DEL SISMO (GMT)"][:2]))
        elif 'CIRES' in metadata["INSTITUCION RESPONSABLE"]:
            year, month, day = (
                get_int('20'+metadata["FECHA DEL SISMO (GMT)"][-2:]),
                months_abrev[metadata["FECHA DEL SISMO (GMT)"].split('/')[1]],
                get_int(metadata["FECHA DEL SISMO (GMT)"][:2]))
        # UNAM data, which is not always indicated in "INSTITUCION RESPONSABLE"
        else:
            year, month, day = (
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[0]),
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[1]),
                get_int(metadata["FECHA DEL SISMO [GMT]"].split("/")[2]))

        # Get event time, naming is not consistent (e.g. 07.1, 00, 17,1)
        for i in metadata:
            if 'HORA EPICENTRO (GMT)' in i:
                hour, minute, second = (get_int(metadata[i].split(":")[0]),
                                        get_int(metadata[i].split(":")[1]),
                                        int(float(metadata[i].split(":")[2].
                                            replace("0", "", 1).
                                            replace(",", "."))))
        try:
            eq_datetime = datetime(year, month, day, hour, minute, second)
        except:
            raise ValueError("Record %s is missing event time" % file_str)

        # Event ID - No EVID, so use the date and time of the event
        eq_id = str(eq_datetime).replace(" ", "_")

        # Event Name
        eq_name = None

        # Get magnitudes, below are the different types given in ASA files
        moment_mag = None
        surface_mag = None
        body_mag = None
        c_mag = None
        l_mag = None
        e_mag = None
        a_mag = None
        m_mag = None

        mag_list = []
        mag = metadata["MAGNITUD(ES)"].split("/")
        for i in range(0, len(mag)):
            if mag[i][0:2] == "":
                continue
            if mag[i][0:2] == "Mw":
                m_w = get_float(mag[i][3:])
                moment_mag = Magnitude(m_w, "Mw")
                mag_list.append(moment_mag)
            if mag[i][0:2] == "Ms":
                m_s = get_float(mag[i][3:])
                surface_mag = Magnitude(m_s, "Ms")
                mag_list.append(surface_mag)
            if mag[i][0:2] == "Mb":
                m_b = get_float(mag[i][3:])
                body_mag = Magnitude(m_b, "Mb")
                mag_list.append(body_mag)
            if mag[i][0:2] == "Mc":
                m = get_float(mag[i][3:])
                c_mag = Magnitude(m, "Mc")
                mag_list.append(c_mag)
            if mag[i][0:2] == "Ml":
                m = get_float(mag[i][3:])
                l_mag = Magnitude(m, "Ml")
                mag_list.append(l_mag)
            if mag[i][0:2] == "Me" or mag[i][0:2] == "ME":
                m = get_float(mag[i][3:])
                e_mag = Magnitude(m, "Me")
                mag_list.append(e_mag)
            if mag[i][0:2] == "Ma":
                m = get_float(mag[i][3:])
                a_mag = Magnitude(m, "Ma")
                mag_list.append(a_mag)
            if mag[i][0:2] == "M=":
                m = get_float(mag[i][2:])
                m_mag = Magnitude(m, "M")
                mag_list.append(m_mag)

        # magnitude hierarchy for defining pref_mag
        if moment_mag is not None:
            pref_mag = moment_mag
        elif surface_mag is not None:
            pref_mag = surface_mag
        elif body_mag is not None:
            pref_mag = body_mag
        elif c_mag is not None:
            pref_mag = c_mag
        elif l_mag is not None:
            pref_mag = l_mag
        elif e_mag is not None:
            pref_mag = e_mag
        elif a_mag is not None:
            pref_mag = a_mag
        elif m_mag is not None:
            pref_mag = m_mag
        else:
            raise ValueError("Record %s has no magnitude!" % file_str)

        # Get focal mechanism data (not given in ASA file)
        foc_mech = FocalMechanism(eq_id,
                                  eq_name,
                                  None,
                                  None,
                                  mechanism_type=None)

        # Get depths, naming is not consistent so allow for variation
        for i in metadata:
                if 'PROFUNDIDAD ' in i:
                    # assume <5km = 5km
                    evtdepth = get_float(re.sub('[ <>]', '', metadata[i]))
        if evtdepth is None:
            raise ValueError("Record %s is missing event depth" % file_str)

        # Build event
        eqk = Earthquake(
            eq_id,
            eq_name,
            eq_datetime,
            -get_float(metadata["COORDENADAS DEL EPICENTRO"].split(" ")[3]),
            get_float(metadata["COORDENADAS DEL EPICENTRO"].split(" ")[0]),
            evtdepth,
            pref_mag,
            foc_mech)

        eqk.magnitude_list = mag_list

        return eqk