def test_pattern_correlation(self): """ test pattern correlation function """ x = self.D.copy() # correlation with random values y = self.D.copy() tmp = np.random.random(y.shape) y.data = np.ma.array(tmp, mask=tmp != tmp) P2 = PatternCorrelation(x, y) P2._correlate() self.assertEqual(x.nt,len(P2.r_value)) self.assertEqual(x.nt,len(P2.t)) for i in xrange(x.nt): slope, intercept, r_value, p_value, std_err = stats.mstats.linregress(x.data[i,:,:].flatten(),y.data[i,:,:].flatten()) self.assertEqual(P2.r_value[i], r_value) self.assertEqual(P2.p_value[i], p_value) self.assertEqual(P2.slope[i], slope) self.assertEqual(P2.intercept[i], intercept) self.assertEqual(P2.std_err[i], std_err)
def test_pattern_correlation(self): """ test pattern correlation function """ x = self.D.copy() # correlation with random values y = self.D.copy() tmp = np.random.random(y.shape) y.data = np.ma.array(tmp, mask=tmp != tmp) P2 = PatternCorrelation(x, y) P2._correlate() self.assertEqual(x.nt, len(P2.r_value)) self.assertEqual(x.nt, len(P2.t)) for i in xrange(x.nt): slope, intercept, r_value, p_value, std_err = stats.mstats.linregress( x.data[i, :, :].flatten(), y.data[i, :, :].flatten()) self.assertEqual(P2.r_value[i], r_value) self.assertEqual(P2.p_value[i], p_value) self.assertEqual(P2.slope[i], slope) self.assertEqual(P2.intercept[i], intercept) self.assertEqual(P2.std_err[i], std_err)
# -*- coding: utf-8 -*- """ This file is part of pyCMBS. (c) 2012- Alexander Loew For COPYING and LICENSE details, please refer to the LICENSE file """ from pycmbs.data import Data from pycmbs.diagnostic import PatternCorrelation import matplotlib.pyplot as plt import numpy as np file_name = '../../../pycmbs/examples/example_data/air.mon.mean.nc' A = Data(file_name, 'air', lat_name='lat', lon_name='lon', read=True, label='air temperature') B = A.copy() B.mulc(2.3, copy=False) B.data = B.data + np.random.random(B.shape) * 100. # calculate spatial correlation for all timesteps ... P = PatternCorrelation(A, B) # ... and vizalize it P.plot() plt.show()
""" This file is part of pyCMBS. (c) 2012- Alexander Loew For COPYING and LICENSE details, please refer to the LICENSE file """ """ development script for pattern correlation analysis """ from pycmbs.diagnostic import PatternCorrelation from pycmbs.data import Data import numpy as np import matplotlib.pyplot as plt plt.close('all') fname = '../pycmbs/examples/example_data/air.mon.mean.nc' # generate two datasets x = Data(fname, 'air', read=True) xc = x.get_climatology(return_object=True) yc = xc.copy() yc.data = yc.data * np.random.random(yc.shape)*10. PC = PatternCorrelation(xc, yc) PC.plot() plt.show()
# -*- coding: utf-8 -*- from pycmbs.data import Data from pycmbs.diagnostic import PatternCorrelation import matplotlib.pyplot as plt import numpy as np file_name = '../../../pycmbs/examples/example_data/air.mon.mean.nc' A = Data(file_name, 'air', lat_name='lat', lon_name='lon', read=True, label='air temperature') B = A.copy() B.mulc(2.3, copy=False) B.data = B.data + np.random.random(B.shape)*100. # calculate spatial correlation for all timesteps ... P = PatternCorrelation(A,B) # ... and vizalize it P.plot() plt.show()
""" This file is part of pyCMBS. (c) 2012- Alexander Loew For COPYING and LICENSE details, please refer to the LICENSE file """ """ development script for pattern correlation analysis """ from pycmbs.diagnostic import PatternCorrelation from pycmbs.data import Data import numpy as np import matplotlib.pyplot as plt plt.close('all') fname = '../pycmbs/examples/example_data/air.mon.mean.nc' # generate two datasets x = Data(fname, 'air', read=True) xc = x.get_climatology(return_object=True) yc = xc.copy() yc.data = yc.data * np.random.random(yc.shape) * 10. PC = PatternCorrelation(xc, yc) PC.plot() plt.show()