Commit c79ba39c authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweaks, mostly PEP8

parent c803a3ec
Pipeline #24510 passed with stage
in 6 minutes and 16 seconds
......@@ -28,7 +28,7 @@ if __name__ == "__main__":
# Set up the geometry
s_space = ift.RGSpace([N_pixels, N_pixels], distances=pixel_width)
h_space = s_space.get_default_codomain()
ht = ift.HarmonicTransformOperator(h_space, s_space)
HT = ift.HarmonicTransformOperator(h_space, s_space)
p_space = ift.PowerSpace(h_space)
# Create mock data
......@@ -38,7 +38,8 @@ if __name__ == "__main__":
sp = ift.PS_field(p_space, pow_spec)
sh = ift.power_synthesize(sp, real_signal=True)
R = ht*ift.create_harmonic_smoothing_operator((h_space,),0,response_sigma)
R = HT*ift.create_harmonic_smoothing_operator((h_space,), 0,
response_sigma)
noiseless_data = R(sh)
signal_to_noise = 1.
......@@ -64,10 +65,9 @@ if __name__ == "__main__":
# Plotting
d_field = ift.Field(s_space, val=d.val)
zmax = max(ht(sh).max(), d_field.max(), ht(m).max())
zmin = min(ht(sh).min(), d_field.min(), ht(m).min())
plotdict = {"xlabel": "Pixel index", "ylabel": "Pixel index",
"colormap": "Planck-like", "zmax": zmax, "zmin": zmin}
ift.plot(ht(sh), name="mock_signal.png", **plotdict)
zmax = max(HT(sh).max(), d_field.max(), HT(m).max())
zmin = min(HT(sh).min(), d_field.min(), HT(m).min())
plotdict = {"colormap": "Planck-like", "zmax": zmax, "zmin": zmin}
ift.plot(HT(sh), name="mock_signal.png", **plotdict)
ift.plot(d_field, name="data.png", **plotdict)
ift.plot(ht(m), name="reconstruction.png", **plotdict)
ift.plot(HT(m), name="reconstruction.png", **plotdict)
......@@ -3,9 +3,17 @@ import nifty4 as ift
import numericalunits as nu
def init_nu():
if ift.dobj.ntask > 1:
from mpi4py import MPI
comm = MPI.COMM_WORLD
data = np.random.randint(10000000, size=1)
data = comm.bcast(data, root=0)
nu.reset_units(data[0])
if __name__ == "__main__":
# In MPI mode, the random seed for numericalunits must be set by hand
#nu.reset_units(43)
init_nu()
# the number of dimensions for the problem
# For dimensionality>2, you should probably reduce N_pixels, otherwise
......@@ -29,7 +37,7 @@ if __name__ == "__main__":
# note that field_variance**2 = a*k_0/4. for this analytic form of power
# spectrum
def power_spectrum(k):
#RL FIXME: signal_amplitude is not how much signal varies
# RL FIXME: signal_amplitude is not how much signal varies
cldim = correlation_length**(2*dimensionality)
a = 4/(2*np.pi) * cldim * field_sigma**2
# to be integrated over spherical shells later on
......@@ -58,7 +66,8 @@ if __name__ == "__main__":
R = ift.GeometryRemover(signal_space)
R = R*ift.ScalingOperator(sensitivity, signal_space)
R = R*HT
R = R * ift.create_harmonic_smoothing_operator((harmonic_space,),0,response_sigma)
R = R * ift.create_harmonic_smoothing_operator(
(harmonic_space,), 0, response_sigma)
data_domain = R.target[0]
noiseless_data = R(mock_signal)
......@@ -85,6 +94,8 @@ if __name__ == "__main__":
zmin = min(m_s.min(), HT(mock_signal).min())
plotdict = {"zmax": zmax/nu.K, "zmin": zmin/nu.K}
ift.plot(ift.Field(sspace2, HT(mock_signal).val)/nu.K, name="mock_signal.png", **plotdict)
ift.plot(ift.Field(sspace2, HT(mock_signal).val)/nu.K,
name="mock_signal.png", **plotdict)
ift.plot(ift.Field(sspace2, val=data.val), name="data.png")
ift.plot(ift.Field(sspace2, m_s.val)/nu.K, name="reconstruction.png", **plotdict)
ift.plot(ift.Field(sspace2, m_s.val)/nu.K, name="reconstruction.png",
**plotdict)
......@@ -55,8 +55,9 @@ from .plotting.plot import plot
from . import library
from . import extra
__all__ = ["Domain", "UnstructuredDomain", "StructuredDomain", "RGSpace", "LMSpace",
"HPSpace", "GLSpace", "DOFSpace", "PowerSpace", "DomainTuple",
__all__ = ["Domain", "UnstructuredDomain", "StructuredDomain",
"RGSpace", "LMSpace", "HPSpace", "GLSpace", "DOFSpace",
"PowerSpace", "DomainTuple",
"LinearOperator", "EndomorphicOperator", "ScalingOperator",
"DiagonalOperator", "FFTOperator", "FFTSmoothingOperator",
"DirectSmoothingOperator", "LaplaceOperator",
......
......@@ -164,13 +164,9 @@ class LinearOperator(with_metaclass(
raise ValueError("The operator's and field's domains don't match.")
def draw_sample(self):
""" Generates a sample from a Gaussian distribution with
""" Generates a sample from a Gaussian distribution with zero mean and
covariance given by the operator.
This method generates samples by setting up the observation and
reconstruction of a mock signal in order to obtain residuals of the
right correlation.
Returns
-------
sample : Field
......
Markdown is supported
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