Commit 44f09724 authored by Julien's avatar Julien
Browse files

Final PEP8 on simulation

parent e81ad1d7
...@@ -64,7 +64,7 @@ def getNl(pixvar, nside, nbins): ...@@ -64,7 +64,7 @@ def getNl(pixvar, nside, nbins):
return pixvar*4.*np.pi/(12*nside**2.)*np.ones((nbins)) return pixvar*4.*np.pi/(12*nside**2.)*np.ones((nbins))
def getstokes(polar=True,temp=False,EBTB=False): def getstokes(polar=True, temp=False, EBTB=False):
""" """
??? ???
...@@ -79,28 +79,30 @@ def getstokes(polar=True,temp=False,EBTB=False): ...@@ -79,28 +79,30 @@ def getstokes(polar=True,temp=False,EBTB=False):
??? : ??? ??? : ???
??? ???
""" """
allStoke=['I','Q','U'] allStoke = ['I', 'Q', 'U']
if EBTB: if EBTB:
der=['TT','EE','BB','TE','EB','TB'] der = ['TT', 'EE', 'BB', 'TE', 'EB', 'TB']
ind=[0,1,2,3,4,5] ind = [0, 1, 2, 3, 4, 5]
else: else:
der=['TT','EE','BB','TE'] der = ['TT', 'EE', 'BB', 'TE']
ind=[0,1,2,3] ind = [0, 1, 2, 3]
if not temp: if not temp:
allStoke=['Q','U'] allStoke = ['Q', 'U']
if EBTB: if EBTB:
der=['EE','BB','EB'] der = ['EE', 'BB', 'EB']
ind=[1,2,4] ind = [1, 2, 4]
else: else:
der=['EE','BB'] der = ['EE', 'BB']
ind=[1,2] ind = [1, 2]
if not polar: if not polar:
allStoke=['I'] allStoke = ['I']
der=['TT'] der = ['TT']
ind=[0] ind = [0]
return allStoke, der, ind return allStoke, der, ind
def GetBinningMatrix(ellbins, lmax, norm=False,polar=True,temp=False,EBTB=False, verbose=False): def GetBinningMatrix(
ellbins, lmax, norm=False, polar=True,
temp=False, EBTB=False, verbose=False):
""" """
Return P and Q matrices such taht Cb = P.Cl and Vbb = P.Vll.Q Return P and Q matrices such taht Cb = P.Cl and Vbb = P.Vll.Q
Return ell (total non-binned multipole range) Return ell (total non-binned multipole range)
...@@ -118,33 +120,36 @@ def GetBinningMatrix(ellbins, lmax, norm=False,polar=True,temp=False,EBTB=False, ...@@ -118,33 +120,36 @@ def GetBinningMatrix(ellbins, lmax, norm=False,polar=True,temp=False,EBTB=False,
??? ???
""" """
#### define Stokes #### define Stokes
allStoke, der, ind = getstokes(polar,temp,EBTB) allStoke, der, ind = getstokes(polar, temp, EBTB)
nder = len(der) nder = len(der)
nbins=len(ellbins)-1 nbins = len(ellbins) - 1
ellmin=np.array(ellbins[0:nbins]) ellmin = np.array(ellbins[0: nbins])
ellmax=np.array(ellbins[1:nbins+1])-1 ellmax = np.array(ellbins[1: nbins + 1]) - 1
ell=np.arange(np.min(ellbins),lmax+2) ell = np.arange(np.min(ellbins), lmax + 2)
maskl=(ell[:-1]<(lmax+2)) & (ell[:-1]>1) maskl = (ell[:-1] < (lmax + 2)) & (ell[:-1] > 1)
minell=np.array(ellbins[0:nbins]) # define min # define min
maxell=np.array(ellbins[1:nbins+1])-1 # and max of a bin minell = np.array(ellbins[0: nbins])
ellval=(minell+maxell)*0.5 # and max of a bin
maxell = np.array(ellbins[1: nbins + 1]) - 1
ellval = (minell + maxell) * 0.5
masklm=[] masklm = []
for i in np.arange(nbins): for i in np.arange(nbins):
masklm.append(((ell[:-1]>=minell[i]) & (ell[:-1]<=maxell[i]))) masklm.append(((ell[:-1] >= minell[i]) & (ell[:-1] <= maxell[i])))
allmasklm = nder*[list(masklm)] allmasklm = nder*[list(masklm)]
masklM = np.array(sparse.block_diag(allmasklm[:]).toarray()) masklM = np.array(sparse.block_diag(allmasklm[:]).toarray())
binsnorm = np.array(nder*[list(np.arange(minell[0],np.max(ellbins)))]).flatten() binsnorm = np.array(
nder * [list(np.arange(minell[0], np.max(ellbins)))]).flatten()
binsnorm = binsnorm*(binsnorm+1)/2./np.pi binsnorm = binsnorm*(binsnorm+1)/2./np.pi
P = np.array(masklM)*1. P = np.array(masklM)*1.
Q = P.T Q = P.T
P=P/np.sum(P,1)[:,None] P = P / np.sum(P, 1)[:, None]
if norm: if norm:
P*=binsnorm P *= binsnorm
return P, Q, ell, ellval return P, Q, ell, ellval
...@@ -164,7 +169,9 @@ def GetCorr(F): ...@@ -164,7 +169,9 @@ def GetCorr(F):
??? ???
""" """
nbins = len(F) nbins = len(F)
Corr = np.array([F[i,j]/(F[i,i]*F[j,j])**.5 for i in np.arange(nbins) for j in np.arange(nbins)]).reshape(nbins, nbins) Corr = np.array(
[F[i, j] / (F[i, i]*F[j, j])**.5 for i in np.arange(nbins)
for j in np.arange(nbins)]).reshape(nbins, nbins)
return Corr return Corr
def IsInvertible(F): def IsInvertible(F):
...@@ -182,5 +189,6 @@ def IsInvertible(F): ...@@ -182,5 +189,6 @@ def IsInvertible(F):
??? : ??? ??? : ???
??? ???
""" """
print("Cond Numb = ", np.linalg.cond(F), "Matrix eps=", np.finfo(F.dtype).eps) eps = np.finfo(F.dtype).eps
print("Cond Numb = ", np.linalg.cond(F), "Matrix eps=", eps)
return np.linalg.cond(F) > np.finfo(F.dtype).eps return np.linalg.cond(F) > np.finfo(F.dtype).eps
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment