Module pyspecan.utils.matrix

Functions

def cdot(x, y, psds, yt=0.05, yb=0.05)
Expand source code
def cdot(x, y, psds, yt=0.05, yb=0.05):
    hist = dot(x, y, psds, yt, yb)
    return _fill(hist)
def cvec(x, y, psds, yt=0.05, yb=0.05, interp=16)
Expand source code
def cvec(x, y, psds, yt=0.05, yb=0.05, interp=16):
    hist = vec(x, y, psds, yt, yb, interp)
    return _fill(hist)
def dot(x: int, y: int, psds, yt: float, yb: float)
Expand source code
def dot(x: int, y: int, psds, yt: float, yb: float):
    """Dot Matrix
    Each PSD's x/y mapped to histogram x/y
    """
    hist = np.zeros((y, x), dtype=np.int8)

    if np.all(psds < yb):
        return hist
    elif np.all(psds > yt):
        return hist

    y_rng = abs(abs(yt) - abs(yb))
    y_off = yb if yb > 0 else -yb

    x_ratio = x/psds.shape[0]
    y_ratio = y/y_rng

    x_idx = np.floor(np.arange(0, psds.shape[0])*x_ratio).astype(int)
    y_idx = np.floor((psds+y_off)*y_ratio).astype(int)

    y_idx = np.clip(y_idx, 0, y-1)

    y_val = np.ones_like(y_idx)
    y_val[y_idx == 0] = 0
    y_val[y_idx >= y-1] = 0

    for i in range(psds.shape[1]):
        hist[y_idx[:,i], x_idx] += y_val[:,i]
    return hist

Dot Matrix Each PSD's x/y mapped to histogram x/y

def vec(x, y, psds, yt=0.05, yb=0.05, interp=32)
Expand source code
def vec(x, y, psds, yt=0.05, yb=0.05, interp=32):
    """Vector Matrix
    Interpolate between PSD x/y to mimic vector matrix
    """
    y_int = np.zeros((psds.shape[0]*interp, psds.shape[1]))
    t = np.arange(psds.shape[0])*interp
    t_int = np.arange(psds.shape[0]*interp)-1
    for i in range(psds.shape[1]):
        y_int[:,i] = np.interp(t_int, t, psds[:,i])
    return dot(x, y, y_int, yt, yb)

Vector Matrix Interpolate between PSD x/y to mimic vector matrix