Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate and show the covariance matrix for template noise.
from numpy import *
from pylab import *
from glob import glob
from scipy.stats import nanmean
NN = '088' # change this
fileglob = 'Residuals_NN' + NN + '_Index*'
print 'Using', fileglob, '\n'
filenames = glob(fileglob)
filenames.sort()
arr = []
for f in filenames:
a = loadtxt(f, unpack=True)
#print nanmean(a)
a = a - nanmean(a)
arr.append(a)
print len(arr), '"realizations" of', shape(arr)[1], 'variables\n'
nr = len(arr)
nv = shape(arr)[1]
arr_wn = nan_to_num(arr) # replace nan with 0 (should we do this?)
R = corrcoef(arr_wn)
pcolor(R)
cb = colorbar()
yticks(arange(0.5,nr+0.5),range(1,nr+1))
xticks(arange(0.5,nr+0.5),range(1,nr+1))
xlim([0,nr])
ylim([0,nr])
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.