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

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 parameterized
coverage coverage
git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
sphinx sphinx==1.6.7
sphinx_rtd_theme sphinx_rtd_theme
numpydoc numpydoc
...@@ -8,7 +8,7 @@ np.random.seed(42) ...@@ -8,7 +8,7 @@ np.random.seed(42)
if __name__ == "__main__": if __name__ == "__main__":
# Set up position space # Set up position space
s_space = ift.RGSpace([128, 128]) s_space = ift.RGSpace([128, 128])
#s_space = ift.HPSpace(32) # s_space = ift.HPSpace(32)
# Define harmonic transformation and associated harmonic space # Define harmonic transformation and associated harmonic space
h_space = s_space.get_default_codomain() h_space = s_space.get_default_codomain()
...@@ -63,7 +63,8 @@ if __name__ == "__main__": ...@@ -63,7 +63,8 @@ if __name__ == "__main__":
tol_abs_gradnorm=1e-15) tol_abs_gradnorm=1e-15)
minimizer = ift.RelaxedNewton(IC1) 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) map_inverter = ift.ConjugateGradient(controller=ICI)
ICI2 = ift.GradientNormController(iteration_limit=200, ICI2 = ift.GradientNormController(iteration_limit=200,
......
...@@ -53,8 +53,9 @@ if __name__ == "__main__": ...@@ -53,8 +53,9 @@ if __name__ == "__main__":
MaskOperator = ift.DiagonalOperator(mask) MaskOperator = ift.DiagonalOperator(mask)
R = ift.GeometryRemover(s_space) R = ift.GeometryRemover(s_space)
R = R*MaskOperator R = R*MaskOperator
#R = R*HT # 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)
MeasurementOperator = R MeasurementOperator = R
d_space = MeasurementOperator.target d_space = MeasurementOperator.target
......
...@@ -71,8 +71,8 @@ if __name__ == "__main__": ...@@ -71,8 +71,8 @@ if __name__ == "__main__":
mask_2 = ift.Field(signal_space_2, ift.dobj.from_global_data(mask_2)) mask_2 = ift.Field(signal_space_2, ift.dobj.from_global_data(mask_2))
R = ift.GeometryRemover(signal_domain) R = ift.GeometryRemover(signal_domain)
R = R*ift.DiagonalOperator(mask_1, signal_domain,spaces=0) 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_2, signal_domain, spaces=1)
R = R*ht R = R*ht
R = R * ift.create_harmonic_smoothing_operator(harmonic_domain, 0, R = R * ift.create_harmonic_smoothing_operator(harmonic_domain, 0,
response_sigma_1) response_sigma_1)
...@@ -101,11 +101,13 @@ if __name__ == "__main__": ...@@ -101,11 +101,13 @@ if __name__ == "__main__":
plotdict = {"colormap": "Planck-like"} plotdict = {"colormap": "Planck-like"}
plot_space = ift.RGSpace((N_pixels_1, N_pixels_2)) 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', ift.plot(ift.Field(plot_space, val=ht(mock_signal).val),
**plotdict) 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=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=m.val), name='map.png', **plotdict)
# sampling the uncertainty map # sampling the uncertainty map
mean, variance = ift.probe_with_posterior_samples(wiener_curvature, ht, 10) 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=ift.sqrt(variance).val),
ift.plot(ift.Field(plot_space, val=(mean+m).val), name="posterior_mean.png", **plotdict) 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__": ...@@ -38,7 +38,8 @@ if __name__ == "__main__":
R = ift.GeometryRemover(signal_space) R = ift.GeometryRemover(signal_space)
R = R*ift.DiagonalOperator(mask) R = R*ift.DiagonalOperator(mask)
R = R*ht 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] data_domain = R.target[0]
noiseless_data = R(mock_signal) noiseless_data = R(mock_signal)
......
...@@ -85,5 +85,5 @@ if __name__ == "__main__": ...@@ -85,5 +85,5 @@ if __name__ == "__main__":
# try to do the same with diagonal probing # try to do the same with diagonal probing
variance = ift.probe_diagonal(ht*curv.inverse*ht.adjoint, 100) variance = ift.probe_diagonal(ht*curv.inverse*ht.adjoint, 100)
#sm = ift.FFTSmoothingOperator(s_space, sigma=0.005) # sm = ift.FFTSmoothingOperator(s_space, sigma=0.015)
ift.plot(variance, name="posterior_variance2.png", **plotdict2) ift.plot(variance, name="posterior_variance2.png", **plotdict)
This diff is collapsed.
rm -rf docs/build docs/source/mod 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/ 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 ...@@ -22,14 +22,16 @@ from .structured_domain import StructuredDomain
class GLSpace(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 Parameters
---------- ----------
nlat : int nlat : int
Number of latitudinal bins (or rings) that are used for this Number of latitudinal bins (or rings) that are used for this
pixelization. pixelization.
nlon : int, *optional* nlon : int, optional
Number of longitudinal bins that are used for this pixelization. Number of longitudinal bins that are used for this pixelization.
Default value is 2*nlat + 1. Default value is 2*nlat + 1.
...@@ -37,19 +39,6 @@ class GLSpace(StructuredDomain): ...@@ -37,19 +39,6 @@ class GLSpace(StructuredDomain):
------ ------
ValueError ValueError
If input `nlat` or `nlon` is invalid. 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): def __init__(self, nlat, nlon=None):
......
...@@ -24,14 +24,14 @@ from .. import dobj ...@@ -24,14 +24,14 @@ from .. import dobj
class PowerSpace(StructuredDomain): class PowerSpace(StructuredDomain):
"""NIFTy class for spaces of power spectra. """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. k-modes of equal length get mapped to one power index.
Parameters Parameters
---------- ----------
harmonic_partner : Space harmonic_partner : StructuredDomain
The harmonic Space of which this is the power space. The harmonic dmain of which this is the power space.
binbounds: None, or tuple/array/list of float binbounds : None, or tuple of float
if None: if None:
There will be as many bins as there are distinct k-vector lengths There will be as many bins as there are distinct k-vector lengths
in the harmonic partner space. in the harmonic partner space.
...@@ -54,9 +54,9 @@ class PowerSpace(StructuredDomain): ...@@ -54,9 +54,9 @@ class PowerSpace(StructuredDomain):
binbounds[0]=first_bound and binbounds[-1]=last_bound and the remaining binbounds[0]=first_bound and binbounds[-1]=last_bound and the remaining
values equidistantly spaced (in linear scale) between these two. values equidistantly spaced (in linear scale) between these two.
nbin: integer nbin : int
the number of bins 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 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 boundary of the last bin, respectively. They are given in length
units of the harmonic partner space. units of the harmonic partner space.
...@@ -74,9 +74,9 @@ class PowerSpace(StructuredDomain): ...@@ -74,9 +74,9 @@ class PowerSpace(StructuredDomain):
values equidistantly spaced (in natural logarithmic scale) values equidistantly spaced (in natural logarithmic scale)
between these two. between these two.
nbin: integer nbin : int
the number of bins 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 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 boundary of the last bin, respectively. They are given in length
units of the harmonic partner space. units of the harmonic partner space.
......
...@@ -30,16 +30,16 @@ class RGSpace(StructuredDomain): ...@@ -30,16 +30,16 @@ class RGSpace(StructuredDomain):
Parameters Parameters
---------- ----------
shape : {int, numpy.ndarray} shape : int or tuple of int
Number of grid points or numbers of gridpoints along each axis. 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 Distance between two grid points along each axis
(default: None). (default: None).
If distances==None: If distances==None:
if harmonic==True, all distances will be set to 1 if harmonic==True, all distances will be set to 1
if harmonic==False, the distance along each axis will be if harmonic==False, the distance along each axis will be
set to the inverse of the number of points along that axis. 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. Whether the space represents a grid in position or harmonic space.
(default: False). (default: False).
""" """
......
...@@ -354,7 +354,7 @@ class Field(object): ...@@ -354,7 +354,7 @@ class Field(object):
Returns Returns
------- -------
Field: Field
The complex conjugated field. The complex conjugated field.
""" """
return Field(self._domain, self.val.conjugate()) return Field(self._domain, self.val.conjugate())
......
...@@ -34,33 +34,34 @@ class CriticalPowerEnergy(Energy): ...@@ -34,33 +34,34 @@ class CriticalPowerEnergy(Energy):
Parameters Parameters
---------- ----------
position : Field, position : Field
The current position of this energy. (Logarithm of power spectrum) 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 The map whose power spectrum is inferred. Needs to live in harmonic
signal space. signal space.
D : EndomorphicOperator, D : EndomorphicOperator, optional
The curvature of the Gaussian encoding the posterior covariance. The curvature of the Gaussian encoding the posterior covariance.
If not specified, the map is assumed to be no reconstruction. If not specified, the map is assumed to be no reconstruction.
default : None default : None
alpha : float alpha : float, optional
The spectral prior of the inverse gamma distribution. 1.0 corresponds The spectral prior of the inverse gamma distribution. 1.0 corresponds
to non-informative. to non-informative.
default : 1.0 default : 1.0
q : float q : float, optional
The cutoff parameter of the inverse gamma distribution. 0.0 corresponds The cutoff parameter of the inverse gamma distribution. 0.0 corresponds
to non-informative. to non-informative.
default : 0.0 default : 0.0
smoothness_prior : float smoothness_prior : float, optional
Controls the strength of the smoothness prior Controls the strength of the smoothness prior
default : 0.0 default : 0.0
logarithmic : boolean logarithmic : bool, optional
Whether smoothness acts on linear or logarithmic scale. 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 Number of samples used for the estimation of the uncertainty
corrections. corrections.
default : 3 default : 3
w : Field w : Field, optional
The contribution from the map with or without uncertainty. It is used The contribution from the map with or without uncertainty. It is used
to pass on the result of the costly sampling during the minimization. to pass on the result of the costly sampling during the minimization.
default : None default : None
......
...@@ -34,18 +34,18 @@ class NonlinearPowerEnergy(Energy): ...@@ -34,18 +34,18 @@ class NonlinearPowerEnergy(Energy):
Parameters Parameters
---------- ----------
position : Field, position : Field
The current position of this energy. The current position of this energy.
m : Field, m : Field
The map whichs power spectrum has to be inferred The map whichs power spectrum has to be inferred
D : EndomorphicOperator, D : EndomorphicOperator
The curvature of the Gaussian encoding the posterior covariance. The curvature of the Gaussian encoding the posterior covariance.
If not specified, the map is assumed to be no reconstruction. If not specified, the map is assumed to be no reconstruction.
default : None default : None
sigma : float sigma : float
The parameter of the smoothness prior. The parameter of the smoothness prior.
default : ??? None? ??????? default : ??? None? ???????
samples : integer samples : int
Number of samples used for the estimation of the uncertainty Number of samples used for the estimation of the uncertainty
corrections. corrections.
default : 3 default : 3
......
...@@ -56,9 +56,9 @@ class ConjugateGradient(Minimizer): ...@@ -56,9 +56,9 @@ class ConjugateGradient(Minimizer):
Returns Returns
------- -------
energy : QuadraticEnergy QuadraticEnergy
state at last point of the iteration state at last point of the iteration
status : integer int
Can be controller.CONVERGED or controller.ERROR Can be controller.CONVERGED or controller.ERROR
""" """
controller = self._controller controller = self._controller
......
...@@ -50,15 +50,15 @@ class DescentMinimizer(Minimizer): ...@@ -50,15 +50,15 @@ class DescentMinimizer(Minimizer):
Parameters Parameters
---------- ----------
energy : Energy object nergy : Energy
Energy object which provides value, gradient and curvature at a Energy object which provides value, gradient and curvature at a
specific position in parameter space. specific position in parameter space.
Returns