Installation
Using CAMEL
Tutorials
|
python howtosOn this page... (hide) 1. open a fits file and plot spectrum (loglog)from astropy.io import fits from matplotlib import pyplot as plt h= fits.open("output.fits") pkdata=h[3].data k=pkdata['k'] pk=pkdata['pklin'] plt.loglog(k,pk) 2. read a likehood file and plot the points with errorsThe file is in plain text, columns corresponds to "k_i, Pk_i, sig(Pk_i)" import numpy as np from matplotlib import pyplot as plt k,pk,sigpk=np.loadtxt("pk_0.5.dat",skiprows=1,unpack=True) plt.errorbar(k,pk,sigpk,fmt='.') 3. covariance and correlationWhen we have a set where
The correlation matrix is the covariance matrix divided by some diagonal elements.
where
By construction all the elements should lie in the range [-1,1]. This a convenient way to see how much pairs of variable are correlated: positive values= correlated, negative=anti-correlated, 0=uncorrelated. To code it we could use a double index loop, here is a more pythonic way: def cov2cor(c): d=diag(c) return c/sqrt(d[:,None]*d[None,:]) |