示例#1
0
 def test_pca_xrec(self):
     var = setup_data1()
     A = Analyzer(var)
     rec = A.pca_rec()
     xeof = A.pca_eof()
     xpc = A.pca_pc()
     xrec = A.pca_rec(xeof=xeof, xpc=xpc)
     self.assertTrue(npy.allclose(rec, xrec))
示例#2
0
    def test_pca_rec(self):
        """Test a PCA analysis and reconstruction with a gap inside"""
        # Init
        data = gensin2d(xnper=5, xper=30, ynper=5, yper=20)
        data[0:30, 0:55] = npy.ma.masked

        # Fill
        A = Analyzer(data, npca=10)
        rec = A.pca_rec()

        # Check
#        import pylab as P
#        P.subplot(211)
#        P.pcolor(data, vmin=data.min(), vmax=data.max())
#        P.subplot(212)
#        P.pcolor(rec, vmin=data.min(), vmax=data.max())
#        P.show()
        self.assertAlmostEqual(((data-rec)**2).sum()/(data**2).sum()*100,
            0.064630381956367611)
示例#3
0
 def test_pca_rec(self):
     A = Analyzer(setup_data1())
     rec1 = A.pca_rec()
     self.assertAlmostEqual(rec1.sum(), 18464.31988812385)