def test_pca_mssa_ec(self): data = setup_data2(nx=30, ny=20) span = Analyzer(data) span.mssa(nmssa=4) ec = span.mssa_ec(xeof=span.mssa_eof(), xdata=data) pc = span.mssa_pc() self.assertTrue(npy.allclose(ec, pc))
def test_mssa_eof(self): data = setup_data2(nx=3, ny=2) span = Analyzer(data) eof = span.mssa_eof(nmssa=4) self.assertTrue(npy.allclose( eof[1,1].compressed(), npy.array([ 0.10764546, -0.0763087 , -0.07211439, 0.05060925, 0.128224 ])))
def test_ssa_xrec(self): data = setup_data0() span = Analyzer(data, nmssa=6) rec = span.mssa_rec() eof = span.mssa_eof() pc = span.mssa_pc() xrec = span.mssa_rec(xeof=eof, xpc=pc) self.assertTrue(npy.allclose(rec,xrec))
def test_mssa_eof_restack(self): data = setup_data2(nx=3, ny=2) span = Analyzer(data) steof = span.mssa_eof(nmssa=4) stacked_eof = npy.ascontiguousarray(span.restack(steof, scale=False)) self.assertTrue(npy.allclose(steof[1,1].compressed(), stacked_eof[:,1,1])) raw_eof = span._mssa_raw_eof.reshape(stacked_eof.shape) self.assertTrue(npy.allclose(stacked_eof, raw_eof))
def test_pca_mssa_xrec(self): data = setup_data2(nx=30, ny=20) span = Analyzer(data) rec = span.mssa_rec(nmssa=4) xeof = span.mssa_eof() xpc = span.mssa_pc() xrec = span.mssa_rec(xeof=xeof, xpc=xpc) self.assertTrue(npy.allclose(rec, xrec))
def test_pca_mssa(self): data = setup_data2(nx=30, ny=20) span = Analyzer(data, nmssa=2) self.assertTrue(npy.allclose( span.mssa_ev(), npy.array([ 2482.65882191, 2355.53413819]))) pc = span.mssa_pc() self.assertTrue(npy.allclose( span.mssa_pc()[:,:2].ravel(), npy.array([-19.47701848, -20.97653195, 2.99480916, -0.20444392]))) self.assertAlmostEqual(span.mssa_eof()[1,2,3,4], 0.0041007559488027926)