Пример #1
0
 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))
Пример #2
0
 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))
Пример #3
0
 def test_pca_mssa_rec(self):
     data = setup_data2(nx=30, ny=20)
     span = Analyzer(data)
     rec = span.mssa_rec(nmssa=10)
     self.assertTrue(npy.allclose(
         rec[2,:2,:2].compressed(),
         npy.array([ 0.36712853,  0.28310489,  0.27881545])))
Пример #4
0
 def test_mssa_phases(self):
     nt = 100.
     nx = 5
     data = npy.cos(npy.linspace(0, 5*6.2, nt*nx)*npy.pi*2).reshape((nx, nt)).T
     data += npy.cos(npy.linspace(0, 5*3.4, nt*nx)*npy.pi*2).reshape((nx, nt)).T
     span = Analyzer(data)
     rec = span.mssa_rec(imodes=[-1], phases=8)
     self.assertTrue(npy.allclose(
         rec[:2,:2].ravel(),
         npy.array([ 0.5525298 ,  0.32848071,  0.15829024,  1.19338772])))
Пример #5
0
    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 ])))
Пример #6
0
 def test_ssa_rec(self):
     data = setup_data0()
     span = Analyzer(data)
     rec = span.mssa_rec(nmssa=6)
     self.assertTrue(npy.allclose(rec[:4],
         npy.array([  2.14699609,  1.3861899 ,  2.70336958,  0.70994501])))