Commit 82a92a51 authored by Theo Steininger's avatar Theo Steininger

Merge branch 'sphinx_docs' into 'master'

Sphinx docs

See merge request !140
parents 4efa0f58 3681524e
Pipeline #13049 passed with stages
in 11 minutes and 19 seconds
Two step creation of webpages:
sphinx-apidoc -l -e -d 3 -o sphinx/source/mod/ nifty/ nifty/plotting/ nifty/spaces/power_space/power_indices.py nifty/spaces/power_space/power_index_factory.py nifty/config/ nifty/basic_arithmetics.py nifty/nifty_meta.py nifty/random.py nifty/version.py nifty/field_types/ nifty/operators/fft_operator/transformations/rg_transforms.py
creates all .rst files neccesary for ModuleIndex excluding helper modules
sphinx-build -b html sphinx/source/ sphinx/build/
generates html filel amd build directory
/* override table width restrictions */
.wy-nav-content {
max-width: none;
}
{% extends "!layout.html" %}
{% block extrahead %}
<link href="{{ pathto("_static/style.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}
......@@ -16,7 +16,6 @@ from nifty import *
import sys
import os
import sphinx_rtd_theme
......@@ -89,9 +88,9 @@ author = u'Theo Steininger'
# built documents.
#
# The short X.Y version.
version = u'3.0.4'
version = u'3.0'
# The full version, including alpha/beta/rc tags.
release = u'3.0.x'
release = u'3.0.4'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -142,34 +141,20 @@ todo_include_todos = True
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'collapse_navigation': False,
'display_version': False,
'navigation_depth': 3,
'collapse_navigation': False,
'display_version': False,
'navigation_depth': 3,
}
#html_theme = 'alabaster'
#html_theme_options = {
# 'page_width':''
#}
#html_theme = 'classic'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
......@@ -215,7 +200,7 @@ html_last_updated_fmt = '%b %d, %Y'
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
html_domain_indices = False
# If false, no index is generated.
#html_use_index = True
......@@ -340,4 +325,4 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'https://docs.python.org/': None}
#intersphinx_mapping = {'https://docs.python.org/': None}
\ No newline at end of file
......@@ -10,8 +10,3 @@ In NIFTY, Fields are used to store data arrays and carry all the needed metainfo
.. autoclass:: Field
:show-inheritance:
:members:
.. rubric:: Methods
.. autoautosummary:: Field
:methods:
Image Gallery
-------------
Transformations & Projections
.............................
.. currentmodule:: nifty
The "Faraday Map" [1]_ in spherical representation on a :py:class:`hp_space` and a :py:class:`gl_space`, their quadrupole projections, the uncertainty of the map, and the angular power spectrum.
+----------------------------+----------------------------+
| .. image:: images/f_00.png | .. image:: images/f_01.png |
| :width: 90 % | :width: 90 % |
+----------------------------+----------------------------+
| .. image:: images/f_02.png | .. image:: images/f_03.png |
| :width: 90 % | :width: 90 % |
+----------------------------+----------------------------+
| .. image:: images/f_04.png | .. image:: images/f_05.png |
| :width: 90 % | :width: 70 % |
+----------------------------+----------------------------+
Gaussian random fields
......................
Statistically homogeneous and isotropic Gaussian random fields drawn from different power spectra.
+----------------------------+----------------------------+
| .. image:: images/t_03.png | .. image:: images/t_04.png |
| :width: 60 % | :width: 70 % |
+----------------------------+----------------------------+
| .. image:: images/t_05.png | .. image:: images/t_06.png |
| :width: 60 % | :width: 70 % |
+----------------------------+----------------------------+
Wiener filtering I
..................
Wiener filter reconstruction of Gaussian random signal.
+--------------------------------+--------------------------------+--------------------------------+
| original signal | noisy data | reconstruction |
+================================+================================+================================+
| .. image:: images/rg1_s.png | .. image:: images/rg1_d.png | .. image:: images/rg1_m.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+--------------------------------+--------------------------------+--------------------------------+
| .. image:: images/rg2_s_pm.png | .. image:: images/rg2_d_pm.png | .. image:: images/rg2_m_pm.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+--------------------------------+--------------------------------+--------------------------------+
| .. image:: images/hp_s.png | .. image:: images/hp_d.png | .. image:: images/hp_m.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+--------------------------------+--------------------------------+--------------------------------+
Image reconstruction
....................
Image reconstruction of the classic "Moon Surface" image. The original image "Moon Surface" was taken from the `USC-SIPI image database <http://sipi.usc.edu/database/>`_.
+-----------------------------------+-----------------------------------+-----------------------------------+
| .. image:: images/moon_s.png | .. image:: images/moon_d.png | .. image:: images/moon_m.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+-----------------------------------+-----------------------------------+-----------------------------------+
| .. image:: images/moon_kernel.png | .. image:: images/moon_mask.png | .. image:: images/moon_sigma.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+-----------------------------------+-----------------------------------+-----------------------------------+
Wiener filtering II
...................
Wiener filter reconstruction results for the full and partially blinded data. Shown are the original signal (orange), the reconstruction (green), and :math:`1\sigma`-confidence interval (gray).
+--------------------------------------+--------------------------------------+
| noisy data | reconstruction results |
+======================================+======================================+
| .. image:: images/rg1_d.png | .. image:: images/rg1_m_err_.png |
| :width: 90 % | :width: 90 % |
+--------------------------------------+--------------------------------------+
| .. image:: images/rg1_d_gap.png | .. image:: images/rg1_m_gap_err_.png |
| :width: 90 % | :width: 90 % |
+--------------------------------------+--------------------------------------+
D\ :sup:`3`\ PO -- Denoising, Deconvolving, and Decomposing Photon Observations
...............................................................................
Application of the D\ :sup:`3`\ PO algorithm [2]_ showing the raw photon count data and the denoised, deconvolved, and decomposed reconstruction of the diffuse photon flux.
+--------------------------------------+--------------------------------------+
| .. image:: images/D3PO_data.png | .. image:: images/D3PO_diffuse.png |
| :width: 95 % | :width: 95 % |
+--------------------------------------+--------------------------------------+
RESOLVE -- Aperature synthesis imaging in radio astronomy
.........................................................
Signal inference on simulated single-frequency data: reconstruction by CLEAN (using uniform weighting) and by RESOLVE [3]_ (using IFT & NIFTY).
+-------------------------------------+-------------------------------------+-------------------------------------+
| .. image:: images/radio_signal.png | .. image:: images/radio_CLEAN.png | .. image:: images/radio_RESOLVE.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+-------------------------------------+-------------------------------------+-------------------------------------+
D\ :sup:`3`\ PO -- light
........................
Inference of the mock distribution of some species across Australia exploiting geospatial correlations in a (strongly) simplified scenario [4]_.
+--------------------------------+--------------------------------+--------------------------------+
| .. image:: images/au_data.png | .. image:: images/au_map.png | .. image:: images/au_error.png |
| :width: 90 % | :width: 90 % | :width: 90 % |
+--------------------------------+--------------------------------+--------------------------------+
NIFTY meets Lensing
...................
Signal reconstruction for a simulated image that has undergone strong gravitational lensing. Without *a priori* knowledge of the signal covariance :math:`S`, a common approach rescaling the `Laplace-Operator <http://de.wikipedia.org/wiki/Laplace-Operator>`_ and IFT's `"critical" filter <./demo_excaliwir.html#critical-wiener-filtering>`_ are compared.
+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
| .. image:: images/lens_s0.png | .. image:: images/lens_d0.png | .. image:: images/lens_m1.png | .. image:: images/lens_m2.png |
| :width: 80 % | :width: 80 % | :width: 80 % | :width: 80 % |
| | | | |
| | | .. math:: | .. math:: |
| | | S(x,y) &= | S(x,y) &= |
| | | \lambda \: \Delta^{-1} | S(|x-y|) |
| | | \\ \equiv | \\ \equiv |
| | | S(k,l) &= \delta(k-l) | S(k,l) &= \delta(k-l) |
| | | \: \lambda \: k^{-2} | \: P(k) |
+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
.. [1] N. Oppermann et. al., "An improved map of the Galactic Faraday sky", Astronomy & Astrophysics, vol. 542, id. A93, p. 14, see also the `project homepage <http://www.mpa-garching.mpg.de/ift/faraday/>`_
.. [2] M. Selig et. al., "Denoising, Deconvolving, and Decomposing Photon Observations", submitted to Astronomy & Astrophysics, 2013; `arXiv:1311.1888 <http://www.arxiv.org/abs/1311.1888>`_
.. [3] H. Junklewitz et. al., "RESOLVE: A new algorithm for aperture synthesis imaging of extended emission in radio astronomy", submitted to Astronomy & Astrophysics, 2013; `arXiv:1311.5282 <http://www.arxiv.org/abs/1311.5282>`_
.. [4] M. Selig, "The NIFTY way of Bayesian signal inference", submitted proceeding of the 33rd MaxEnt, 2013
IFT -- Information Field Theory
===============================
Theoretical Background
----------------------
`Information Field Theory <http://www.mpa-garching.mpg.de/ift/>`_ [1]_ (IFT) is information theory, the logic of reasoning under uncertainty, applied to fields. A field can be any quantity defined over some space, e.g. the air temperature over Europe, the magnetic field strength in the Milky Way, or the matter density in the Universe. IFT describes how data and knowledge can be used to infer field properties. Mathematically it is a statistical field theory and exploits many of the tools developed for such. Practically, it is a framework for signal processing and image reconstruction.
IFT is fully Bayesian. How else can infinitely many field degrees of freedom be constrained by finite data?
It can be used without the knowledge of Feynman diagrams. There is a full toolbox of methods. It reproduces many known well working algorithms. This should be reassuring. And, there were certainly previous works in a similar spirit. Anyhow, in many cases IFT provides novel rigorous ways to extract information from data.
.. tip:: An *in-a-nutshell introduction to information field theory* can be found in [2]_.
.. [1] T. Ensslin et al., "Information field theory for cosmological perturbation reconstruction and nonlinear signal analysis", PhysRevD.80.105005, 09/2009; `arXiv:0806.3474 <http://www.arxiv.org/abs/0806.3474>`_
.. [2] T. Ensslin, "Information field theory", accepted for the proceedings of MaxEnt 2012 -- the 32nd International Workshop on Bayesian Inference and Maximum Entropy Methods in Science and Engineering; `arXiv:1301.2556 <http://arxiv.org/abs/1301.2556>`_
Discretized continuum
---------------------
The representation of fields that are mathematically defined on a continuous space in a finite computer environment is a common necessity. The goal hereby is to preserve the continuum limit in the calculus in order to ensure a resolution independent discretization.
+-----------------------------+-----------------------------+
| .. image:: images/42vs6.png | .. image:: images/42vs9.png |
| :width: 100 % | :width: 100 % |
+-----------------------------+-----------------------------+
Any partition of the continuous position space :math:`\Omega` (with volume :math:`V`) into a set of :math:`Q` disjoint, proper subsets :math:`\Omega_q` (with volumes :math:`V_q`) defines a pixelization,
.. math::
\Omega &\quad=\quad \dot{\bigcup_q} \; \Omega_q \qquad \mathrm{with} \qquad q \in \{1,\dots,Q\} \subset \mathbb{N}
, \\
V &\quad=\quad \int_\Omega \mathrm{d}x \quad=\quad \sum_{q=1}^Q \int_{\Omega_q} \mathrm{d}x \quad=\quad \sum_{q=1}^Q V_q
.
Here the number :math:`Q` characterizes the resolution of the pixelization and the continuum limit is described by :math:`Q \rightarrow \infty` and :math:`V_q \rightarrow 0` for all :math:`q \in \{1,\dots,Q\}` simultaneously. Moreover, the above equation defines a discretization of continuous integrals, :math:`\int_\Omega \mathrm{d}x \mapsto \sum_q V_q`.
Any valid discretization scheme for a field :math:`{s}` can be described by a mapping,
.. math::
s(x \in \Omega_q) \quad\mapsto\quad s_q \quad=\quad \int_{\Omega_q} \mathrm{d}x \; w_q(x) \; s(x)
,
if the weighting function :math:`w_q(x)` is chosen appropriately. In order for the discretized version of the field to converge to the actual field in the continuum limit, the weighting functions need to be normalized in each subset; i.e., :math:`\forall q: \int_{\Omega_q} \mathrm{d}x \; w_q(x) = 1`. Choosing such a weighting function that is constant with respect to :math:`x` yields
.. math::
s_q = \frac{\int_{\Omega_q} \mathrm{d}x \; s(x)}{\int_{\Omega_q} \mathrm{d}x} = \left< s(x) \right>_{\Omega_q}
,
which corresponds to a discretization of the field by spatial averaging. Another common and equally valid choice is :math:`w_q(x) = \delta(x-x_q)`, which distinguishes some position :math:`x_q \in \Omega_q`, and evaluates the continuous field at this position,
.. math::
s_q \quad=\quad \int_{\Omega_q} \mathrm{d}x \; \delta(x-x_q) \; s(x) \quad=\quad s(x_q)
.
In practice, one often makes use of the spatially averaged pixel position, :math:`x_q = \left< x \right>_{\Omega_q}`. If the resolution is high enough to resolve all features of the signal field :math:`{s}`, both of these discretization schemes approximate each other, :math:`\left< s(x) \right>_{\Omega_q} \approx s(\left< x \right>_{\Omega_q})`, since they approximate the continuum limit by construction. (The approximation of :math:`\left< s(x) \right>_{\Omega_q} \approx s(x_q \in \Omega_q)` marks a resolution threshold beyond which further refinement of the discretization reveals no new features; i.e., no new information content of the field :math:`{s}`.)
All operations involving position integrals can be normalized in accordance with the above definitions. For example, the scalar product between two fields :math:`{s}` and :math:`{u}` is defined as
.. math::
{s}^\dagger {u} \quad=\quad \int_\Omega \mathrm{d}x \; s^*(x) \; u(x) \quad\approx\quad \sum_{q=1}^Q V_q^{\phantom{*}} \; s_q^* \; u_q^{\phantom{*}}
,
where :math:`\dagger` denotes adjunction and :math:`*` complex conjugation. Since the above approximation becomes an equality in the continuum limit, the scalar product is independent of the pixelization scheme and resolution, if the latter is sufficiently high.
The above line of argumentation analogously applies to the discretization of operators. For a linear operator :math:`{A}` acting on some field :math:`{s}` as :math:`{A} {s} = \int_\Omega \mathrm{d}y \; A(x,y) \; s(y)`, a matrix representation discretized with constant weighting functions is given by
.. math::
A(x \in \Omega_p, y \in \Omega_q) \quad\mapsto\quad A_{pq} \quad=\quad \frac{\iint_{\Omega_p \Omega_q} \mathrm{d}x \, \mathrm{d}y \; A(x,y)}{\iint_{\Omega_p \Omega_q} \mathrm{d}x \, \mathrm{d}y} \quad=\quad \big< \big< A(x,y) \big>_{\Omega_p} \big>_{\Omega_q}
.
The proper discretization of spaces, fields, and operators, as well as the normalization of position integrals, is essential for the conservation of the continuum limit. Their consistent implementation in NIFTY allows a pixelization independent coding of algorithms.
......@@ -23,9 +23,12 @@ Contents
.. toctree::
:maxdepth: 1
spaces
operator
minimization
gallery
ift
start
spaces/spaces
operators/operator
minimizer/minimization
field
......@@ -33,6 +36,5 @@ Indices and tables
..................
* :ref:`genindex`
* :ref:`modindex`
* :any:`Module Index <mod/modules>`
* :ref:`search`
.. currentmodule:: nifty
The ``ConjugateGradient`` class -- Minimization routine
.......................................................
.. autoclass:: ConjugateGradient
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``DescentMinimizer`` class -- The Base class for minimizers
...............................................................
.. autoclass:: DescentMinimizer
:show-inheritance:
:members:
Minimization
------------
NIFTY provides several minimization routines.
.. toctree::
:maxdepth: 1
conjugate_gradient
descent_minimizer
.. currentmodule:: nifty
The ``ComposedOperator`` class -- NIFTY class for composed operators
....................................................................
.. autoclass:: ComposedOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``DiagonalOperator`` class -- NIFTY class for diagonal operators
....................................................................
.. autoclass:: DiagonalOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``EndomorphicOperator`` class -- ...
........................................
.. autoclass:: EndomorphicOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``FFTOperator`` class -- Transforms between a pair of position and harmonic domains
.......................................................................................
.. autoclass:: FFTOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``InvertibleOperatorMixin`` class -- Mixin class to invert implicit defined operators
.........................................................................................
.. autoclass:: InvertibleOperatorMixin
:show-inheritance:
:members:
Operators
=========
Operators perform some operation on a given field. In practice an operator can
take the form of an explicit matrix (e.g. stored in a Numpy array) or it may be
implicitly defined as a function (e.g. an FFT operation would not be encoded in
a matrix, but performed using an FFT routine). NIFTY includes a framework for
handling arbitrary operators, and basic methods for manipulating these
operators. Common functions like taking traces and extracting diagonals are
provided.
In order to have a blueprint for operators capable of handling fields, any
application of operators is split into a general and a concrete part. The
general part comprises the correct involvement of normalizations and
transformations, necessary for any operator type, while the concrete part is
unique for each operator subclass. In analogy to the field class, any operator
instance has a set of properties that specify its domain and target as well as
some additional flags.
Operator classes
----------------
NIFTY provides a base class for defining operators, as well as several pre-implemented operator types that are very often needed for signal inference
algorithms.
.. toctree::
:maxdepth: 1
diagonal_operator
fft_operator
composed_operator
response_operator
smoothing_operator
projection_operator
propagator_operator
endomorphic_operator
invertible_operator_mixin
transformations
.. currentmodule:: nifty
The ``LinearOperator`` class -- The base Operator Object
--------------------------------------------------------
.. autoclass:: LinearOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``ProjectionOperator`` class -- NIFTY class for projection operators
........................................................................
.. autoclass:: ProjectionOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``PropagatorOperator`` class -- NIFTY Propagator Operator D
...............................................................
.. autoclass:: PropagatorOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``ResponseOperator`` class -- NIFTy ResponseOperator (example)
..................................................................
.. autoclass:: ResponseOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``SmoothingOperator`` class -- NIFTY class for smoothing operators
......................................................................
.. autoclass:: SmoothingOperator
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``GLSpace`` class -- Gauss-Legendre pixelization of the sphere
..................................................................
.. autoclass:: GLSpace
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``GLLMTransformation`` class -- A transformation routine
............................................................
.. autoclass:: GLLMTransformation
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``HPSpace`` class -- HEALPix discretization of the sphere
.............................................................
.. autoclass:: HPSpace
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``HPLMTransformation`` class -- A transformation routine
............................................................
.. autoclass:: HPLMTransformation
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``LMSpace`` class -- Spherical Harmonics components
.......................................................
.. autoclass:: LMSpace
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``LMGLTransformation`` class -- A transformation routine
............................................................
.. autoclass:: LMGLTransformation
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``LMHPTransformation`` class -- A transformation routine
............................................................
.. autoclass:: LMHPTransformation
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``PowerSpace`` class -- NIFTY class for spaces of power spectra
....................................................................
.. autoclass:: PowerSpace
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``RGSpace`` class -- Regular Cartesian grids
................................................
.. autoclass:: RGSpace
:show-inheritance:
:members:
.. currentmodule:: nifty
The ``RGRGTransformation`` class -- A transformation routine
............................................................
.. autoclass:: RGRGTransformation
:show-inheritance:
:members:
Spaces
======
The :py:class:`Space` classes of NIFTY represent geometrical spaces approximated by grids in the computer environment. Each subclass of the base class corresponds to a specific grid type and replaces some of the inherited methods with its own methods that are unique to the respective grid. This framework ensures an abstract handling of spaces independent of the underlying geometrical grid and the grid's resolution.
Each instance of a :py:class:`Space` needs to capture all structural and dimensional specifics of the grid and all computationally relevant quantities such as the data type of associated field values. These parameters are stored as properties of an instance of the class at its initialization, and they do not need to be accessed explicitly by the user thereafter. This prevents the writing of grid or resolution dependent code.
Spatial symmetries of a system can be exploited by corresponding coordinate transformations. Often, transformations from one basis to its harmonic counterpart can greatly reduce the computational complexity of algorithms. The harmonic basis is defined by the eigenbasis of the Laplace operator; e.g., for a flat position space it is the Fourier basis. This conjugation of bases is implemented in NIFTY by distinguishing conjugate space classes, which can be obtained by the instance method *get_codomain* (and checked for by *check_codomain*). Moreover, transformations between conjugate spaces are performed automatically if required.
Space classes
-------------
Next to the generic :py:class:`Space` class, NIFTY has implementations of five subclasses, representing specific geometrical spaces and their discretizations.
.. toctree::
:maxdepth: 1
rg_space
hp_space
gl_space
lm_space
power_space
transformations
.. currentmodule:: nifty