stop_itemp,
    taup_model,
] = read_input_par(filepar)
st = Stream()
tr = Trace()

# half time length of templates is used to calculate origin_time
half_time = tlen_bef

# read event coordinates from catalog
print("event catalog should be ZMAP or QUAKEML")

if _is_zmap(ev_catalog):
    print("reading ZMAP catalog")

elif _is_quakeml(ev_catalog):
    print("reading QUAKEML catalog")

else:
    print("warning error in reading ZMAP or QUAKEML")

cat = read_events(ev_catalog)

ncat = len(cat)
print(cat.__str__(print_all=True))

for iev in range(start_itemp, stop_itemp):
    inplist = tempinp_dir + str(
        iev) + ".??" + "." + "*" + "..???" + "." + "mseed"
    print("inplist == ...", inplist)
    st.clear()
Beispiel #2
0
def read_moment_quakeml(momentfile):
    """Read moment parameters from a QuakeML file.

    Args:
        momentfile (str): Path to a QuakeML file.

    Returns:
        dict: Empty if momentfile is somehow not valid, or:
              - moment:
                  - T:
                    - azimuth
                    - plunge
                  - N:
                    - azimuth
                    - plunge
                  - P:
                    - azimuth
                    - plunge
                  - NP1:
                    - strike: float
                    - dip: float
                    - rake: float
                  - NP2:
                    - strike: float
                    - dip: float
                    - rake: float
                  - type: string
                  - source: string
    """
    params = {}
    if not _is_quakeml(momentfile):
        return params

    # obspy spits out a bunch of warnings we don't care about
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        catalog = read_events(momentfile)

    if not len(catalog.events):
        return params
    event = catalog.events[0]
    if not len(event.focal_mechanisms):
        return params
    focal = catalog.events[0].focal_mechanisms[0]

    # get the source and type information, if possible
    mtype = 'unknown'
    if focal.method_id is not None:
        mtype = focal.method_id

    msource = 'unknown'
    if focal.creation_info is not None:
        if focal.creation_info.agency_id is not None:
            msource = focal.creation_info.agency_id

    if focal.nodal_planes is None:
        return params
    if focal.nodal_planes.nodal_plane_1 is None:
        if focal.moment_tensor.tensor.m_rr is not None:
            mrr = focal.moment_tensor.tensor.m_rr
            mtt = focal.moment_tensor.tensor.m_tt
            mpp = focal.moment_tensor.tensor.m_pp
            mrt = focal.moment_tensor.tensor.m_rt
            mrp = focal.moment_tensor.tensor.m_rp
            mtp = focal.moment_tensor.tensor.m_tp
            params = fill_tensor_from_components(mrr,
                                                 mtt,
                                                 mpp,
                                                 mrt,
                                                 mrp,
                                                 mtp,
                                                 source=msource,
                                                 mtype=mtype)
    else:
        plane1 = focal.nodal_planes.nodal_plane_1
        plane2 = focal.nodal_planes.nodal_plane_2
        params['NP1'] = {
            'strike': plane1.strike,
            'dip': plane1.dip,
            'rake': plane1.rake
        }
        params['NP2'] = {
            'strike': plane2.strike,
            'dip': plane2.dip,
            'rake': plane2.rake
        }
        params['T'] = {
            'azimuth': focal.principal_axes.t_axis.azimuth,
            'plunge': focal.principal_axes.t_axis.plunge
        }
        params['N'] = {
            'azimuth': focal.principal_axes.n_axis.azimuth,
            'plunge': focal.principal_axes.n_axis.plunge
        }
        params['P'] = {
            'azimuth': focal.principal_axes.p_axis.azimuth,
            'plunge': focal.principal_axes.p_axis.plunge
        }

    moment = {'moment': params}
    return moment