コード例 #1
0
    def test_planewave1(self):
        w = wave.planewave((1, 12), (1, 2), 0.4, 0)
        w1 = wave.planewave1(12, (1, 2), 0.4)
        self.allclose(w[..., 0, :], w1)
        w = wave.planewave((12, 1), (1, 2), 0.4, np.pi / 2)
        self.allclose(w[..., 0], w1)
        out = np.empty_like(w1)
        wave.planewave1(12, (1, 2), 0.4, out=out)
        self.allclose(out, w1)

        w = wave.planewave((1, 12), 2, 0.4, 0)
        w1 = wave.planewave1(12, 2, 0.4)
        self.allclose(w[0, :], w1)
コード例 #2
0
 def test_planewave_k(self):
     shape = (13, 11)
     for k in (0.1, 1., 10):
         b, p = wave.betaphi(shape, k)
         for i in range(shape[0]):
             for j in range(shape[1]):
                 w1 = wave.planewave(shape, k, b[i, j], p[i, j])
                 w2 = wave.eigenwave(shape, i, j)
                 self.allclose(w1, w2)
コード例 #3
0
 def test_planewave_shapes(self):
     shapes = ((16, 16), (15, 15), (12, 13), (7, 6))
     k = 1
     for shape in shapes:
         b, p = wave.betaphi(shape, k)
         for i in range(shape[0]):
             for j in range(shape[1]):
                 w1 = wave.planewave(shape, k, b[i, j], p[i, j])
                 w2 = wave.eigenwave(shape, i, j)
                 self.allclose(w1, w2)
コード例 #4
0
 def test_wave2eigenwave(self):
     w = wave.planewave((12, 14), (1, 2), 0.5, 0)
     e = wave.wave2eigenwave(w)
     e0 = wave.eigenwave((12, 14), 0, 1)
     self.allclose(e[0], e0)
     e0 = wave.eigenwave((12, 14), 0, 2)
     self.allclose(e[1], e0)
     out = np.empty_like(e)
     wave.wave2eigenwave(w, out=out)
     self.allclose(out, e)
     self.iscomplex(e)
コード例 #5
0
def illumination_waves(shape, k0, beta=0., phi=0., window=None, out=None):
    """Builds scalar illumination wave. 
    """
    k0 = np.asarray(k0)
    beta = np.asarray(beta)[..., np.newaxis]
    phi = np.asarray(phi)[..., np.newaxis]
    if not k0.ndim in (0, 1):
        raise ValueError("k0, must be an array with dimesion 1")
    out = planewave(shape, k0, beta, phi, out)
    if window is None:
        return out
    else:
        return np.multiply(out, window, out=out)
コード例 #6
0
ファイル: field.py プロジェクト: IJSComplexMatter/dtmm
def illumination_eigenwaves(shape, k0, beta=0., phi=0., out=None):
    """Builds scalar illumination wave. 
    """
    k0 = np.asarray(k0)
    beta = np.asarray(beta)
    phi = np.asarray(phi)
    if beta.ndim < 1:  #and k0.ndim == 1:
        beta = beta[..., np.newaxis]
    if phi.ndim < 1:  #and k0.ndim == 1:
        phi = phi[..., np.newaxis]
    if not k0.ndim in (0, 1):
        raise ValueError("k0, must be an array with dimesion 1")
    out = planewave(shape, k0, beta, phi, out)