Ejemplo n.º 1
0
def mean(tr, params):
    """
    Return DC offset of input trace.

    Arguments:
    tr - Trace4.1 schema trace object <class 'Dbptr'>
    params - Empty <dict>

    Return Values:
    <list> of <dict>s containing field:value pairs. Field values 
    correspond to a CSS3.0 schema wfmeas table fields.

    """
    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate", "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        m = cs.mean(d[istart:iend])
        if abs(m) > params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append(
            {"meastype": params["meastype"], "tmeas": time + dt * i[0], "twin": dt * (i[1] - i[0]), "auth": "auto_qc"}
        )
    return ret
Ejemplo n.º 2
0
def rms(tr, params):
    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate",
                                             "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        rms = cs.rms(d[istart:iend])
        if abs(rms) < params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append({
            "meastype": params["meastype"],
            "tmeas": time + dt * i[0],
            "twin": dt * (i[1] - i[0]),
            "auth": "auto_qc",
        })
    return ret
Ejemplo n.º 3
0
def std(tr, params):
    """
    Test for large spread in data.

    Arguments:
    tr - Trace4.1 schema trace object <class 'Dbptr'>
    params - User-defined parameters <dict>
    params['filter'] - Antelope filter string <str>

    Return Values:
    <list> of <dict>s containing field:value pairs. Field values
    correspond to a CSS3.0 schema wfmeas table fields.
    """

    from math import sqrt

    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate",
                                             "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        var = cs.var(d[istart:iend])
        if sqrt(var) > params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append({
            "meastype": params["meastype"],
            "tmeas": time + dt * i[0],
            "twin": dt * (i[1] - i[0]),
            "auth": "auto_qc",
        })
    return ret
Ejemplo n.º 4
0
def std(tr, params):
    """
    Test for large spread in data.

    Arguments:
    tr - Trace4.1 schema trace object <class 'Dbptr'>
    params - User-defined parameters <dict>
    params['filter'] - Antelope filter string <str>

    Return Values:
    <list> of <dict>s containing field:value pairs. Field values 
    correspond to a CSS3.0 schema wfmeas table fields.

    """
    from numpy import std, float64
    from math import sqrt

    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate", "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        var = cs.var(d[istart:iend])
        if sqrt(var) > params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append(
            {"meastype": params["meastype"], "tmeas": time + dt * i[0], "twin": dt * (i[1] - i[0]), "auth": "auto_qc"}
        )
    return ret
Ejemplo n.º 5
0
def mean(tr, params):
    """
    Return DC offset of input trace.

    Arguments:
    tr - Trace4.1 schema trace object <class 'Dbptr'>
    params - Empty <dict>

    Return Values:
    <list> of <dict>s containing field:value pairs. Field values
    correspond to a CSS3.0 schema wfmeas table fields.

    """
    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate",
                                             "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        m = cs.mean(d[istart:iend])
        if abs(m) > params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append({
            "meastype": params["meastype"],
            "tmeas": time + dt * i[0],
            "twin": dt * (i[1] - i[0]),
            "auth": "auto_qc",
        })
    return ret
Ejemplo n.º 6
0
def rms(tr, params):
    d = tr.data()
    time, endtime, samprate, nsamp = tr.getv("time", "endtime", "samprate", "nsamp")
    dt = 1.0 / samprate
    nsmps = int(params["twin"] * samprate)
    inds = []
    for i in range(int(nsamp / nsmps)):
        istart = i * nsmps
        iend = istart + nsmps
        if iend > len(d):
            break
        rms = cs.rms(d[istart:iend])
        if abs(rms) < params["thresh"]:
            inds.append((istart, iend))
    if len(inds) == 0:
        return None
    inds = _flatten_index_tuples(inds)
    ret = []
    for i in inds:
        ret.append(
            {"meastype": params["meastype"], "tmeas": time + dt * i[0], "twin": dt * (i[1] - i[0]), "auth": "auto_qc"}
        )
    return ret