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
02632255
Commit
02632255
authored
Aug 24, 2017
by
Martin Reinecke
Browse files
Merge branch 'master' into fix_smoothing
parents
2c2489b9
846cc966
Pipeline
#17244
passed with stage
in 50 minutes and 31 seconds
Changes
5
Pipelines
1
Show whitespace changes
Inline
Side-by-side
demos/wiener_filter_via_hamiltonian.py
View file @
02632255
...
...
@@ -117,13 +117,13 @@ if __name__ == "__main__":
# Solving the problem analytically
m0
=
D0
.
inverse_times
(
j
)
sample_variance
=
Field
(
sh
.
domain
,
val
=
0.
+
0j
)
sample_mean
=
Field
(
sh
.
domain
,
val
=
0.
+
0j
)
sample_variance
=
Field
(
sh
.
domain
,
val
=
0.
)
sample_mean
=
Field
(
sh
.
domain
,
val
=
0.
)
# sampling the uncertainty map
n_samples
=
1
n_samples
=
1
0
for
i
in
range
(
n_samples
):
sample
=
sugar
.
generate_posterior_sample
(
m
0
,
D0
)
sample
=
fft
(
sugar
.
generate_posterior_sample
(
0
.
,
D0
)
)
sample_variance
+=
sample
**
2
sample_mean
+=
sample
variance
=
sample_variance
/
n_samples
-
(
sample_mean
/
n_samples
)
variance
=
(
sample_variance
-
sample_mean
**
2
)
/
n_samples
nifty/basic_arithmetics.py
View file @
02632255
...
...
@@ -24,7 +24,7 @@ from .field import Field
__all__
=
[
'cos'
,
'sin'
,
'cosh'
,
'sinh'
,
'tan'
,
'tanh'
,
'arccos'
,
'arcsin'
,
'arccosh'
,
'arcsinh'
,
'arctan'
,
'arctanh'
,
'sqrt'
,
'exp'
,
'log'
,
'conjugate'
,
'clipped_exp'
,
'limited_exp'
]
'conjugate'
,
'clipped_exp'
,
'limited_exp'
,
'limited_exp_deriv'
]
def
_math_helper
(
x
,
function
):
...
...
@@ -101,15 +101,28 @@ def clipped_exp(x):
def
limited_exp
(
x
):
thr
=
200
expthr
=
np
.
exp
(
thr
)
return
_math_helper
(
x
,
lambda
z
:
_limited_exp_helper
(
z
,
thr
,
expthr
))
return
_math_helper
(
x
,
_limited_exp_helper
)
def
_limited_exp_helper
(
x
):
thr
=
200.
mask
=
x
>
thr
if
np
.
count_nonzero
(
mask
)
==
0
:
return
np
.
exp
(
x
)
result
=
((
1.
-
thr
)
+
x
)
*
np
.
exp
(
thr
)
result
[
~
mask
]
=
np
.
exp
(
x
[
~
mask
])
return
result
def
_limited_exp_helper
(
x
,
thr
,
expthr
):
mask
=
(
x
>
thr
)
result
=
np
.
exp
(
x
)
result
[
mask
]
=
((
1
-
thr
)
+
x
[
mask
])
*
expthr
def
limited_exp_deriv
(
x
):
return
_math_helper
(
x
,
_limited_exp_deriv_helper
)
def
_limited_exp_deriv_helper
(
x
):
thr
=
200.
mask
=
x
>
thr
if
np
.
count_nonzero
(
mask
)
==
0
:
return
np
.
exp
(
x
)
result
=
np
.
empty_like
(
x
)
result
[
mask
]
=
np
.
exp
(
thr
)
result
[
~
mask
]
=
np
.
exp
(
x
[
~
mask
])
return
result
...
...
nifty/field.py
View file @
02632255
...
...
@@ -330,7 +330,7 @@ class Field(Loggable, Versionable, object):
Returns
-------
out : Field
The output object. It
'
s domain is a PowerSpace and it contains
The output object. Its domain is a PowerSpace and it contains
the power spectrum of 'self's field.
See Also
...
...
nifty/minimization/line_searching/line_search.py
View file @
02632255
...
...
@@ -28,7 +28,7 @@ class LineSearch(with_metaclass(abc.ABCMeta, type('NewBase', (Loggable, object),
"""Class for determining the optimal step size along some descent direction.
Initialize the line search procedure which can be used by a specific line
search method. It
s
finds the step size in a specific direction in the
search method. It finds the step size in a specific direction in the
minimization process.
Attributes
...
...
nifty/sugar.py
View file @
02632255
...
...
@@ -108,7 +108,7 @@ def generate_posterior_sample(mean, covariance):
R
=
covariance
.
R
N
=
covariance
.
N
power
=
S
.
diagonal
().
power_analyze
()
**
.
5
power
=
sqrt
(
S
.
diagonal
().
power_analyze
()
)
mock_signal
=
power
.
power_synthesize
(
real_signal
=
True
)
noise
=
N
.
diagonal
(
bare
=
True
)
...
...
Write
Preview
Supports
Markdown
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