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
Thomas Peters
NIFTy
Commits
ef50508c
Commit
ef50508c
authored
Jul 13, 2017
by
Philipp Arras
Browse files
Update demo wiener_filter_easy to match PEP8 style
parent
be48424b
Changes
1
Hide whitespace changes
Inline
Side-by-side
demos/wiener_filter_easy.py
View file @
ef50508c
from
nifty
import
*
#import plotly.offline as pl
#import plotly.graph_objs as go
import
numpy
as
np
from
nifty
import
(
DiagonalOperator
,
EndomorphicOperator
,
FFTOperator
,
Field
,
InvertibleOperatorMixin
,
PowerSpace
,
RGSpace
,
SmoothingOperator
,
create_power_operator
)
from
mpi4py
import
MPI
comm
=
MPI
.
COMM_WORLD
rank
=
comm
.
rank
class
PropagatorOperator
(
InvertibleOperatorMixin
,
EndomorphicOperator
):
def
__init__
(
self
,
R
,
N
,
S
,
default_spaces
=
None
):
super
(
PropagatorOperator
,
self
).
__init__
(
default_spaces
=
default_spaces
)
...
...
@@ -37,39 +39,39 @@ class PropagatorOperator(InvertibleOperatorMixin, EndomorphicOperator):
def
self_adjoint
(
self
):
return
True
if
__name__
==
"__main__"
:
distribution_strategy
=
'not'
#Set
ting
up physical constants
#
t
otal length of
I
nterval or
V
olume the field lives on, e.g. in meters
#
Set up physical constants
#
T
otal length of
i
nterval or
v
olume the field lives on, e.g. in meters
L
=
2.
#
t
ypical distance over which the field is correlated (in same unit as L)
#
T
ypical distance over which the field is correlated (in same unit as L)
correlation_length
=
0.1
#
v
ariance of field in position space sqrt(<|s_x|^2>) (in unit of s)
#
V
ariance of field in position space sqrt(<|s_x|^2>) (in unit of s)
field_variance
=
2.
#
s
moothing length of response (in same unit as L)
#
S
moothing length of response (in same unit as L)
response_sigma
=
0.01
#
d
efin
ing
resolution (pixels per dimension)
#
D
efin
e
resolution (pixels per dimension)
N_pixels
=
256
#Set
ting
up derived constants
#
Set up derived constants
k_0
=
1.
/
correlation_length
#
n
ote that field_variance**2 = a*k_0/4. for this analytic form of power
#spectrum
#
N
ote that field_variance**2 = a*k_0/4. for this analytic form of power
#
spectrum
a
=
field_variance
**
2
/
k_0
*
4.
pow_spec
=
(
lambda
k
:
a
/
(
1
+
k
/
k_0
)
**
4
)
pixel_width
=
L
/
N_pixels
# Set
ting
up the geometry
s_space
=
RGSpace
([
N_pixels
,
N_pixels
],
distances
=
pixel_width
)
# Set up the geometry
s_space
=
RGSpace
([
N_pixels
,
N_pixels
],
distances
=
pixel_width
)
fft
=
FFTOperator
(
s_space
)
h_space
=
fft
.
target
[
0
]
p_space
=
PowerSpace
(
h_space
,
distribution_strategy
=
distribution_strategy
)
# Creating the mock data
# Create mock data
S
=
create_power_operator
(
h_space
,
power_spectrum
=
pow_spec
,
distribution_strategy
=
distribution_strategy
)
...
...
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