Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
18d2fafe
Commit
18d2fafe
authored
Apr 29, 2013
by
Marco Selig
Browse files
docu adjustments; changed to pre-release version 0.3.9; TODO: nifty reference.
parent
9ba55278
Changes
5
Hide whitespace changes
Inline
Side-by-side
demos/demo_excaliwir.py
View file @
18d2fafe
...
...
@@ -52,7 +52,7 @@ g = gl_space(48)
z
=
s_space
=
k
=
k_space
=
p
=
d_space
=
None
## power spectrum (and more)
power
=
powerindex
=
powerundex
=
kindex
=
rho
=
None
power
=
kindex
=
rho
=
powerindex
=
powerundex
=
None
## operators
S
=
Sk
=
R
=
N
=
Nj
=
D
=
None
...
...
@@ -111,7 +111,7 @@ def setup(space,s2n=3,nvar=None):
the noise variance, `nvar` will be calculated according to
`s2n` if not specified (default: None)
"""
global
z
,
s_space
,
k
,
k_space
,
p
,
d_space
,
power
,
powerindex
,
powerundex
,
kindex
,
rho
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
global
z
,
s_space
,
k
,
k_space
,
p
,
d_space
,
power
,
kindex
,
rho
,
powerindex
,
powerundex
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
## signal space
z
=
s_space
=
space
...
...
@@ -119,17 +119,15 @@ def setup(space,s2n=3,nvar=None):
## conjugate space
k
=
k_space
=
s_space
.
get_codomain
()
## the power indices are calculated once and saved
powerindex
=
k_space
.
get_power_index
()
powerundex
=
k_space
.
get_power_undex
()
kindex
,
rho
=
k_space
.
get_power_index
(
irreducible
=
True
)
kindex
,
rho
,
powerindex
,
powerundex
=
k_space
.
get_power_indices
()
## power spectrum
power
=
[
42
/
(
kk
+
1
)
**
3
for
kk
in
kindex
]
power
=
(
lambda
kk
:
42
/
(
kk
+
1
)
**
3
)
## prior signal covariance operator (power operator)
S
=
power_operator
(
k_space
,
spec
=
power
,
pindex
=
powerindex
)
S
=
power_operator
(
k_space
,
spec
=
power
)
## projection operator to the spectral bands
Sk
=
S
.
get_projection_operator
(
pindex
=
powerindex
)
Sk
=
S
.
get_projection_operator
()
## the Gaussian random field generated from its power operator S
s
=
S
.
get_random_field
(
domain
=
s_space
,
target
=
k_space
)
...
...
@@ -169,7 +167,7 @@ def run(space=r1,s2n=3,nvar=None,**kwargs):
the noise variance, `nvar` will be calculated according to
`s2n` if not specified (default: None)
"""
global
z
,
s_space
,
k
,
k
_space
,
p
,
d_space
,
power
,
powerindex
,
powerundex
,
kindex
,
rho
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
global
s_space
,
k_space
,
d_space
,
power
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
## setting up signal, noise, data and the operators S, N and R
setup
(
space
,
s2n
=
s2n
,
nvar
=
nvar
)
...
...
@@ -196,7 +194,7 @@ def run(space=r1,s2n=3,nvar=None,**kwargs):
m
.
plot
(
title
=
"reconstructed map"
,
vmin
=
np
.
min
(
s
.
val
),
vmax
=
np
.
max
(
s
.
val
),
**
kwargs
)
## power spectrum
# s.plot(title="power spectra",power=True,other=(m,power),mono=False
,kindex=kindex
)
# s.plot(title="power spectra",power=True,other=(m,power),mono=False)
## uncertainty
# uncertainty = D.hat(bare=True,nrun=D.domain.dim()//4,target=k_space)
...
...
@@ -234,7 +232,7 @@ def run_critical(space=r2,s2n=3,nvar=None,q=1E-12,alpha=1,perception=[1,0],**kwa
infer_power
"""
global
z
,
s_space
,
k
,
k
_space
,
p
,
d_space
,
power
,
powerindex
,
powerundex
,
kindex
,
rho
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
global
s_space
,
k_space
,
d_space
,
power
,
rho
,
S
,
Sk
,
R
,
N
,
Nj
,
D
,
s
,
n
,
d
,
j
,
m
## setting up signal, noise, data and the operators S, N and R
setup
(
space
,
s2n
=
s2n
,
nvar
=
nvar
)
...
...
@@ -245,7 +243,7 @@ def run_critical(space=r2,s2n=3,nvar=None,q=1E-12,alpha=1,perception=[1,0],**kwa
j
=
R
.
adjoint_times
(
N
.
inverse_times
(
d
))
## unknown power spectrum, the power operator is given an initial value
S
.
set_power
(
42
,
bare
=
True
,
pindex
=
powerindex
)
## The answer is 42. I double checked.
S
.
set_power
(
42
,
bare
=
True
)
## The answer is 42. I double checked.
## the power spectrum is drawn from the first guess power operator
pk
=
S
.
get_power
(
bare
=
False
)
## non-bare(!)
...
...
@@ -266,14 +264,14 @@ def run_critical(space=r2,s2n=3,nvar=None,q=1E-12,alpha=1,perception=[1,0],**kwa
b1
=
Sk
.
pseudo_tr
(
m
)
## == Sk(m).pseudo_dot(m), but faster
b2
=
Sk
.
pseudo_tr
(
D
,
nrun
=
np
.
sqrt
(
Sk
.
domain
.
dim
())
//
4
)
## probing of the partial traces of D
pk_new
=
(
2
*
q
+
b1
+
perception
[
0
]
*
b2
)
/
(
rho
+
2
*
(
alpha
-
1
+
perception
[
1
]))
## non-bare(!)
pk_new
=
smooth_power
(
pk_new
,
kindex
,
mode
=
"2s"
,
exclude
=
min
(
8
,
len
(
power
)))
## smoothing
pk_new
=
smooth_power
(
pk_new
,
domain
=
k_space
,
mode
=
"2s"
,
exclude
=
min
(
8
,
len
(
rho
)))
## smoothing
## the power operator is given the new spectrum
S
.
set_power
(
pk_new
,
bare
=
False
,
pindex
=
powerindex
)
## auto-updates D
S
.
set_power
(
pk_new
,
bare
=
False
)
## auto-updates D
## check convergence
log_change
=
np
.
max
(
np
.
abs
(
log
(
pk_new
/
pk
)))
if
(
log_change
<=
0.01
):
note
.
cprint
(
"NOTE: accuracy reached in iteration %u."
%
(
iteration
))
note
.
cprint
(
"NOTE:
desired
accuracy reached in iteration %u."
%
(
iteration
))
break
else
:
note
.
cprint
(
"NOTE: log-change == %4.3f ( > 1%% ) in iteration %u."
%
(
log_change
,
iteration
))
...
...
@@ -290,7 +288,7 @@ def run_critical(space=r2,s2n=3,nvar=None,q=1E-12,alpha=1,perception=[1,0],**kwa
m
.
plot
(
title
=
"reconstructed map"
,
vmin
=
np
.
min
(
s
.
val
),
vmax
=
np
.
max
(
s
.
val
),
**
kwargs
)
## power spectrum
s
.
plot
(
title
=
"power spectra"
,
power
=
True
,
other
=
(
S
.
get_power
(
pundex
=
powerundex
),
power
),
mono
=
False
,
kindex
=
kindex
)
s
.
plot
(
title
=
"power spectra"
,
power
=
True
,
other
=
(
S
.
get_power
(),
power
),
mono
=
False
)
## uncertainty
# uncertainty = D.hat(bare=True,nrun=D.domain.dim()//4,target=k_space)
...
...
demos/demo_faraday.py
View file @
18d2fafe
...
...
@@ -91,8 +91,7 @@ def run(projection=False, power=False):
m1
=
m0
.
transform
(
l
)
if
(
projection
):
## define projection operator
powerindex
=
l
.
get_power_index
()
Sk
=
projection_operator
(
l
,
assign
=
powerindex
)
Sk
=
projection_operator
(
l
)
## project quadrupole
m2
=
Sk
(
m0
,
band
=
2
)
...
...
@@ -116,7 +115,7 @@ def run(projection=False, power=False):
m3
.
plot
(
title
=
r
"$m$ on a spherical Gauss-Legendre grid"
,
vmin
=-
4
,
vmax
=
4
,
cmap
=
ncmap
.
fm
())
m4
.
plot
(
title
=
r
"$m$ on a regular 2D grid"
,
vmin
=-
4
,
vmax
=
4
,
cmap
=
ncmap
.
fm
())
if
(
power
):
m5
.
plot
(
title
=
r
"(restricted) Fourier power spectrum of $m$"
,
vmin
=
1E-3
,
vmax
=
1E+0
,
mono
=
False
)
m5
.
plot
(
title
=
r
"(restricted
, binned
) Fourier power spectrum of $m$"
,
vmin
=
1E-3
,
vmax
=
1E+0
,
mono
=
False
,
log
=
True
)
##=============================================================================
nifty_core.py
View file @
18d2fafe
...
...
@@ -483,7 +483,7 @@ class _about(object): ## nifty support class for global settings
"""
## version
self
.
_version
=
"0.3.
1"
self
.
_version
=
"0.3.
9"
## FIXME: release veriosn 0.4.0 << REFERENCE + README
## switches and notifications
self
.
_errors
=
notification
(
default
=
True
,
ccode
=
notification
.
_code
)
...
...
@@ -1071,7 +1071,7 @@ class space(object):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Provides the indexing array of the power spectrum.
**DEPRECATED**
Provides the indexing array of the power spectrum.
Provides either an array giving for each component of a field the
corresponding index of a power spectrum (if ``irreducible==False``)
...
...
@@ -1105,9 +1105,9 @@ class space(object):
about
.
warnings
.
cprint
(
"WARNING: 'get_power_index' is deprecated."
)
raise
NotImplementedError
(
about
.
_errors
.
cstring
(
"ERROR: no generic instance method 'get_power_index'."
))
def
get_power_undex
(
self
,
pindex
=
None
):
def
get_power_undex
(
self
,
pindex
=
None
):
## TODO: remove in future version
"""
Provides the unindexing list for an indexed power spectrum.
**DEPRECATED**
Provides the unindexing list for an indexed power spectrum.
Parameters
----------
...
...
@@ -1948,8 +1948,8 @@ class point_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Raises an error since the power spectrum is
ill-defined for point
spaces.
**DEPRECATED**
Raises an error since the power spectrum is
ill-defined for point
spaces.
"""
about
.
warnings
.
cprint
(
"WARNING: 'get_power_index' is deprecated."
)
raise
AttributeError
(
about
.
_errors
.
cstring
(
"ERROR: power spectra ill-defined for (unstructured) point spaces."
))
...
...
@@ -2454,7 +2454,7 @@ class rg_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Provides the indexing array of the power spectrum.
**DEPRECATED**
Provides the indexing array of the power spectrum.
Provides either an array giving for each component of a field the
corresponding index of a power spectrum (if ``irreducible==False``)
...
...
@@ -3542,7 +3542,7 @@ class lm_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Provides the indexing array of the power spectrum.
**DEPRECATED**
Provides the indexing array of the power spectrum.
Provides either an array giving for each component of a field the
corresponding index of a power spectrum (if ``irreducible==False``)
...
...
@@ -4367,7 +4367,7 @@ class gl_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Raises an error since the power spectrum for a field on the sphere
**DEPRECATED**
Raises an error since the power spectrum for a field on the sphere
is defined via the spherical harmonics components and not its
position-space representation.
"""
...
...
@@ -5000,7 +5000,7 @@ class hp_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Raises an error since the power spectrum for a field on the sphere
**DEPRECATED**
Raises an error since the power spectrum for a field on the sphere
is defined via the spherical harmonics components and not its
position-space representation.
"""
...
...
@@ -5528,8 +5528,8 @@ class nested_space(space):
def
get_power_index
(
self
,
irreducible
=
False
):
## TODO: remove in future version
"""
Raises an error since there is no canonical
definition for the
power spectrum on a generic product space.
**DEPRECATED**
Raises an error since there is no canonical
definition for the
power spectrum on a generic product space.
"""
about
.
warnings
.
cprint
(
"WARNING: 'get_power_index' is deprecated."
)
raise
AttributeError
(
about
.
_errors
.
cstring
(
"ERROR: power spectra indexing ill-defined."
))
...
...
nifty_power.py
View file @
18d2fafe
...
...
@@ -41,9 +41,9 @@
"""
from
__future__
import
division
from
scipy.interpolate
import
interp1d
as
ip
from
scipy.interpolate
import
interp1d
as
ip
##
#import numpy as np
from
nifty_core
import
*
from
nifty.
nifty_core
import
*
import
smoothing
as
gs
...
...
setup.py
View file @
18d2fafe
...
...
@@ -23,7 +23,7 @@ from distutils.core import setup
import
os
setup
(
name
=
"nifty"
,
version
=
"0.
3.1
"
,
version
=
"0.
4.0
"
,
description
=
"Numerical Information Field Theory"
,
author
=
"Marco Selig"
,
author_email
=
"mselig@mpa-garching.mpg.de"
,
...
...
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