Commit cb30efb6 authored by Martin Reinecke's avatar Martin Reinecke

merge

parents fd73e398 4fb590bb
#FROM ubuntu:artful
FROM debian:testing-slim
# dependencies via apt
RUN apt-get update
ADD ci/install_basics.sh /tmp/install_basics.sh
RUN sh /tmp/install_basics.sh
# python dependencies
ADD ci/requirements.txt /tmp/requirements.txt
RUN pip install --process-dependency-links -r /tmp/requirements.txt
# copy sources and install nifty
COPY . /tmp/NIFTy
RUN pip install /tmp/NIFTy
# Cleanup
RUN rm -r /tmp/*
parameterized
coverage
git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
sphinx
sphinx==1.6.7
sphinx_rtd_theme
numpydoc
......@@ -8,7 +8,7 @@ np.random.seed(42)
if __name__ == "__main__":
# Set up position space
s_space = ift.RGSpace([128, 128])
#s_space = ift.HPSpace(32)
# s_space = ift.HPSpace(32)
# Define harmonic transformation and associated harmonic space
h_space = s_space.get_default_codomain()
......@@ -63,7 +63,8 @@ if __name__ == "__main__":
tol_abs_gradnorm=1e-15)
minimizer = ift.RelaxedNewton(IC1)
ICI = ift.GradientNormController(iteration_limit=500, tol_abs_gradnorm=1e-10)
ICI = ift.GradientNormController(iteration_limit=500,
tol_abs_gradnorm=1e-10)
map_inverter = ift.ConjugateGradient(controller=ICI)
ICI2 = ift.GradientNormController(iteration_limit=200,
......
......@@ -53,8 +53,9 @@ if __name__ == "__main__":
MaskOperator = ift.DiagonalOperator(mask)
R = ift.GeometryRemover(s_space)
R = R*MaskOperator
#R = R*HT
#R = R * ift.create_harmonic_smoothing_operator((harmonic_space,),0,response_sigma)
# R = R*HT
# R = R * ift.create_harmonic_smoothing_operator((harmonic_space,), 0,
# response_sigma)
MeasurementOperator = R
d_space = MeasurementOperator.target
......
......@@ -71,8 +71,8 @@ if __name__ == "__main__":
mask_2 = ift.Field(signal_space_2, ift.dobj.from_global_data(mask_2))
R = ift.GeometryRemover(signal_domain)
R = R*ift.DiagonalOperator(mask_1, signal_domain,spaces=0)
R = R*ift.DiagonalOperator(mask_2, signal_domain,spaces=1)
R = R*ift.DiagonalOperator(mask_1, signal_domain, spaces=0)
R = R*ift.DiagonalOperator(mask_2, signal_domain, spaces=1)
R = R*ht
R = R * ift.create_harmonic_smoothing_operator(harmonic_domain, 0,
response_sigma_1)
......@@ -101,11 +101,13 @@ if __name__ == "__main__":
plotdict = {"colormap": "Planck-like"}
plot_space = ift.RGSpace((N_pixels_1, N_pixels_2))
ift.plot(ift.Field(plot_space,val=ht(mock_signal).val), name='mock_signal.png',
**plotdict)
ift.plot(ift.Field(plot_space,val=data.val), name='data.png', **plotdict)
ift.plot(ift.Field(plot_space,val=m.val), name='map.png', **plotdict)
ift.plot(ift.Field(plot_space, val=ht(mock_signal).val),
name='mock_signal.png', **plotdict)
ift.plot(ift.Field(plot_space, val=data.val), name='data.png', **plotdict)
ift.plot(ift.Field(plot_space, val=m.val), name='map.png', **plotdict)
# sampling the uncertainty map
mean, variance = ift.probe_with_posterior_samples(wiener_curvature, ht, 10)
ift.plot(ift.Field(plot_space, val=ift.sqrt(variance).val), name="uncertainty.png", **plotdict)
ift.plot(ift.Field(plot_space, val=(mean+m).val), name="posterior_mean.png", **plotdict)
ift.plot(ift.Field(plot_space, val=ift.sqrt(variance).val),
name="uncertainty.png", **plotdict)
ift.plot(ift.Field(plot_space, val=(mean+m).val),
name="posterior_mean.png", **plotdict)
......@@ -38,7 +38,8 @@ if __name__ == "__main__":
R = ift.GeometryRemover(signal_space)
R = R*ift.DiagonalOperator(mask)
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,5 +85,5 @@ if __name__ == "__main__":
# try to do the same with diagonal probing
variance = ift.probe_diagonal(ht*curv.inverse*ht.adjoint, 100)
#sm = ift.FFTSmoothingOperator(s_space, sigma=0.005)
ift.plot(variance, name="posterior_variance2.png", **plotdict2)
# sm = ift.FFTSmoothingOperator(s_space, sigma=0.015)
ift.plot(variance, name="posterior_variance2.png", **plotdict)
This diff is collapsed.
rm -rf docs/build docs/source/mod
sphinx-apidoc -l -e -d 2 -o docs/source/mod nifty4
#sphinx-apidoc -l -e -d 2 -o docs/source/mod nifty4
python docs/better_apidoc.py -l -e -d 3 -t docs/generation-templates -o docs/source/mod nifty4
sphinx-build -b html docs/source/ docs/build/
{% if name %}
{{ name }}
{% for item in range(8 + name|length) -%}={%- endfor %}
{% else %}
{{ fullname }}
{% for item in range(8 + fullname|length) -%}={%- endfor %}
{% endif %}
({{ fullname }} module)
.. currentmodule:: {{ fullname }}
.. automodule:: {{ fullname }}
{% if members -%}
:members: {{ members|join(", ") }}
:undoc-members:
:show-inheritance:
:member-order: bysource
Summary
-------
{%- if exceptions %}
Exceptions:
.. autosummary::
:nosignatures:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- if classes %}
Classes:
.. autosummary::
:nosignatures:
{% for item in classes %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- if functions %}
Functions:
.. autosummary::
:nosignatures:
{% for item in functions %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- if data %}
Data:
.. autosummary::
:nosignatures:
{% for item in data %}
{{ item }}
{%- endfor %}
{%- endif %}
{% if all_refs %}
``__all__``: {{ all_refs|join(", ") }}
{%- endif %}
{% if members %}
Reference
---------
{%- endif %}
{% if name %}
{{ name }}
{% for item in range(8 + name|length) -%}={%- endfor %}
{% else %}
{{ fullname }}
{% for item in range(8 + fullname|length) -%}={%- endfor %}
{% endif %}
({{ fullname }} package)
.. automodule:: {{ fullname }}
{% if members -%}
:members: {{ members|join(", ") }}
:undoc-members:
:show-inheritance:
{%- endif %}
{% if submodules %}
Submodules
----------
.. toctree::
:maxdepth: 1
{% for item in submodules %}
{{ fullname }}.{{ item }}
{%- endfor %}
{%- endif -%}
{% if subpackages %}
Subpackages
-----------
.. toctree::
:maxdepth: 1
{% for item in subpackages %}
{{ fullname }}.{{ item }}
{%- endfor %}
{%- endif %}
{% if members %}
Summary
-------
{%- if exceptions %}
Exceptions:
.. autosummary::
:nosignatures:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- if classes %}
Classes:
.. autosummary::
:nosignatures:
{% for item in classes %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- if functions %}
Functions:
.. autosummary::
:nosignatures:
{% for item in functions %}
{{ item }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- if data %}
Data:
.. autosummary::
:nosignatures:
{% for item in data %}
{{ item }}
{%- endfor %}
{%- endif %}
{% if all_refs %}
``__all__``: {{ all_refs|join(", ") }}
{%- endif %}
{% if members %}
Reference
---------
{%- endif %}
......@@ -22,14 +22,16 @@ from .structured_domain import StructuredDomain
class GLSpace(StructuredDomain):
"""NIFTy subclass for Gauss-Legendre pixelizations [#]_ of the two-sphere.
"""NIFTy subclass for Gauss-Legendre pixelizations of the two-sphere.
Its harmonic partner is the :class:`LMSpace`
Parameters
----------
nlat : int
Number of latitudinal bins (or rings) that are used for this
pixelization.
nlon : int, *optional*
nlon : int, optional
Number of longitudinal bins that are used for this pixelization.
Default value is 2*nlat + 1.
......@@ -37,19 +39,6 @@ class GLSpace(StructuredDomain):
------
ValueError
If input `nlat` or `nlon` is invalid.
See Also
--------
HPSpace, LMSpace
References
----------
.. [#] M. Reinecke and D. Sverre Seljebotn, 2013, "Libsharp - spherical
harmonic transforms revisited";
`arXiv:1303.4945 <http://www.arxiv.org/abs/1303.4945>`_
.. [#] K.M. Gorski et al., 2005, "HEALPix: A Framework for
High-Resolution Discretization and Fast Analysis of Data
Distributed on the Sphere", *ApJ* 622..759G.
"""
def __init__(self, nlat, nlon=None):
......
......@@ -24,14 +24,14 @@ from .. import dobj
class PowerSpace(StructuredDomain):
"""NIFTy class for spaces of power spectra.
A power space is the result of a projection of a harmonic space where
A power space is the result of a projection of a harmonic domain where
k-modes of equal length get mapped to one power index.
Parameters
----------
harmonic_partner : Space
The harmonic Space of which this is the power space.
binbounds: None, or tuple/array/list of float
harmonic_partner : StructuredDomain
The harmonic dmain of which this is the power space.
binbounds : None, or tuple of float
if None:
There will be as many bins as there are distinct k-vector lengths
in the harmonic partner space.
......@@ -54,9 +54,9 @@ class PowerSpace(StructuredDomain):
binbounds[0]=first_bound and binbounds[-1]=last_bound and the remaining
values equidistantly spaced (in linear scale) between these two.
nbin: integer
nbin : int
the number of bins
first_bound, last_bound: float
first_bound, last_bound : float
the k values for the right boundary of the first bin and the left
boundary of the last bin, respectively. They are given in length
units of the harmonic partner space.
......@@ -74,9 +74,9 @@ class PowerSpace(StructuredDomain):
values equidistantly spaced (in natural logarithmic scale)
between these two.
nbin: integer
nbin : int
the number of bins
first_bound, last_bound: float
first_bound, last_bound : float
the k values for the right boundary of the first bin and the left
boundary of the last bin, respectively. They are given in length
units of the harmonic partner space.
......
......@@ -30,16 +30,16 @@ class RGSpace(StructuredDomain):
Parameters
----------
shape : {int, numpy.ndarray}
shape : int or tuple of int
Number of grid points or numbers of gridpoints along each axis.
distances : {float, numpy.ndarray}, *optional*
distances : None or float or tuple of float, optional
Distance between two grid points along each axis
(default: None).
If distances==None:
if harmonic==True, all distances will be set to 1
if harmonic==False, the distance along each axis will be
set to the inverse of the number of points along that axis.
harmonic : bool, *optional*
harmonic : bool, optional
Whether the space represents a grid in position or harmonic space.
(default: False).
"""
......
......@@ -354,7 +354,7 @@ class Field(object):
Returns
-------
Field:
Field
The complex conjugated field.
"""
return Field(self._domain, self.val.conjugate())
......
......@@ -34,33 +34,34 @@ class CriticalPowerEnergy(Energy):
Parameters
----------
position : Field,
position : Field
The current position of this energy. (Logarithm of power spectrum)
m : Field,
m : Field
The map whose power spectrum is inferred. Needs to live in harmonic
signal space.
D : EndomorphicOperator,
D : EndomorphicOperator, optional
The curvature of the Gaussian encoding the posterior covariance.
If not specified, the map is assumed to be no reconstruction.
default : None
alpha : float
alpha : float, optional
The spectral prior of the inverse gamma distribution. 1.0 corresponds
to non-informative.
default : 1.0
q : float
q : float, optional
The cutoff parameter of the inverse gamma distribution. 0.0 corresponds
to non-informative.
default : 0.0
smoothness_prior : float
smoothness_prior : float, optional
Controls the strength of the smoothness prior
default : 0.0
logarithmic : boolean
logarithmic : bool, optional
Whether smoothness acts on linear or logarithmic scale.
samples : integer
default : True
samples : int, optional
Number of samples used for the estimation of the uncertainty
corrections.
default : 3
w : Field
w : Field, optional
The contribution from the map with or without uncertainty. It is used
to pass on the result of the costly sampling during the minimization.
default : None
......
......@@ -34,18 +34,18 @@ class NonlinearPowerEnergy(Energy):
Parameters
----------
position : Field,
position : Field
The current position of this energy.
m : Field,
m : Field
The map whichs power spectrum has to be inferred
D : EndomorphicOperator,
D : EndomorphicOperator
The curvature of the Gaussian encoding the posterior covariance.
If not specified, the map is assumed to be no reconstruction.
default : None
sigma : float
The parameter of the smoothness prior.
default : ??? None? ???????
samples : integer
samples : int
Number of samples used for the estimation of the uncertainty
corrections.
default : 3
......
......@@ -56,9 +56,9 @@ class ConjugateGradient(Minimizer):
Returns
-------
energy : QuadraticEnergy
QuadraticEnergy
state at last point of the iteration
status : integer
int
Can be controller.CONVERGED or controller.ERROR
"""
controller = self._controller
......
......@@ -50,15 +50,15 @@ class DescentMinimizer(Minimizer):
Parameters
----------
energy : Energy object
nergy : Energy
Energy object which provides value, gradient and curvature at a
specific position in parameter space.
Returns
-------
energy : Energy object
Energy
Latest `energy` of the minimization.
status : integer
int
Can be controller.CONVERGED or controller.ERROR
Notes
......
......@@ -41,13 +41,13 @@ class LineSearchStrongWolfe(LineSearch):
Parameter for curvature condition rule. (Default: 0.9)
max_step_size : float
Maximum step allowed in to be made in the descent direction.
(Default: 50)
max_iterations : integer
(Default: 1000000000)
max_iterations : int, optional
Maximum number of iterations performed by the line search algorithm.
(Default: 10)
max_zoom_iterations : integer
(Default: 100)
max_zoom_iterations : int, optional
Maximum number of iterations performed by the zoom algorithm.
(Default: 10)
(Default: 100)
"""
def __init__(self, c1=1e-4, c2=0.9,
......@@ -71,18 +71,18 @@ class LineSearchStrongWolfe(LineSearch):
Parameters
----------
energy : Energy object
energy : Energy
Energy object from which we will calculate the energy and the
gradient at a specific point.
pk : Field
Vector pointing into the search direction.
f_k_minus_1 : float
f_k_minus_1 : float, optional
Value of the fuction (which is being minimized) at the k-1
iteration of the line search procedure. (Default: None)
Returns
-------
energy_star : Energy object
Energy
The new Energy object on the new position.
"""
le_0 = LineEnergy(0., energy, pk, 0.)
......@@ -188,7 +188,7 @@ class LineSearchStrongWolfe(LineSearch):
Returns
-------
energy_star : Energy object
Energy
The new Energy object on the new position.
"""
cubic_delta = 0.2 # cubic interpolant checks
......
......@@ -39,8 +39,9 @@ class Minimizer(with_metaclass(NiftyMeta, type('NewBase', (object,), {}))):
Returns
-------
energy : Energy object
Energy
Latest `energy` of the minimization.
status : integer
int
exit status of the minimization
"""
raise NotImplementedError
......@@ -51,9 +51,9 @@ class NonlinearCG(Minimizer):
Returns
-------
energy :
Energy
state at last point of the iteration
status : integer
int
Can be controller.CONVERGED or controller.ERROR
"""
controller = self._controller
......
......@@ -87,7 +87,7 @@ class InformationStore(object):
Parameters
----------
max_history_length : integer
max_history_length : int
Maximum number of stored past updates.
x0 : Field
Initial position in variable space.
......@@ -96,7 +96,7 @@ class InformationStore(object):
Attributes
----------
max_history_length : integer
max_history_length : int
Maximum number of stored past updates.
s : List
Circular buffer of past position differences, which are Fields.
......@@ -106,7 +106,7 @@ class InformationStore(object):
Latest position in variable space.
last_gradient : Field
Gradient at latest position.
k : integer
k : int
Number of updates that have taken place
ss : numpy.ndarray
2D circular buffer of scalar products between different elements of s.
......@@ -139,7 +139,7 @@ class InformationStore(object):
Returns
-------
result : List
List
List of new basis vectors.
"""
result = []
......@@ -165,7 +165,7 @@ class InformationStore(object):
Returns
-------
result : numpy.ndarray
numpy.ndarray
Scalar matrix.
"""
m = self.history_length
......@@ -207,7 +207,7 @@ class InformationStore(object):
Returns
-------
delta : List
List
List of the new scalar coefficients (deltas).
"""
m = self.history_length
......
......@@ -30,7 +30,7 @@ def FFTSmoothingOperator(domain, sigma, space=None):
Parameters
----------
domain : Domain, tuple of Domains, or DomainTuple
domain : Domain, tuple of Domain, or DomainTuple
The total domain of the operator's input and output fields
sigma : float>=0
......@@ -38,7 +38,7 @@ def FFTSmoothingOperator(domain, sigma, space=None):
the RGSpace the operator is working on.
If `sigma==0`, an identity operator will be returned.
space: integer, *optional*
space : int, optional
The index of the sub-domain on which the smoothing is performed.
Can be omitted if `domain` only has one sub-domain.