def test_sos_freqresp():
    H = sos_FreqResp(S0, delta, f0, fe5)
    indmax = np.abs(H).argmax()
    assert np.round(np.abs(f0 - fe5[indmax])) <= 0.01 * f0
    assert np.abs(H[0]) == approx(S0)
    Hmulti = sos_FreqResp(S0 * np.ones(K), delta * np.ones(K), f0 * np.ones(K), fe5)
    assert Hmulti.shape[1] == K
def test_sos_freqresp():
    H = sos_FreqResp(S0, delta, f0, fe5)
    indmax = np.abs(H).argmax()
    assert np.round(np.abs(f0 - fe5[indmax])) <= 0.01 * f0
    assert np.abs(H[0]) == approx(S0)
    Hmulti = sos_FreqResp(S0 * np.ones(K), delta * np.ones(K), f0 * np.ones(K),
                          fe5)
    assert Hmulti.shape[1] == K
def test_sos_phys2filter():
    b, a = sos_phys2filter(S0, delta, f0)
    H = freqs(b, a, 2 * np.pi * fe5)[1]
    indmax = np.abs(H).argmax()
    assert np.round(np.abs(f0 - fe5[indmax])) <= 0.01 * f0
    assert np.abs(H[0]) == approx(S0)
    bmulti, amulti = sos_phys2filter(S0 * np.ones(K), delta * np.ones(K), f0 * np.ones(K))
    assert len(bmulti[0]) == K
    assert amulti.shape == (K, 3)
def test_sos_phys2filter():
    b, a = sos_phys2filter(S0, delta, f0)
    H = freqs(b, a, 2 * np.pi * fe5)[1]
    indmax = np.abs(H).argmax()
    assert np.round(np.abs(f0 - fe5[indmax])) <= 0.01 * f0
    assert np.abs(H[0]) == approx(S0)
    bmulti, amulti = sos_phys2filter(S0 * np.ones(K), delta * np.ones(K),
                                     f0 * np.ones(K))
    assert len(bmulti[0]) == K
    assert amulti.shape == (K, 3)
Beispiel #5
0
 def _compute_factorization(self, coords_flat):
     # hash each coordinate in grid to unique value
     hashed_coords = self._hash_coords(coords_flat)
     unique_hashes, unique_idx, idx = np.unique(hashed_coords, return_index=True, return_inverse=True)
     # identify unique set of vertices
     unique_coords = coords_flat[unique_idx]
     self.nvertices = len(unique_coords)
     # construct sparse splat matrix that maps from pixels to vertices
     self.S = csr_matrix((np.ones(self.npixels), (idx, np.arange(self.npixels))))
     # construct sparse blur matrices, note that these represent [1 0 1] blurs, excluding the central element
     self.blurs = []
     for d in range(self.dim):
         blur = 0.0
         for offset in (-1, 1):
             offset_vec = np.zeros((1, self.dim))
             offset_vec[:, d] = offset
             neighbor_hash = self._hash_coords(unique_coords + offset_vec)
             valid_coord, idx = get_valid_idx(unique_hashes, neighbor_hash)
             blur = blur + csr_matrix((np.ones((len(valid_coord),)), (valid_coord, idx)),
                                      shape=(self.nvertices, self.nvertices))
         self.blurs.append(blur)