How to use the spaudiopy.utils.asarray_1d function in spaudiopy

To help you get started, we’ve selected a few spaudiopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chris-hld / spaudiopy / spaudiopy / sig.py View on Github external
def conv(self, h, **kwargs):
        """Convolve signal, kwargs are forwarded to signal.convolve."""
        h = utils.asarray_1d(h)
        self.signal = scysig.convolve(self.signal, h, **kwargs)
        return self
github chris-hld / spaudiopy / spaudiopy / sph.py View on Github external
SH_type :  'complex' or 'real' spherical harmonics.
    weights : (Q,) array_like, optional
        Quadrature weights.

    Returns
    -------
    Ymn : (Q, (N+1)**2) numpy.ndarray
        Matrix of spherical harmonics.

    Notes
    -----
    The convention used here is also known as N3D-ACN.

    """
    azi = utils.asarray_1d(azi)
    colat = utils.asarray_1d(colat)
    if azi.ndim == 0:
        Q = 1
    else:
        Q = len(azi)
    if weights is None:
        weights = np.ones(Q)
    if SH_type == 'complex':
        Ymn = np.zeros([Q, (N+1)**2], dtype=complex)
    elif SH_type == 'real':
        Ymn = np.zeros([Q, (N+1)**2], dtype=float)
    else:
        raise ValueError('SH_type unknown.')

    i = 0
    for n in range(N+1):
        for m in range(-n, n+1):
github chris-hld / spaudiopy / spaudiopy / sdm.py View on Github external
Pseudo intensity vector for each time sample.

    """
    # WIP
    if jobs_count is None:
        jobs_count = multiprocessing.cpu_count()

    assert(win_len % 2)
    win = np.hanning(win_len)
    fs = ambi_b.fs
    # Z_0 = 413.3
    # T_int = 1/fs * win_len
    # a = 1 / (np.sqrt(2) * T_int * Z_0)

    # get first order signals
    W = utils.asarray_1d(ambi_b.W)
    X = utils.asarray_1d(ambi_b.X)
    Y = utils.asarray_1d(ambi_b.Y)
    Z = utils.asarray_1d(ambi_b.Z)

    # Bandpass signals
    if f_bp is not None:
        f_lo = f_bp[0]
        f_hi = f_bp[1]
        b, a = signal.butter(N=2, Wn=(f_lo / (fs / 2), f_hi / (fs / 2)),
                             btype='bandpass')
        W = signal.filtfilt(b, a, W)
        X = signal.filtfilt(b, a, X)
        Y = signal.filtfilt(b, a, Y)
        Z = signal.filtfilt(b, a, Z)

    # Initialize intensity vector
github chris-hld / spaudiopy / spaudiopy / sig.py View on Github external
def __init__(self, signals, fs=None):
        MultiSignal.__init__(self, signals, fs=fs)
        assert self.channel_count == 4, "Provide four channels!"
        self.W = utils.asarray_1d(self.channel[0].signal)
        self.X = utils.asarray_1d(self.channel[1].signal)
        self.Y = utils.asarray_1d(self.channel[2].signal)
        self.Z = utils.asarray_1d(self.channel[3].signal)
github chris-hld / spaudiopy / spaudiopy / sph.py View on Github external
def src_to_B(signal, src_azi, src_colat):
    """Get B format signal channels for source in direction azi/colat."""
    signal = utils.asarray_1d(signal)
    src_azi = utils.asarray_1d(src_azi)
    src_colat = utils.asarray_1d(src_colat)
    gw = np.ones(len(src_azi))
    gx, gy, gz = utils.sph2cart(src_azi, src_colat)
    g = np.c_[gw, gx, gy, gz]
    return np.outer(g, signal)
github chris-hld / spaudiopy / spaudiopy / plots.py View on Github external
def spherical_function(f, azi, colat, title=None):
    """Plot function 1D vector f over azi and colat."""
    f = utils.asarray_1d(np.real_if_close(f))
    azi = utils.asarray_1d(azi)
    colat = utils.asarray_1d(colat)
    x, y, z = utils.sph2cart(azi, colat, r=abs(f))

    # triangulate in the underlying parametrization
    triang = tri.Triangulation(colat, azi)

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    p_tri = ax.plot_trisurf(x, y, z,
                            cmap=plt.cm.coolwarm,
                            # antialiased=False,
                            triangles=triang.triangles, shade=True,
                            edgecolor='none', linewidth=0.06, alpha=0.25)

    # Draw axis lines
github chris-hld / spaudiopy / spaudiopy / sph.py View on Github external
def src_to_B(signal, src_azi, src_colat):
    """Get B format signal channels for source in direction azi/colat."""
    signal = utils.asarray_1d(signal)
    src_azi = utils.asarray_1d(src_azi)
    src_colat = utils.asarray_1d(src_colat)
    gw = np.ones(len(src_azi))
    gx, gy, gz = utils.sph2cart(src_azi, src_colat)
    g = np.c_[gw, gx, gy, gz]
    return np.outer(g, signal)