Commit 8bc3a2d0 by Ultima

### More tests for lm_space.

Some bugfixes.
parent e10b54aa
 ... ... @@ -38,7 +38,6 @@ from nifty_core import space,\ field from nifty_mpi_data import distributed_data_object, d2o_librarian from nifty_power import * from nifty_random import random from nifty_simple_math import * from nifty_utilities import * ... ... @@ -46,7 +45,6 @@ from nifty_utilities import * from nifty_paradict import space_paradict,\ point_space_paradict,\ nested_space_paradict from smoothing import * from operators import * ## optional submodule `rg` ... ...
 ... ... @@ -32,25 +32,33 @@ """ from __future__ import division import matplotlib as mpl mpl.use('Agg') import imp nifty = imp.load_module('nifty', None, '/home/steininger/Downloads/nifty', ('','',5)) from nifty import * # version 0.8.0 about.warnings.off() # some signal space; e.g., a two-dimensional regular grid x_space = rg_space([1280, 1280]) # define signal space #x_space = rg_space(512) x_space = rg_space([4280, 1280]) # define signal space #y_space = point_space(1280*1280) #x_space = hp_space(32) #x_space = gl_space(96) #x_space = gl_space(800) k_space = x_space.get_codomain() # get conjugate space y_space = point_space(1280*1280) # some power spectrum power = (lambda k: 42 / (k + 1) ** 3) power = (lambda k: 42 / (k + 1) ** 4) S = power_operator(k_space, spec=power) # define signal covariance S = power_operator(k_space, codomain=x_space, spec=power) # define signal covariance s = S.get_random_field(domain=x_space) # generate signal R = response_operator(x_space, sigma=0.0, mask=1.0, assign=None, target = y_space) # define response R = response_operator(x_space, sigma=0.0, mask=1.0, assign=None) # define response d_space = R.target # get data space # some noise variance; e.g., signal-to-noise ratio of 1 ... ... @@ -58,15 +66,15 @@ N = diagonal_operator(d_space, diag=s.var(), bare=True) # define noise n = N.get_random_field(domain=d_space) # generate noise d = R(s) #+ n # compute data d = R(s) + n # compute data j = R.adjoint_times(N.inverse_times(d)) # define information source D = propagator_operator(S=S, N=N, R=R) # define information propagator m = D(j, W=S, tol=1E-2, note=True) # reconstruct map s.plot(title="signal", save = 'plot_s.png') # plot signal d_ = field(x_space, val=d.val, target=k_space) d_.plot(title="data", vmin=s.min(), vmax=s.max(), save = 'plot_d.png') # plot data m.plot(title="reconstructed map", vmin=s.min(), vmax=s.max(), save = 'plot_m.png') # plot map m = D(j, W=S, tol=1E-8, limii=10, note=True) # reconstruct map #s.plot(title="signal", save = 'plot_s.png') # plot signal #d_ = field(x_space, val=d.val, target=k_space) #d_.plot(title="data", vmin=s.min(), vmax=s.max(), save = 'plot_d.png') # plot data #m.plot(title="reconstructed map", vmin=s.min(), vmax=s.max(), save = 'plot_m.png') # plot map #
 ... ... @@ -21,7 +21,8 @@ class Comm(object): class Intracomm(Comm): def __init__(self): def __init__(self, name): self.name = name self.rank = 0 self.size = 1 ... ... @@ -115,4 +116,4 @@ COMPLEX = _datatype("MPI_COMPLEX") DOUBLE_COMPLEX = _datatype("MPI_DOUBLE_COMPLEX") COMM_WORLD = Intracomm() COMM_WORLD = Intracomm('MPI_dummy_COMM_WORLD')
 ... ... @@ -71,7 +71,7 @@ class configuration(object): self.set_path(path=path, path_section=path_section) try: self.load() except ValueError: except: pass def __getitem__(self, key): ... ...
 ... ... @@ -23,13 +23,28 @@ variable_fft_module = variable('fft_module', variable_lm2gl = variable('lm2gl', [True, False], lambda z: z is True or z is False, genus = 'boolean') lambda z: isinstance(z, bool), genus='boolean') variable_use_healpy = variable( 'use_healpy', [True, False], lambda z: (('healpy' in global_dependency_injector) if z else True) and isinstance(z, bool), genus='boolean') variable_use_libsharp = variable('use_libsharp', [True, False], lambda z: (('libsharp_wrapper_gl' in global_dependency_injector) if z else True) and isinstance(z, bool), genus='boolean') variable_verbosity = variable('verbosity', [1], lambda z: z == abs(int(z)), genus = 'int') genus='int') variable_mpi_module = variable('mpi_module', ['MPI', 'MPI_dummy'], ... ... @@ -45,6 +60,8 @@ variable_default_distribution_strategy = variable( global_configuration = configuration( [variable_fft_module, variable_lm2gl, variable_use_healpy, variable_use_libsharp, variable_verbosity, variable_mpi_module, variable_default_distribution_strategy ... ... @@ -60,4 +77,7 @@ variable_default_comm = variable( global_configuration.register(variable_default_comm) try: global_configuration.load() except: pass
 # -*- coding: utf-8 -*- import imp import sys class dependency_injector(object): ... ... @@ -40,7 +39,7 @@ class dependency_injector(object): # print pathname # loaded_module = \ # imp.load_module(module_name, fp, pathname, description) # # # print loaded_module self.registry[key_name] = loaded_module except ImportError: ... ... @@ -52,10 +51,15 @@ class dependency_injector(object): # except (UnboundLocalError, AttributeError): # pass def unregister(self, module_name): try: del self.registry['module_name'] except KeyError: pass def recursive_import(name): m = __import__(name) for n in name.split(".")[1:]: m = getattr(m, n) return m