Commit de59bf62 authored by Marco Selig's avatar Marco Selig

version update.

parent 33a90fc9
...@@ -63,6 +63,7 @@ apply to fields. ...@@ -63,6 +63,7 @@ apply to fields.
vector vector
* ``response_operator`` - exemplary responses that include a convolution, * ``response_operator`` - exemplary responses that include a convolution,
masking and projection masking and projection
* ``propagator_operator`` - information propagator in Wiener filter theory
* (and more) * (and more)
* (and more) * (and more)
...@@ -96,7 +97,7 @@ Requirements ...@@ -96,7 +97,7 @@ Requirements
Download Download
........ ........
The latest release is tagged **v0.4.2** and is available as a source package The latest release is tagged **v0.6.0** and is available as a source package
at `<https://github.com/mselig/nifty/tags>`_. The current version can be at `<https://github.com/mselig/nifty/tags>`_. The current version can be
obtained by cloning the repository:: obtained by cloning the repository::
...@@ -122,7 +123,7 @@ Please, acknowledge the use of NIFTY in your publication(s) by using a phrase ...@@ -122,7 +123,7 @@ Please, acknowledge the use of NIFTY in your publication(s) by using a phrase
such as the following: such as the following:
*"Some of the results in this publication have been derived using the NIFTY *"Some of the results in this publication have been derived using the NIFTY
[Selig et al., 2013] package."* package [Selig et al., 2013]."*
References References
.......... ..........
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
""" """
from __future__ import division from __future__ import division
from nifty import * # version 0.6.0 from nifty import * # version 0.6.0
from nifty.nifty_tools import *
# some signal space; e.g., a two-dimensional regular grid # some signal space; e.g., a two-dimensional regular grid
...@@ -57,15 +55,11 @@ n = N.get_random_field(domain=d_space) # generate ...@@ -57,15 +55,11 @@ n = N.get_random_field(domain=d_space) # generate
d = R(s) + n # compute data d = R(s) + n # compute data
j = R.adjoint_times(N.inverse_times(d)) # define information source j = R.adjoint_times(N.inverse_times(d)) # define information source
D = propagator_operator(S=S,N=N,R=R) # define information propagator D = propagator_operator(S=S, N=N, R=R) # define information propagator
m = D(j, tol=1E-4, note=True) # reconstruct map m = D(j, tol=1E-4, note=True) # reconstruct map
s.plot(title="signal") # plot signal s.plot(title="signal") # plot signal
d_ = field(x_space, val=d.val, target=k_space) d_ = field(x_space, val=d.val, target=k_space)
d_.plot(title="data", vmin=s.val.min(), vmax=s.val.max()) # plot data d_.plot(title="data", vmin=s.val.min(), vmax=s.val.max()) # plot data
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
""" """
from __future__ import division from __future__ import division
from nifty import * # version 0.6.0 from nifty import * # version 0.6.0
from nifty.nifty_tools import *
# some signal space; e.g., a two-dimensional regular grid # some signal space; e.g., a two-dimensional regular grid
...@@ -57,10 +55,8 @@ n = N.get_random_field(domain=d_space) # generate ...@@ -57,10 +55,8 @@ n = N.get_random_field(domain=d_space) # generate
d = R(s) + n # compute data d = R(s) + n # compute data
j = R.adjoint_times(N.inverse_times(d)) # define information source j = R.adjoint_times(N.inverse_times(d)) # define information source
D = propagator_operator(S=S,N=N,R=R) # define information propagator D = propagator_operator(S=S, N=N, R=R) # define information propagator
def eggs(x): def eggs(x):
...@@ -68,17 +64,15 @@ def eggs(x): ...@@ -68,17 +64,15 @@ def eggs(x):
Calculation of the information Hamiltonian and its gradient. Calculation of the information Hamiltonian and its gradient.
""" """
Dx = D.inverse_times(x) DIx = D.inverse_times(x)
H = 0.5 * Dx.dot(x) - j.dot(x) # compute information Hamiltonian H = 0.5 * DIx.dot(x) - j.dot(x) # compute information Hamiltonian
g = Dx - j # compute its gradient g = DIx - j # compute its gradient
return H,g return H, g
m = field(x_space, target=k_space) # reconstruct map m = field(x_space, target=k_space) # reconstruct map
m,convergence = steepest_descent(eggs=eggs, note=True)(m, tol=1E-4, clevel=3) m,convergence = steepest_descent(eggs=eggs, note=True)(m, tol=1E-4, clevel=3)
s.plot(title="signal") # plot signal s.plot(title="signal") # plot signal
d_ = field(x_space, val=d.val, target=k_space) d_ = field(x_space, val=d.val, target=k_space)
d_.plot(title="data", vmin=s.val.min(), vmax=s.val.max()) # plot data d_.plot(title="data", vmin=s.val.min(), vmax=s.val.max()) # plot data
......
...@@ -486,7 +486,7 @@ class _about(object): ## nifty support class for global settings ...@@ -486,7 +486,7 @@ class _about(object): ## nifty support class for global settings
""" """
## version ## version
self._version = "0.5.9" self._version = "0.6.0"
## switches and notifications ## switches and notifications
self._errors = notification(default=True,ccode=notification._code) self._errors = notification(default=True,ccode=notification._code)
...@@ -11703,17 +11703,17 @@ class probing(object): ...@@ -11703,17 +11703,17 @@ class probing(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def evaluate(self,sum_,num_,var_): def evaluate(self,summa,num,var):
""" """
Evaluates the probing results. Evaluates the probing results.
Parameters Parameters
---------- ----------
sum_ : numpy.array summa : numpy.array
Sum of all probing results. Sum of all probing results.
num_ : int num : int
Number of successful probings (not returning ``None``). Number of successful probings (not returning ``None``).
var_ : numpy.array var : numpy.array
Sum of all squared probing results Sum of all squared probing results
Returns Returns
...@@ -11727,27 +11727,27 @@ class probing(object): ...@@ -11727,27 +11727,27 @@ class probing(object):
(`final`,`var`). (`final`,`var`).
""" """
if(num_<self.nrun): if(num<self.nrun):
about.infos.cflush(" ( %u probe(s) failed, effectiveness == %.1f%% )\n"%(self.nrun-num_,100*num_/self.nrun)) about.infos.cflush(" ( %u probe(s) failed, effectiveness == %.1f%% )\n"%(self.nrun-num,100*num/self.nrun))
if(num_==0): if(num==0):
about.warnings.cprint("WARNING: probing failed.") about.warnings.cprint("WARNING: probing failed.")
return None return None
else: else:
about.infos.cflush("\n") about.infos.cflush("\n")
if(sum_.size==1): if(summa.size==1):
sum_ = sum_.flatten(order='C')[0] summa = summa.flatten(order='C')[0]
var_ = var_.flatten(order='C')[0] var = var.flatten(order='C')[0]
if(np.iscomplexobj(sum_))and(np.all(np.imag(sum_)==0)): if(np.iscomplexobj(summa))and(np.all(np.imag(summa)==0)):
sum_ = np.real(sum_) summa = np.real(summa)
final = sum_*(1/num_) final = summa*(1/num)
if(self.var): if(self.var):
if(num_==1): if(num==1):
about.warnings.cprint("WARNING: infinite variance.") about.warnings.cprint("WARNING: infinite variance.")
return final,None return final,None
else: else:
var = var_*(1/(num_*(num_-1)))-np.real(np.conjugate(final)*final)*(1/(num_-1)) var = var*(1/(num*(num-1)))-np.real(np.conjugate(final)*final)*(1/(num-1))
return final,var return final,var
else: else:
return final return final
...@@ -11858,7 +11858,7 @@ class probing(object): ...@@ -11858,7 +11858,7 @@ class probing(object):
## evaluate ## evaluate
return self.evaluate(_sum,_num,_var) return self.evaluate(_sum,_num,_var)
def __call__(self,loop=False,**kwargs): ## FIXME: doc def __call__(self,loop=False,**kwargs):
""" """
Starts the probing process. Starts the probing process.
...@@ -12129,17 +12129,17 @@ class trace_probing(probing): ...@@ -12129,17 +12129,17 @@ class trace_probing(probing):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def evaluate(self,sum_,num_,var_): def evaluate(self,summa,num,var):
""" """
Evaluates the probing results. Evaluates the probing results.
Parameters Parameters
---------- ----------
sum_ : scalar summa : scalar
Sum of all probing results. Sum of all probing results.
num_ : int num : int
Number of successful probings (not returning ``None``). Number of successful probings (not returning ``None``).
var_ : scalar var : scalar
Sum of all squared probing results Sum of all squared probing results
Returns Returns
...@@ -12153,24 +12153,24 @@ class trace_probing(probing): ...@@ -12153,24 +12153,24 @@ class trace_probing(probing):
(`final`,`var`). (`final`,`var`).
""" """
if(num_<self.nrun): if(num<self.nrun):
about.infos.cflush(" ( %u probe(s) failed, effectiveness == %.1f%% )\n"%(self.nrun-num_,100*num_/self.nrun)) about.infos.cflush(" ( %u probe(s) failed, effectiveness == %.1f%% )\n"%(self.nrun-num,100*num/self.nrun))
if(num_==0): if(num==0):
about.warnings.cprint("WARNING: probing failed.") about.warnings.cprint("WARNING: probing failed.")
return None return None
else: else:
about.infos.cflush("\n") about.infos.cflush("\n")
if(self.domain.datatype in [np.complex64,np.complex128]): if(self.domain.datatype in [np.complex64,np.complex128]):
sum_ = np.real(sum_) summa = np.real(summa)
final = sum_/num_ final = summa/num
if(self.var): if(self.var):
if(num_==1): if(num==1):
about.warnings.cprint("WARNING: infinite variance.") about.warnings.cprint("WARNING: infinite variance.")
return final,None return final,None
else: else:
var = var_/(num_*(num_-1))-np.real(np.conjugate(final)*final)/(num_-1) var = var/(num*(num-1))-np.real(np.conjugate(final)*final)/(num-1)
return final,var return final,var
else: else:
return final return final
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
.. /__/ /__/ /__/ /__/ \___/ \___ / power .. /__/ /__/ /__/ /__/ \___/ \___ / power
.. /______/ .. /______/
NIFTy offers a number of automatized routines for handling NIFTY offers a number of automatized routines for handling
power spectra. It is possible to draw a field from a random distribution power spectra. It is possible to draw a field from a random distribution
with a certain autocorrelation or, equivalently, with a certain with a certain autocorrelation or, equivalently, with a certain
power spectrum in its conjugate space (see :py:func:`field.random`). In power spectrum in its conjugate space (see :py:func:`field.random`). In
NIFTy, it is usually assumed that such a field follows statistical NIFTY, it is usually assumed that such a field follows statistical
homogeneity and isotropy. Fields which are only statistically homogeneous homogeneity and isotropy. Fields which are only statistically homogeneous
can also be created using the diagonal operator routine. can also be created using the diagonal operator routine.
......
...@@ -28,9 +28,12 @@ ...@@ -28,9 +28,12 @@
.. /__/ /__/ /__/ /__/ \___/ \___ / tools .. /__/ /__/ /__/ /__/ \___/ \___ / tools
.. /______/ .. /______/
A nifty set of tools. This module extends NIFTY with a nifty set of tools including further
operators, namely the :py:class:`invertible_operator` and the
## TODO: *DESCRIPTION* :py:class:`propagator_operator`, and minimization schemes, namely
:py:class:`steepest_descent` and :py:class:`conjugate_gradient`. Those
tools are supposed to support the user in solving information field
theoretical problems (almost) without numerical pain.
""" """
from __future__ import division from __future__ import division
...@@ -51,9 +54,10 @@ class invertible_operator(operator): ...@@ -51,9 +54,10 @@ class invertible_operator(operator):
NIFTY subclass for invertible, self-adjoint (linear) operators NIFTY subclass for invertible, self-adjoint (linear) operators
The base NIFTY operator class is an abstract class from which other The invertible operator class is an abstract class for self-adjoint or
specific operator subclasses, including those preimplemented in NIFTY symmetric (linear) operators from which other more specific operator
(e.g. the diagonal operator class) must be derived. subclassescan be derived. Such operators inherit an automated inversion
routine, namely conjugate gradient.
Parameters Parameters
---------- ----------
...@@ -76,9 +80,9 @@ class invertible_operator(operator): ...@@ -76,9 +80,9 @@ class invertible_operator(operator):
Notes Notes
----- -----
Operator classes derived from this one only need a `_multiply` or This class is not meant to be instantiated. Operator classes derived
`_inverse_multiply` instance method to perform the other. However, one from this one only need a `_multiply` or `_inverse_multiply` instance
of them needs to be defined. method to perform the other. However, one of them needs to be defined.
Attributes Attributes
---------- ----------
...@@ -275,8 +279,8 @@ class propagator_operator(operator): ...@@ -275,8 +279,8 @@ class propagator_operator(operator):
NIFTY subclass for propagator operators (of a certain family) NIFTY subclass for propagator operators (of a certain family)
The propagator operators :math:`D` implemented here have an inverse The propagator operators :math:`D` implemented here have an inverse
formulation like :math:`S^{-1} + M`, :math:`S^{-1} + N^{-1}`, or formulation like :math:`(S^{-1} + M)`, :math:`(S^{-1} + N^{-1})`, or
:math:`S^{-1} + R^\dagger N^{-1} R` as appearing in Wiener filter :math:`(S^{-1} + R^\dagger N^{-1} R)` as appearing in Wiener filter
theory. theory.
Parameters Parameters
...@@ -296,7 +300,7 @@ class propagator_operator(operator): ...@@ -296,7 +300,7 @@ class propagator_operator(operator):
Notes Notes
----- -----
The propagator will puzzle the operators `S` and `M` or `R`,`N` or The propagator will puzzle the operators `S` and `M` or `R`, `N` or
only `N` together in the predefined from, a domain is set only `N` together in the predefined from, a domain is set
automatically. The application of the inverse is done by invoking a automatically. The application of the inverse is done by invoking a
conjugate gradient. conjugate gradient.
...@@ -610,8 +614,8 @@ class conjugate_gradient(object): ...@@ -610,8 +614,8 @@ class conjugate_gradient(object):
References References
---------- ----------
.. [#] J. R. Shewchuk, 1994, `"An Introduction to the Conjugate .. [#] J. R. Shewchuk, 1994, `"An Introduction to the Conjugate
Gradient Method Without the Agonizing Pain" Gradient Method Without the Agonizing Pain"
`<http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf>`_ <http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf>`_
Examples Examples
-------- --------
......
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