Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
xQML
xQML
Commits
44f09724
Commit
44f09724
authored
Jul 30, 2018
by
Julien
Browse files
Final PEP8 on simulation
parent
e81ad1d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
31 deletions
+39
-31
simulation.py
simulation.py
+39
-31
No files found.
simulation.py
View file @
44f09724
...
...
@@ -64,7 +64,7 @@ def getNl(pixvar, nside, 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):
??? : ???
???
"""
allStoke
=
[
'I'
,
'Q'
,
'U'
]
allStoke
=
[
'I'
,
'Q'
,
'U'
]
if
EBTB
:
der
=
[
'TT'
,
'EE'
,
'BB'
,
'TE'
,
'EB'
,
'TB'
]
ind
=
[
0
,
1
,
2
,
3
,
4
,
5
]
der
=
[
'TT'
,
'EE'
,
'BB'
,
'TE'
,
'EB'
,
'TB'
]
ind
=
[
0
,
1
,
2
,
3
,
4
,
5
]
else
:
der
=
[
'TT'
,
'EE'
,
'BB'
,
'TE'
]
ind
=
[
0
,
1
,
2
,
3
]
der
=
[
'TT'
,
'EE'
,
'BB'
,
'TE'
]
ind
=
[
0
,
1
,
2
,
3
]
if
not
temp
:
allStoke
=
[
'Q'
,
'U'
]
allStoke
=
[
'Q'
,
'U'
]
if
EBTB
:
der
=
[
'EE'
,
'BB'
,
'EB'
]
ind
=
[
1
,
2
,
4
]
der
=
[
'EE'
,
'BB'
,
'EB'
]
ind
=
[
1
,
2
,
4
]
else
:
der
=
[
'EE'
,
'BB'
]
ind
=
[
1
,
2
]
der
=
[
'EE'
,
'BB'
]
ind
=
[
1
,
2
]
if
not
polar
:
allStoke
=
[
'I'
]
der
=
[
'TT'
]
ind
=
[
0
]
allStoke
=
[
'I'
]
der
=
[
'TT'
]
ind
=
[
0
]
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 ell (total non-binned multipole range)
...
...
@@ -118,33 +120,36 @@ def GetBinningMatrix(ellbins, lmax, norm=False,polar=True,temp=False,EBTB=False,
???
"""
#### define Stokes
allStoke
,
der
,
ind
=
getstokes
(
polar
,
temp
,
EBTB
)
allStoke
,
der
,
ind
=
getstokes
(
polar
,
temp
,
EBTB
)
nder
=
len
(
der
)
nbins
=
len
(
ellbins
)
-
1
ellmin
=
np
.
array
(
ellbins
[
0
:
nbins
])
ellmax
=
np
.
array
(
ellbins
[
1
:
nbins
+
1
])
-
1
ell
=
np
.
arange
(
np
.
min
(
ellbins
),
lmax
+
2
)
maskl
=
(
ell
[:
-
1
]
<
(
lmax
+
2
))
&
(
ell
[:
-
1
]
>
1
)
nbins
=
len
(
ellbins
)
-
1
ellmin
=
np
.
array
(
ellbins
[
0
:
nbins
])
ellmax
=
np
.
array
(
ellbins
[
1
:
nbins
+
1
])
-
1
ell
=
np
.
arange
(
np
.
min
(
ellbins
),
lmax
+
2
)
maskl
=
(
ell
[:
-
1
]
<
(
lmax
+
2
))
&
(
ell
[:
-
1
]
>
1
)
minell
=
np
.
array
(
ellbins
[
0
:
nbins
])
# define min
maxell
=
np
.
array
(
ellbins
[
1
:
nbins
+
1
])
-
1
# and max of a bin
ellval
=
(
minell
+
maxell
)
*
0.5
# define min
minell
=
np
.
array
(
ellbins
[
0
:
nbins
])
# 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
):
masklm
.
append
(((
ell
[:
-
1
]
>=
minell
[
i
])
&
(
ell
[:
-
1
]
<=
maxell
[
i
])))
masklm
.
append
(((
ell
[:
-
1
]
>=
minell
[
i
])
&
(
ell
[:
-
1
]
<=
maxell
[
i
])))
allmasklm
=
nder
*
[
list
(
masklm
)]
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
P
=
np
.
array
(
masklM
)
*
1.
Q
=
P
.
T
P
=
P
/
np
.
sum
(
P
,
1
)[:,
None
]
P
=
P
/
np
.
sum
(
P
,
1
)[:,
None
]
if
norm
:
P
*=
binsnorm
P
*=
binsnorm
return
P
,
Q
,
ell
,
ellval
...
...
@@ -164,7 +169,9 @@ def GetCorr(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
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment