Beispiel #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
Beispiel #2
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