def test_mssa_rec(self): data = setup_data2(nx=3, ny=2, xyfact=0) span = Analyzer(data) rec = span.mssa_rec(nmssa=20) print span.mssa_ev(cumsum=True, relative=True) # import pylab as P;P.subplot(211);P.pcolormesh(data.reshape(-1, 6));P.subplot(212);P.pcolormesh(rec.reshape(-1, 6));P.show() print rec[50].compressed() print data[50].compressed() print (rec-data).var()/data.var() self.assertTrue(npy.allclose( rec[50].compressed(), npy.array([0.30848007, 0.8622368, 0.96028445, 0.8236466, 0.56329503 ])))
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)