Skip to content
GitLab
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
e954b8bf
Commit
e954b8bf
authored
Feb 14, 2018
by
Martin Reinecke
Browse files
renamings
parent
7f0d49de
Pipeline
#24889
failed with stage
in 60 minutes and 4 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/nonlinear_critical_filter.py
View file @
e954b8bf
...
...
@@ -59,9 +59,8 @@ if __name__ == "__main__":
d_space
=
MeasurementOperator
.
target
Projection
=
ift
.
PowerProjectionOperator
(
domain
=
h_space
,
power_space
=
p_space
)
power
=
Projection
.
adjoint_times
(
ift
.
exp
(
0.5
*
log_p
))
Distributor
=
ift
.
PowerDistributor
(
target
=
h_space
,
power_space
=
p_space
)
power
=
Distributor
(
ift
.
exp
(
0.5
*
log_p
))
# Creating the mock data
true_sky
=
nonlinearity
(
HT
(
power
*
sh
))
noiseless_data
=
MeasurementOperator
(
true_sky
)
...
...
@@ -75,7 +74,7 @@ if __name__ == "__main__":
m0
=
ift
.
power_synthesize
(
ift
.
Field
(
p_space
,
val
=
1e-7
))
t0
=
ift
.
Field
(
p_space
,
val
=-
4.
)
power0
=
Projection
.
adjoint_
times
(
ift
.
exp
(
0.5
*
t0
))
power0
=
Distributor
.
times
(
ift
.
exp
(
0.5
*
t0
))
IC1
=
ift
.
GradientNormController
(
name
=
"IC1"
,
iteration_limit
=
100
,
tol_abs_gradnorm
=
1e-3
)
...
...
@@ -87,7 +86,7 @@ if __name__ == "__main__":
inverter
=
ift
.
ConjugateGradient
(
controller
=
ICI
)
for
i
in
range
(
20
):
power0
=
Projection
.
adjoint_times
(
ift
.
exp
(
0.5
*
t0
))
power0
=
Distributor
(
ift
.
exp
(
0.5
*
t0
))
map0_energy
=
ift
.
library
.
NonlinearWienerFilterEnergy
(
m0
,
d
,
MeasurementOperator
,
nonlinearity
,
HT
,
power0
,
N
,
S
,
inverter
=
inverter
)
...
...
@@ -103,7 +102,7 @@ if __name__ == "__main__":
power0_energy
=
ift
.
library
.
NonlinearPowerEnergy
(
position
=
t0
,
d
=
d
,
N
=
N
,
xi
=
m0
,
D
=
D0
,
ht
=
HT
,
Instrument
=
MeasurementOperator
,
nonlinearity
=
nonlinearity
,
Projection
=
Projection
,
sigma
=
1.
,
samples
=
2
,
inverter
=
inverter
)
Distributor
=
Distributor
,
sigma
=
1.
,
samples
=
2
,
inverter
=
inverter
)
power0_energy
=
minimizer
(
power0_energy
)[
0
]
...
...
demos/wiener_filter_via_hamiltonian.py
View file @
e954b8bf
...
...
@@ -70,7 +70,8 @@ if __name__ == "__main__":
# Generate plots
zmax
=
max
(
ht
(
sh
).
max
(),
ht
(
m
).
max
())
zmin
=
min
(
ht
(
sh
).
min
(),
ht
(
m
).
min
())
plotdict
=
{
"zmax"
:
zmax
,
"zmin"
:
zmin
,
"colormap"
:
"Planck-like"
}
plotdict
=
{
"zmax"
:
zmax
,
"zmin"
:
zmin
,
"colormap"
:
"Planck-like"
}
plotdict2
=
{
"colormap"
:
"Planck-like"
}
ift
.
plot
(
ht
(
sh
),
name
=
"mock_signal.png"
,
**
plotdict
)
ift
.
plot
(
ht
(
m
),
name
=
"reconstruction.png"
,
**
plotdict
)
...
...
@@ -79,10 +80,10 @@ if __name__ == "__main__":
sample_mean
=
ift
.
Field
.
zeros
(
s_space
)
mean
,
variance
=
ift
.
probe_with_posterior_samples
(
curv
,
ht
,
50
)
ift
.
plot
(
variance
,
name
=
"posterior_variance.png"
,
**
plotdict
)
ift
.
plot
(
variance
,
name
=
"posterior_variance.png"
,
**
plotdict
2
)
ift
.
plot
(
mean
+
ht
(
m
),
name
=
"posterior_mean.png"
,
**
plotdict
)
# try to do the same with diagonal probing
variance
=
ift
.
probe_diagonal
(
ht
*
curv
.
inverse
*
ht
.
adjoint
,
100
)
#sm = ift.FFTSmoothingOperator(s_space, sigma=0.0
1
5)
ift
.
plot
(
variance
,
name
=
"posterior_variance2.png"
,
**
plotdict
)
#sm = ift.FFTSmoothingOperator(s_space, sigma=0.0
0
5)
ift
.
plot
(
variance
,
name
=
"posterior_variance2.png"
,
**
plotdict
2
)
docs/source/concepts/operators.rst
View file @
e954b8bf
...
...
@@ -12,7 +12,7 @@ Description of Operators
ScalingOperator <../mod/nifty4.operators.scaling_operator>
DiagonalOperator <../mod/nifty4.operators.diagonal_operator>
HarmonicTransformOperator <../mod/nifty4.operators.harmonic_transform_operator>
Power
ProjectionOperator
<../mod/nifty4.operators.power_
projection_opera
tor>
Power
Distributor
<../mod/nifty4.operators.power_
distribu
tor>
.. toctree::
:maxdepth: 1
...
...
@@ -26,7 +26,7 @@ Description of Operators
.. Adjoint <../mod/nifty4.operators.adjoint_operator>
.. Chain <../mod/nifty4.operators.chain_operator>
.. DOF
Projection
<../mod/nifty4.operators.dof_
projection_opera
tor>
.. DOF
Distributor
<../mod/nifty4.operators.dof_
distribu
tor>
.. Inverse <../mod/nifty4.operators.inverse_operator>
.. Laplace <../mod/nifty4.operators.linear_operator>
.. Sum <../mod/nifty4.operators.sum_operator>
nifty4/library/critical_power_energy.py
View file @
e954b8bf
...
...
@@ -18,7 +18,7 @@
from
..minimization.energy
import
Energy
from
..operators.smoothness_operator
import
SmoothnessOperator
from
..operators.power_
projection_opera
tor
import
Power
ProjectionOpera
tor
from
..operators.power_
distribu
tor
import
Power
Distribu
tor
from
.critical_power_curvature
import
CriticalPowerCurvature
from
..utilities
import
memo
from
..
import
Field
,
exp
...
...
@@ -86,17 +86,17 @@ class CriticalPowerEnergy(Energy):
self
.
_inverter
=
inverter
if
w
is
None
:
P
=
Power
ProjectionOperator
(
domain
=
self
.
m
.
domain
,
power_space
=
self
.
position
.
domain
[
0
])
Dist
=
Power
Distributor
(
target
=
self
.
m
.
domain
,
power_space
=
self
.
position
.
domain
[
0
])
if
self
.
D
is
not
None
:
w
=
Field
.
zeros
(
self
.
position
.
domain
,
dtype
=
self
.
m
.
dtype
)
for
i
in
range
(
self
.
samples
):
sample
=
self
.
D
.
draw_sample
()
+
self
.
m
w
+=
P
(
abs
(
sample
)
**
2
)
w
+=
Dist
.
adjoint_times
(
abs
(
sample
)
**
2
)
w
*=
1.
/
self
.
samples
else
:
w
=
P
(
abs
(
self
.
m
)
**
2
)
w
=
Dist
.
adjoint_times
(
abs
(
self
.
m
)
**
2
)
self
.
_w
=
w
self
.
_theta
=
exp
(
-
self
.
position
)
*
(
self
.
q
+
self
.
_w
*
0.5
)
...
...
nifty4/library/noise_energy.py
View file @
e954b8bf
...
...
@@ -25,7 +25,7 @@ from ..minimization.energy import Energy
class
NoiseEnergy
(
Energy
):
def
__init__
(
self
,
position
,
d
,
xi
,
D
,
t
,
ht
,
Instrument
,
nonlinearity
,
alpha
,
q
,
Projec
tion
,
samples
=
3
,
nonlinearity
,
alpha
,
q
,
Distribu
tion
,
samples
=
3
,
xi_sample_list
=
None
,
inverter
=
None
):
super
(
NoiseEnergy
,
self
).
__init__
(
position
=
position
)
self
.
xi
=
xi
...
...
@@ -40,8 +40,8 @@ class NoiseEnergy(Energy):
self
.
alpha
=
alpha
self
.
q
=
q
self
.
Projection
=
Projec
tion
self
.
power
=
self
.
Projection
.
adjoint_times
(
exp
(
0.5
*
self
.
t
))
self
.
Distribution
=
Distribu
tion
self
.
power
=
self
.
Distribution
(
exp
(
0.5
*
self
.
t
))
if
xi_sample_list
is
None
:
if
samples
is
None
or
samples
==
0
:
xi_sample_list
=
[
xi
]
...
...
@@ -51,7 +51,7 @@ class NoiseEnergy(Energy):
self
.
xi_sample_list
=
xi_sample_list
self
.
inverter
=
inverter
A
=
Projection
.
adjoint_times
(
exp
(.
5
*
self
.
t
))
A
=
Distribution
(
exp
(.
5
*
self
.
t
))
self
.
_gradient
=
None
for
sample
in
self
.
xi_sample_list
:
...
...
@@ -81,7 +81,7 @@ class NoiseEnergy(Energy):
return
self
.
__class__
(
position
,
self
.
d
,
self
.
xi
,
self
.
D
,
self
.
t
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
alpha
,
self
.
q
,
self
.
Projec
tion
,
xi_sample_list
=
self
.
xi_sample_list
,
self
.
Distribu
tion
,
xi_sample_list
=
self
.
xi_sample_list
,
samples
=
self
.
samples
,
inverter
=
self
.
inverter
)
@
property
...
...
nifty4/library/nonlinear_power_energy.py
View file @
e954b8bf
...
...
@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy):
"""
def
__init__
(
self
,
position
,
d
,
N
,
xi
,
D
,
ht
,
Instrument
,
nonlinearity
,
Projec
tion
,
sigma
=
0.
,
samples
=
3
,
xi_sample_list
=
None
,
Distribu
tion
,
sigma
=
0.
,
samples
=
3
,
xi_sample_list
=
None
,
inverter
=
None
):
super
(
NonlinearPowerEnergy
,
self
).
__init__
(
position
)
self
.
xi
=
xi
...
...
@@ -64,7 +64,7 @@ class NonlinearPowerEnergy(Energy):
self
.
ht
=
ht
self
.
Instrument
=
Instrument
self
.
nonlinearity
=
nonlinearity
self
.
Projection
=
Projec
tion
self
.
Distribution
=
Distribu
tion
self
.
sigma
=
sigma
if
xi_sample_list
is
None
:
if
samples
is
None
or
samples
==
0
:
...
...
@@ -75,7 +75,7 @@ class NonlinearPowerEnergy(Energy):
self
.
xi_sample_list
=
xi_sample_list
self
.
inverter
=
inverter
A
=
Projection
.
adjoint_times
(
exp
(.
5
*
position
))
A
=
Distribution
(
exp
(.
5
*
position
))
map_s
=
self
.
ht
(
A
*
xi
)
Tpos
=
self
.
T
(
position
)
...
...
@@ -83,7 +83,7 @@ class NonlinearPowerEnergy(Energy):
for
xi_sample
in
self
.
xi_sample_list
:
map_s
=
self
.
ht
(
A
*
xi_sample
)
LinR
=
LinearizedPowerResponse
(
self
.
Instrument
,
self
.
nonlinearity
,
self
.
ht
,
self
.
Projec
tion
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
ht
,
self
.
Distribu
tion
,
self
.
position
,
xi_sample
)
residual
=
self
.
d
-
\
...
...
@@ -106,7 +106,7 @@ class NonlinearPowerEnergy(Energy):
def
at
(
self
,
position
):
return
self
.
__class__
(
position
,
self
.
d
,
self
.
N
,
self
.
xi
,
self
.
D
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
Projec
tion
,
sigma
=
self
.
sigma
,
self
.
Distribu
tion
,
sigma
=
self
.
sigma
,
samples
=
len
(
self
.
xi_sample_list
),
xi_sample_list
=
self
.
xi_sample_list
,
inverter
=
self
.
inverter
)
...
...
@@ -124,5 +124,5 @@ class NonlinearPowerEnergy(Energy):
def
curvature
(
self
):
return
NonlinearPowerCurvature
(
self
.
position
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
Projec
tion
,
self
.
N
,
self
.
T
,
self
.
xi_sample_list
,
self
.
Distribu
tion
,
self
.
N
,
self
.
T
,
self
.
xi_sample_list
,
self
.
inverter
)
nifty4/library/response_operators.py
View file @
e954b8bf
...
...
@@ -23,8 +23,9 @@ def LinearizedSignalResponse(Instrument, nonlinearity, ht, power, m):
return
Instrument
*
nonlinearity
.
derivative
(
m
)
*
ht
*
power
def
LinearizedPowerResponse
(
Instrument
,
nonlinearity
,
ht
,
Projection
,
tau
,
xi
):
def
LinearizedPowerResponse
(
Instrument
,
nonlinearity
,
ht
,
Distribution
,
tau
,
xi
):
power
=
exp
(
0.5
*
tau
)
position
=
ht
(
Projection
.
adjoint_times
(
power
)
*
xi
)
position
=
ht
(
Distribution
(
power
)
*
xi
)
linearization
=
nonlinearity
.
derivative
(
position
)
return
0.5
*
Instrument
*
linearization
*
ht
*
xi
*
Projection
.
adjoint
*
power
return
0.5
*
Instrument
*
linearization
*
ht
*
xi
*
Distribution
*
power
nifty4/operators/__init__.py
View file @
e954b8bf
...
...
@@ -7,10 +7,10 @@ from .fft_operator import FFTOperator
from
.fft_smoothing_operator
import
FFTSmoothingOperator
from
.geometry_remover
import
GeometryRemover
from
.laplace_operator
import
LaplaceOperator
from
.power_
projection_opera
tor
import
Power
ProjectionOpera
tor
from
.power_
distribu
tor
import
Power
Distribu
tor
from
.inversion_enabler
import
InversionEnabler
__all__
=
[
"LinearOperator"
,
"EndomorphicOperator"
,
"ScalingOperator"
,
"DiagonalOperator"
,
"HarmonicTransformOperator"
,
"FFTOperator"
,
"FFTSmoothingOperator"
,
"GeometryRemover"
,
"LaplaceOperator"
,
"Power
ProjectionOpera
tor"
,
"InversionEnabler"
]
"LaplaceOperator"
,
"Power
Distribu
tor"
,
"InversionEnabler"
]
nifty4/operators/dof_
projection_opera
tor.py
→
nifty4/operators/dof_
distribu
tor.py
View file @
e954b8bf
...
...
@@ -25,15 +25,15 @@ from .. import dobj
from
..domains.dof_space
import
DOFSpace
class
DOF
ProjectionOpera
tor
(
LinearOperator
):
def
__init__
(
self
,
dofdex
,
domain
=
None
,
space
=
None
):
super
(
DOF
ProjectionOpera
tor
,
self
).
__init__
()
class
DOF
Distribu
tor
(
LinearOperator
):
def
__init__
(
self
,
dofdex
,
target
=
None
,
space
=
None
):
super
(
DOF
Distribu
tor
,
self
).
__init__
()
if
domain
is
None
:
domain
=
dofdex
.
domain
self
.
_
domain
=
DomainTuple
.
make
(
domain
)
space
=
infer_space
(
self
.
_
domain
,
space
)
partner
=
self
.
_
domain
[
space
]
if
target
is
None
:
target
=
dofdex
.
domain
self
.
_
target
=
DomainTuple
.
make
(
target
)
space
=
infer_space
(
self
.
_
target
,
space
)
partner
=
self
.
_
target
[
space
]
if
not
isinstance
(
dofdex
,
Field
):
raise
TypeError
(
"dofdex must be a Field"
)
if
not
len
(
dofdex
.
domain
)
==
1
:
...
...
@@ -64,41 +64,41 @@ class DOFProjectionOperator(LinearOperator):
def
_init2
(
self
,
dofdex
,
space
,
other_space
):
self
.
_space
=
space
tgt
=
list
(
self
.
_
domain
)
tgt
[
self
.
_space
]
=
other_space
self
.
_
target
=
DomainTuple
.
make
(
tgt
)
dom
=
list
(
self
.
_
target
)
dom
[
self
.
_space
]
=
other_space
self
.
_
domain
=
DomainTuple
.
make
(
dom
)
if
dobj
.
default_distaxis
()
in
self
.
_domain
.
axes
[
self
.
_space
]:
dofdex
=
dobj
.
local_data
(
dofdex
)
else
:
# dofdex must be available fully on every task
dofdex
=
dobj
.
to_global_data
(
dofdex
)
self
.
_dofdex
=
dofdex
.
ravel
()
firstaxis
=
self
.
_
domain
.
axes
[
self
.
_space
][
0
]
lastaxis
=
self
.
_
domain
.
axes
[
self
.
_space
][
-
1
]
arrshape
=
dobj
.
local_shape
(
self
.
_
domain
.
shape
,
0
)
firstaxis
=
self
.
_
target
.
axes
[
self
.
_space
][
0
]
lastaxis
=
self
.
_
target
.
axes
[
self
.
_space
][
-
1
]
arrshape
=
dobj
.
local_shape
(
self
.
_
target
.
shape
,
0
)
presize
=
np
.
prod
(
arrshape
[
0
:
firstaxis
],
dtype
=
np
.
int
)
postsize
=
np
.
prod
(
arrshape
[
lastaxis
+
1
:],
dtype
=
np
.
int
)
self
.
_hshape
=
(
presize
,
self
.
_
target
[
self
.
_space
].
shape
[
0
],
postsize
)
self
.
_hshape
=
(
presize
,
self
.
_
domain
[
self
.
_space
].
shape
[
0
],
postsize
)
self
.
_pshape
=
(
presize
,
self
.
_dofdex
.
size
,
postsize
)
def
_times
(
self
,
x
):
def
_adjoint
_times
(
self
,
x
):
arr
=
dobj
.
local_data
(
x
.
val
)
arr
=
arr
.
reshape
(
self
.
_pshape
)
oarr
=
np
.
zeros
(
self
.
_hshape
,
dtype
=
x
.
dtype
)
np
.
add
.
at
(
oarr
,
(
slice
(
None
),
self
.
_dofdex
,
slice
(
None
)),
arr
)
if
dobj
.
distaxis
(
x
.
val
)
in
x
.
domain
.
axes
[
self
.
_space
]:
oarr
=
dobj
.
np_allreduce_sum
(
oarr
).
reshape
(
self
.
_
target
.
shape
)
res
=
Field
(
self
.
_
target
,
dobj
.
from_global_data
(
oarr
))
oarr
=
dobj
.
np_allreduce_sum
(
oarr
).
reshape
(
self
.
_
domain
.
shape
)
res
=
Field
(
self
.
_
domain
,
dobj
.
from_global_data
(
oarr
))
else
:
oarr
=
oarr
.
reshape
(
dobj
.
local_shape
(
self
.
_
target
.
shape
,
oarr
=
oarr
.
reshape
(
dobj
.
local_shape
(
self
.
_
domain
.
shape
,
dobj
.
distaxis
(
x
.
val
)))
res
=
Field
(
self
.
_
target
,
dobj
.
from_local_data
(
self
.
_
target
.
shape
,
oarr
,
res
=
Field
(
self
.
_
domain
,
dobj
.
from_local_data
(
self
.
_
domain
.
shape
,
oarr
,
dobj
.
default_distaxis
()))
return
res
def
_adjoint
_times
(
self
,
x
):
res
=
Field
.
empty
(
self
.
_
domain
,
dtype
=
x
.
dtype
)
def
_times
(
self
,
x
):
res
=
Field
.
empty
(
self
.
_
target
,
dtype
=
x
.
dtype
)
if
dobj
.
distaxis
(
x
.
val
)
in
x
.
domain
.
axes
[
self
.
_space
]:
arr
=
dobj
.
to_global_data
(
x
.
val
)
else
:
...
...
nifty4/operators/power_
projection_opera
tor.py
→
nifty4/operators/power_
distribu
tor.py
View file @
e954b8bf
...
...
@@ -16,20 +16,20 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
.dof_
projection_operator
import
DOFProjectionOpera
tor
from
.dof_
distributor
import
DOFDistribu
tor
from
..domain_tuple
import
DomainTuple
from
..utilities
import
infer_space
from
..domains.power_space
import
PowerSpace
class
Power
ProjectionOperator
(
DOFProjectionOpera
tor
):
def
__init__
(
self
,
domain
,
power_space
=
None
,
space
=
None
):
class
Power
Distributor
(
DOFDistribu
tor
):
def
__init__
(
self
,
target
,
power_space
=
None
,
space
=
None
):
# Initialize domain and target
self
.
_
domain
=
DomainTuple
.
make
(
domain
)
self
.
_space
=
infer_space
(
self
.
_
domain
,
space
)
hspace
=
self
.
_
domain
[
self
.
_space
]
self
.
_
target
=
DomainTuple
.
make
(
target
)
self
.
_space
=
infer_space
(
self
.
_
target
,
space
)
hspace
=
self
.
_
target
[
self
.
_space
]
if
not
hspace
.
harmonic
:
raise
ValueError
(
"Operator
acts on
harmonic
spaces only
"
)
raise
ValueError
(
"Operator
requires
harmonic
target space
"
)
if
power_space
is
None
:
power_space
=
PowerSpace
(
hspace
)
else
:
...
...
nifty4/sugar.py
View file @
e954b8bf
...
...
@@ -21,7 +21,7 @@ from .domains.structured_domain import StructuredDomain
from
.domains.power_space
import
PowerSpace
from
.field
import
Field
,
sqrt
from
.operators.diagonal_operator
import
DiagonalOperator
from
.operators.power_
projection_opera
tor
import
Power
ProjectionOpera
tor
from
.operators.power_
distribu
tor
import
Power
Distribu
tor
from
.operators.harmonic_transform_operator
import
HarmonicTransformOperator
from
.domain_tuple
import
DomainTuple
from
.
import
dobj
,
utilities
...
...
@@ -45,8 +45,8 @@ def PS_field(pspace, func, dtype=None):
def
_single_power_analyze
(
field
,
idx
,
binbounds
):
power_domain
=
PowerSpace
(
field
.
domain
[
idx
],
binbounds
)
p
po
=
Power
ProjectionOpera
tor
(
field
.
domain
,
power_domain
,
idx
)
return
p
po
(
field
.
weight
(
1
)).
weight
(
-
1
)
# divides by bin size
p
d
=
Power
Distribu
tor
(
field
.
domain
,
power_domain
,
idx
)
return
p
d
.
adjoint_times
(
field
.
weight
(
1
)).
weight
(
-
1
)
# divides by bin size
def
power_analyze
(
field
,
spaces
=
None
,
binbounds
=
None
,
...
...
@@ -125,8 +125,8 @@ def power_synthesize_nonrandom(field, spaces=None):
spec
=
sqrt
(
field
)
for
i
in
spaces
:
result_domain
[
i
]
=
field
.
domain
[
i
].
harmonic_partner
p
po
=
Power
ProjectionOpera
tor
(
result_domain
,
field
.
domain
[
i
],
i
)
spec
=
p
po
.
adjoint_times
(
spec
)
p
d
=
Power
Distribu
tor
(
result_domain
,
field
.
domain
[
i
],
i
)
spec
=
p
d
(
spec
)
return
spec
...
...
@@ -203,7 +203,7 @@ def create_power_field(domain, power_spectrum, dtype=None):
power_domain
=
PowerSpace
(
domain
)
fp
=
PS_field
(
power_domain
,
power_spectrum
,
dtype
)
return
Power
ProjectionOpera
tor
(
domain
,
power_domain
)
.
adjoint_times
(
fp
)
return
Power
Distribu
tor
(
domain
,
power_domain
)(
fp
)
def
create_power_operator
(
domain
,
power_spectrum
,
space
=
None
,
dtype
=
None
):
...
...
test/test_energies/test_map.py
View file @
e954b8bf
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-201
7
Max-Planck-Society
# Copyright(C) 2013-201
8
Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
...
...
@@ -39,12 +39,12 @@ class Energy_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
target
=
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
False
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi0
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
)
s0
=
xi0
*
A
Instrument
=
ift
.
ScalingOperator
(
10.
,
space
)
...
...
@@ -85,12 +85,12 @@ class Energy_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
target
=
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
False
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi0
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
)
s
=
ht
(
xi0
*
A
)
R
=
ift
.
ScalingOperator
(
10.
,
space
)
...
...
@@ -129,12 +129,12 @@ class Curvature_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
target
=
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
False
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi0
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
)
s0
=
xi0
*
A
Instrument
=
ift
.
ScalingOperator
(
10.
,
space
)
...
...
@@ -178,12 +178,12 @@ class Curvature_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
target
=
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
False
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi0
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
)
s
=
ht
(
xi0
*
A
)
R
=
ift
.
ScalingOperator
(
10.
,
space
)
...
...
test/test_energies/test_noise.py
View file @
e954b8bf
...
...
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-201
7
Max-Planck-Society
# Copyright(C) 2013-201
8
Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
...
...
@@ -41,12 +41,12 @@ class Noise_Energy_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
target
=
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
False
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
tau
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
tau
))
A
=
Dist
(
ift
.
sqrt
(
tau
))
var
=
1.
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
...
...
@@ -86,7 +86,7 @@ class Noise_Energy_Tests(unittest.TestCase):
energy0
=
ift
.
library
.
NoiseEnergy
(
position
=
eta0
,
d
=
d
,
xi
=
xi
,
D
=
D
,
t
=
tau
,
Instrument
=
R
,
alpha
=
alpha
,
q
=
q
,
Projec
tion
=
P
,
nonlinearity
=
f
,
alpha
=
alpha
,
q
=
q
,
Distribu
tion
=
Dist
,
nonlinearity
=
f
,
ht
=
ht
,
samples
=
10
)
energy1
=
energy0
.
at
(
eta1
)
...
...
test/test_energies/test_power.py
View file @
e954b8bf
...
...
@@ -39,13 +39,13 @@ class Energy_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
True
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
64
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
tau0
=
ift
.
log
(
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
,
std
=
.
01
)
N
=
ift
.
DiagonalOperator
(
n
**
2
)
s
=
xi
*
A
...
...
@@ -91,12 +91,12 @@ class Energy_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
True
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
1
/
(
1
+
k
**
2
)
**
dim
tau0
=
ift
.
PS_field
(
pspace
,
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
tau0
))
A
=
Dist
(
ift
.
sqrt
(
tau0
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
)
s
=
ht
(
xi
*
A
)
R
=
ift
.
ScalingOperator
(
10.
,
space
)
...
...
@@ -132,7 +132,7 @@ class Energy_Tests(unittest.TestCase):
xi
=
xi
,
D
=
D
,
Instrument
=
R
,
Projec
tion
=
P
,
Distribu
tion
=
Dist
,
nonlinearity
=
f
,
ht
=
ht
,
N
=
N
,
...
...
@@ -160,13 +160,13 @@ class Curvature_Tests(unittest.TestCase):
ht
=
ift
.
HarmonicTransformOperator
(
hspace
,
space
)
binbounds
=
ift
.
PowerSpace
.
useful_binbounds
(
hspace
,
logarithmic
=
True
)
pspace
=
ift
.
PowerSpace
(
hspace
,
binbounds
=
binbounds
)
P
=
ift
.
Power
ProjectionOperator
(
domain
=
hspace
,
power_space
=
pspace
)
Dist
=
ift
.
Power
Distributor
(
target
=
hspace
,
power_space
=
pspace
)
xi
=
ift
.
Field
.
from_random
(
domain
=
hspace
,
random_type
=
'normal'
)
def
pspec
(
k
):
return
64
/
(
1
+
k
**
2
)
**
dim
pspec
=
ift
.
PS_field
(
pspace
,
pspec
)
tau0
=
ift
.
log
(
pspec
)
A
=
P
.
adjoint_times
(
ift
.
sqrt
(
pspec
))
A
=
Dist
(
ift
.
sqrt
(
pspec
))
n
=
ift
.
Field
.
from_random
(
domain
=
space
,
random_type
=
'normal'
,
std
=
.
01
)
N
=
ift
.
DiagonalOperator
(
n
**
2
)
s
=
xi
*
A
...
...
test/test_operators/test_adjoint.py
View file @
e954b8bf
...
...
@@ -35,15 +35,15 @@ _p_spaces = _p_RG_spaces + [ift.HPSpace(17), ift.GLSpace(8, 13)]
class
Consistency_Tests
(
unittest
.
TestCase
):
@
expand
(
product
(
_h_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testPPO
(
self
,
sp
,
dtype
):
op
=
ift
.
Power
ProjectionOperator
(
sp
)
op
=
ift
.
Power
Distributor
(
target
=
sp
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
ps
=
ift
.
PowerSpace
(
sp
,
ift
.
PowerSpace
.
useful_binbounds
(
sp
,
logarithmic
=
False
,
nbin
=
3
))
op
=
ift
.
Power
ProjectionOperator
(
sp
,
ps
)
op
=
ift
.
Power
Distributor
(
target
=
sp
,
power_space
=
ps
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
ps
=
ift
.
PowerSpace
(
sp
,
ift
.
PowerSpace
.
useful_binbounds
(
sp
,
logarithmic
=
True
,
nbin
=
3
))
op
=
ift
.
Power
ProjectionOperator
(
sp
,
ps
)
op
=
ift
.
Power
Distributor
(
target
=
sp
,
power_space
=
ps
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
@
expand
(
product
(
_h_RG_spaces
+
_p_RG_spaces
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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