Commit ef50508c authored by Philipp Arras's avatar Philipp Arras
Browse files

Update demo wiener_filter_easy to match PEP8 style

parent be48424b
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'
#Setting up physical constants
#total length of Interval or Volume the field lives on, e.g. in meters
# Set up physical constants
# Total length of interval or volume the field lives on, e.g. in meters
L = 2.
#typical distance over which the field is correlated (in same unit as L)
# Typical distance over which the field is correlated (in same unit as L)
correlation_length = 0.1
#variance of field in position space sqrt(<|s_x|^2>) (in unit of s)
# Variance of field in position space sqrt(<|s_x|^2>) (in unit of s)
field_variance = 2.
#smoothing length of response (in same unit as L)
# Smoothing length of response (in same unit as L)
response_sigma = 0.01
#defining resolution (pixels per dimension)
# Define resolution (pixels per dimension)
N_pixels = 256
#Setting up derived constants
# Set up derived constants
k_0 = 1./correlation_length
#note that field_variance**2 = a*k_0/4. for this analytic form of power
#spectrum
# Note 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
# Setting 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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment