goofi v3.0.0

ZeroCrossings

Zero crossings: how often the signal changes sign over the window.

Explore this node in the cookbook →

ZeroCrossings py
data
count
Type name
signal:ZeroCrossings
Plane
signal
Tags
analysis
Language
python
Tier
in-process
Bundle
complexity
Source
node-bundles/complexity/zero_crossings.py
Availability
available

Slots

SlotDirectionType
datainputARRAY
countoutputARRAY

Parameters

zero

NameTypeDefaultRangeDoc
normalizeboolfalseDivide by the window length, for a rate per sample.

Source

The current source of this node, as it stands in the goofi repository at node-bundles/complexity/zero_crossings.py.

node-bundles/complexity/zero_crossings.py
"""ZeroCrossings — how often a signal changes sign, from antropy.

The crudest frequency estimate there is, and the cheapest: a sine at f crosses zero 2f times a
second. The last axis is time and is consumed; every axis before it survives.
"""

import antropy
import numpy as np
import goofi


class ZeroCrossings(goofi.Node):
    """Zero crossings: how often the signal changes sign over the window."""

    TAGS = ["analysis"]
    INPUTS = {"data": goofi.InputSlot(goofi.DataType.ARRAY, required=True)}
    OUTPUTS = {"count": goofi.DataType.ARRAY}
    PARAMS = {
        "zero": {
            "normalize": goofi.BoolParam(False, doc="Divide by the window length, for a rate per sample."),
        }
    }

    def process(self, data):
        out = antropy.num_zerocross(
            np.asarray(data.data, dtype=np.float64), normalize=self.params.zero.normalize, axis=-1
        )
        return np.asarray(out, dtype=np.float32), data.drop_axis(-1)

← All nodes