Commit fd73e398 authored by Martin Reinecke's avatar Martin Reinecke

doc tweaks

parent 0193c903
......@@ -6,7 +6,7 @@ NIFTy's domain classes
**Abstract base class**
:py:class:`Domain` is the abstract ancestor for all of NIFTy's domains.
:class:`Domain` is the abstract ancestor for all of NIFTy's domains.
.. toctree::
:maxdepth: 1
......@@ -21,7 +21,7 @@ associated with them, like position in space and volume factors),
or *unstructured* (meaning that the data points have no associated manifold).
Unstructured domains can be described by instances of NIFTy's
:py:class:`UnstructuredDomain` class.
:class:`UnstructuredDomain` class.
.. toctree::
:maxdepth: 1
......@@ -34,24 +34,24 @@ Unstructured domains can be described by instances of NIFTy's
In contrast to unstructured domains, these domains have an assigned geometry.
NIFTy requires these domains to provide the volume elements of their grid cells.
The additional methods are described in the abstract class
:py:class:`StructuredDomain`.
:class:`StructuredDomain`.
.. toctree::
:maxdepth: 1
StructuredDomain <../mod/nifty4.domains.structured_domain>
NIFTy comes with several concrete subclasses of :py:class:`StructuredDomain`.
NIFTy comes with several concrete subclasses of :class:`StructuredDomain`.
:py:class:`RGSpace` represents a regular Cartesian grid with an arbitrary
:class:`RGSpace` represents a regular Cartesian grid with an arbitrary
number of dimensions, which is supposed to be periodic in each dimension.
This domain can be constructed to represent either position or harmonic space.
:py:class:`HPSpace` and :py:class:`GLSpace` describe pixelisations of the
2-sphere; their counterpart in harmonic space is :py:class:`LMSpace`, which
:class:`HPSpace` and :class:`GLSpace` describe pixelisations of the
2-sphere; their counterpart in harmonic space is :class:`LMSpace`, which
contains spherical harmonic coefficients.
:py:class:`PowerSpace` is used to describe one-dimensional power spectra.
:class:`PowerSpace` is used to describe one-dimensional power spectra.
.. toctree::
:maxdepth: 1
......
......@@ -52,16 +52,12 @@ extensions = [
'numpydoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.coverage',
'sphinx.ext.todo',
# 'sphinx.ext.coverage',
# 'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
NIFTy -- Numerical Information Field Theory
===========================================
**NIFTy** [1]_, "\ **N**\umerical **I**\nformation **F**\ield **T**\heor\ **y**\ ", is a versatile library designed to enable the development of signal inference algorithms that operate regardless of the underlying spatial grid and its resolution.
**NIFTy** [1]_, "\ **N**\umerical **I**\nformation **F**\ield **T**\heor\ **y**\ ", is a versatile library designed to enable the development of signal inference algorithms that are independent of the underlying spatial grid and its resolution.
Its object-oriented framework is written in Python, although it accesses libraries written in C++ and C for efficiency.
NIFTy offers a toolkit that abstracts discretized representations of continuous spaces, fields in these spaces, and operators acting on fields into classes.
Thereby, the correct normalization of operations on fields is taken care of automatically without concerning the user.
This allows for an abstract formulation and programming of inference algorithms, including those derived within information field theory.
Thus, NIFTy permits its user to rapidly prototype algorithms in 1D and then apply the developed code in higher-dimensional settings of real world problems.
Thus, NIFTy permits its user to rapidly prototype algorithms in 1D and then apply the developed code in higher-dimensional settings to real world problems.
The set of spaces on which NIFTy operates comprises point sets, *n*-dimensional regular grids, spherical spaces, their harmonic counterparts, and product spaces constructed as combinations of those.
References
----------
.. [1] Selig et al., "NIFTy -- Numerical Information Field Theory -- a versatile Python library for signal inference", `A&A, vol. 554, id. A26 <http://dx.doi.org/10.1051/0004-6361/201321236>`_, 2013; `arXiv:1301.4499 <http://www.arxiv.org/abs/1301.4499>`_
Documentation
-------------
Welcome to NIFTy's documentation!
.. [1] Steininger et al., "NIFTy 3 - Numerical Information Field Theory - A Python framework for multicomponent signal inference on HPC clusters", 2017, submitted to PLOS One; `[arXiv:1708.01073] <https://arxiv.org/abs/1708.01073>`_
Contents
........
......
......@@ -2,7 +2,7 @@ Installation
============
In the following, we assume a Debian-based distribution. For other
In the following, we assume a Debian-based Linux distribution. For other
distributions, the "apt" lines will need slight changes.
NIFTy4 and its mandatory dependencies can be installed via::
......@@ -19,7 +19,7 @@ Plotting support is added via::
pip install --user matplotlib
Support for spherical harmonic transforms is added via:
Support for spherical harmonic transforms is added via::
pip install --user git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
......
......@@ -3,9 +3,6 @@
First steps -- An informal introduction
=======================================
NIFTy4 Tutorial
---------------
.. currentmodule:: nifty4
.. automodule:: nifty4
......@@ -42,61 +39,61 @@ Domains
.......
One of the fundamental building blocks of the NIFTy4 framework is the *domain*.
Its required capabilities are expressed by the abstract :py:class:`Domain` class.
Its required capabilities are expressed by the abstract :class:`Domain` class.
A domain must be able to answer the following queries:
- its total number of data entries (pixels)
- the shape of the array that is supposed to hold them
- equality/inequality to another :py:class:`Domain` instance
- equality/inequality to another :class:`Domain` instance
Unstructured domains
....................
There are domains (e.g. the data domain) which have no geometry associated to the individual data values.
In NIFTy4 they are represented by the :py:class:`UnstructuredDomain` class, which is derived from
:py:class:`Domain`.
In NIFTy4 they are represented by the :class:`UnstructuredDomain` class, which is derived from
:class:`Domain`.
Structured domains
..................
All domains defined on a geometrical manifold are derived from :py:class:`StructuredDomain` (which is in turn derived from :py:class:`Domain`).
All domains defined on a geometrical manifold are derived from :class:`StructuredDomain` (which is in turn derived from :class:`Domain`).
In addition to the capabilities of :py:class:`Domain`, :py:class:`StructuredDomain` offers the following functionality:
In addition to the capabilities of :class:`Domain`, :class:`StructuredDomain` offers the following functionality:
- methods returing the pixel volume(s) and the total volume
- a :py:attr:`harmonic` property
- methods :meth:`~StructuredDomain.scalar_dvol`, :meth:`~StructuredDomain.dvol`, and :meth:`~StructuredDomain.total_volume` returning the pixel volume(s) and the total volume
- a :attr:`~StructuredDomain.harmonic` property
- (iff the domain is harmonic) some methods concerned with Gaussian convolution and the absolute distances of the individual grid cells from the origin
Examples for structured domains are
- :py:class:`RGSpace` (an equidistant Cartesian grid with a user-definable number of dimensions),
- :py:class:`GLSpace` (a Gauss-Legendre grid on the sphere), and
- :py:class:`LMSpace` (a grid storing spherical harmonic coefficients).
- :class:`RGSpace` (an equidistant Cartesian grid with a user-definable number of dimensions),
- :class:`GLSpace` (a Gauss-Legendre grid on the sphere), and
- :class:`LMSpace` (a grid storing spherical harmonic coefficients).
Among these, :py:class:`RGSpace` can be harmonic or not (depending on constructor arguments), :py:class:`GLSpace` is a pure position domain (i.e. nonharmonic), and :py:class:`LMSpace` is always harmonic.
Among these, :class:`RGSpace` can be harmonic or not (depending on constructor arguments), :class:`GLSpace` is a pure position domain (i.e. nonharmonic), and :class:`LMSpace` is always harmonic.
Combinations of domains
.......................
A field can live on a single domain, but it can also live on a product of domains (or no domain at all, in which case it is a scalar).
The tuple of domain on which a field lives is described by the :py:class:`DomainTuple` class.
A :py:class:`DomainTuple` object can be constructed from
The tuple of domain on which a field lives is described by the :class:`DomainTuple` class.
A :class:`DomainTuple` object can be constructed from
- a single instance of anything derived from :py:class:`Domain`
- a single instance of anything derived from :class:`Domain`
- a tuple of such instances (possibly empty)
- another :py:class:`DomainTuple` object
- another :class:`DomainTuple` object
.. _fields:
Fields
......
A :py:class:`Field` object consists of the following components:
A :class:`Field` object consists of the following components:
- a domain in form of a :py:class:`DomainTuple` object
- a domain in form of a :class:`DomainTuple` object
- a data type (e.g. numpy.float64)
- an array containing the actual values
......@@ -107,8 +104,8 @@ Fields support arithmetic operations, contractions, etc.
Linear Operators
................
A linear operator (represented by NIFTy4's abstract :py:class:`LinearOperator` class) can be interpreted as an (implicitly defined) matrix.
It can be applied to :py:class:`Field` instances, resulting in other :py:class:`Field` instances that potentially live on other domains.
A linear operator (represented by NIFTy4's abstract :class:`LinearOperator` class) can be interpreted as an (implicitly defined) matrix.
It can be applied to :class:`Field` instances, resulting in other :class:`Field` instances that potentially live on other domains.
There are four basic ways of applying an operator :math:`A` to a field :math:`f`:
......@@ -123,14 +120,14 @@ Operator classes defined in NIFTy may implement an arbitrary subset of these fou
If needed, the set of supported operations can be enhanced by iterative inversion methods;
for example, an operator defining direct and adjoint multiplication, could be enhanced to support the complete set by this method.
There are two domains associated with a :py:class:`LinearOperator`: a *domain* and a *target*.
There are two domains associated with a :class:`LinearOperator`: a *domain* and a *target*.
Direct multiplication and adjoint inverse multiplication transform a field living on the operator's *domain* to one living on the operator's *target*, whereas adjoint multiplication and inverse multiplication transform from *target* to *domain*.
Operators with identical domain and target can be derived from :py:class:`EndomorphicOperator`;
typical examples for this category are the :py:class:`ScalingOperator`, which simply multiplies its input by a scalar value, and :py:class:`DiagonalOperator`, which multiplies every value of its input field with potentially different values.
Operators with identical domain and target can be derived from :class:`EndomorphicOperator`;
typical examples for this category are the :class:`ScalingOperator`, which simply multiplies its input by a scalar value, and :class:`DiagonalOperator`, which multiplies every value of its input field with potentially different values.
Nifty4 allows simple and intuitive construction of combined operators.
As an example, if ``A``, ``B`` and ``C`` are of type :py:class:`LinearOperator` and ``f1`` and ``f2`` are :py:class:`Field` s, writing::
As an example, if ``A``, ``B`` and ``C`` are of type :class:`LinearOperator` and ``f1`` and ``f2`` are :class:`Field` s, writing::
X = A*B.inverse*A.adjoint + C
f2 = X(f1)
......@@ -146,11 +143,11 @@ Minimization
Most problems in IFT are solved by (possibly nested) minimizations of high-dimensional functions, which are often nonlinear.
In NIFTy4 such functions are represented by objects of type :py:class:`Energy`.
In NIFTy4 such functions are represented by objects of type :class:`Energy`.
These hold the prescription how to calculate the function's value, gradient and (optionally) curvature at any given position.
Function values are floating-point scalars, gradients have the form of fields living on the energy's position domain, and curvatures are represented by linear operator objects.
Some examples of concrete energy classes delivered with NIFTy4 are :py:class:`QuadraticEnergy` (with position-independent curvature, mainly used with conjugate gradient minimization) and :py:class:`WienerFilterEnergy`.
Some examples of concrete energy classes delivered with NIFTy4 are :class:`QuadraticEnergy` (with position-independent curvature, mainly used with conjugate gradient minimization) and :class:`WienerFilterEnergy`.
Energies are classes that typically have to be provided by the user when tackling new IFT problems.
The minimization procedure can be carried out by one of several algorithms; NIFTy4 currently ships solvers based on
......
......@@ -24,34 +24,22 @@ from .. import dobj
class LMSpace(StructuredDomain):
"""NIFTy subclass for spherical harmonics components, for representations
of fields on the two-sphere.
"""NIFTy subclass for sets of spherical harmonic coefficients.
Its harmonic partner spaces are :class:`HPSpace` and :class:`GLSpace`.
Parameters
----------
lmax : int
The maximum :math:`l` value of any spherical harmonics
:math:`Y_{lm}` that is represented in this Space.
Must be >=0.
mmax : int *optional*
The maximum :math:`m` value of any spherical harmonics
:math:`Y_{lm}` that is represented in this Space.
If not supplied, it is set to lmax.
Must be >=0 and <=lmax.
See Also
--------
HPSpace, GLSpace
References
----------
.. [#] 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.
.. [#] M. Reinecke and D. Sverre Seljebotn, 2013, "Libsharp - spherical
harmonic transforms revisited";
`arXiv:1303.4945 <http://www.arxiv.org/abs/1303.4945>`_
The maximum :math:`l` value of any spherical harmonic coefficient
:math:`a_{lm}` that is represented by this object.
Must be :math:`\ge 0`.
mmax : int, optional
The maximum :math:`m` value of any spherical harmonic coefficient
:math:`a_{lm}` that is represented by this object.
If not supplied, it is set to `lmax`.
Must be :math:`\ge 0` and :math:`\le` `lmax`.
"""
def __init__(self, lmax, mmax=None):
......@@ -122,14 +110,14 @@ class LMSpace(StructuredDomain):
@property
def lmax(self):
""" Returns the maximum :math:`l` value of any spherical harmonic
:math:`Y_{lm}` that is represented in this Space.
coefficient :math:`a_{lm}` that is represented in this Space.
"""
return self._lmax
@property
def mmax(self):
""" Returns the maximum :math:`m` value of any spherical harmonic
:math:`Y_{lm}` that is represented in this Space.
coefficient :math:`a_{lm}` that is represented in this Space.
"""
return self._mmax
......
......@@ -35,7 +35,7 @@ class Field(object):
Parameters
----------
domain : None, DomainTuple, tuple(Domain), or Domain
domain : None, DomainTuple, tuple of Domain, or Domain
val : None, Field, data_object, or scalar
The values the array should contain after init. A scalar input will
......@@ -45,7 +45,7 @@ class Field(object):
dtype : type
A numpy.type. Most common are float and complex.
copy: boolean
copy: bool
"""
def __init__(self, domain=None, val=None, dtype=None, copy=False):
......@@ -143,7 +143,7 @@ class Field(object):
Parameters
----------
random_type : String
random_type : str
'pm1', 'normal', 'uniform' are the supported arguments for this
method.
......@@ -155,7 +155,7 @@ class Field(object):
Returns
-------
out : Field
Field
The output object.
"""
domain = DomainTuple.make(domain)
......@@ -187,7 +187,8 @@ class Field(object):
Returns
-------
Integer tuple containing the dimensions of the spaces in domain.
tuple of int
the dimensions of the spaces in domain.
"""
return self._domain.shape
......@@ -199,8 +200,8 @@ class Field(object):
Returns
-------
out : int
The dimension of the Field.
int
the dimension of the Field.
"""
return self._domain.size
......@@ -225,7 +226,7 @@ class Field(object):
Returns
-------
out : Field
Field
The output object. An identical copy of 'self'.
"""
return Field(val=self, copy=True)
......@@ -263,7 +264,7 @@ class Field(object):
power : number
The pixels get weighted with the volume-factor**power.
spaces : tuple of ints
spaces : int or tuple of int
Determines on which subspace the operation takes place.
out : Field or None
......@@ -273,7 +274,7 @@ class Field(object):
Returns
-------
out : Field
Field
The weighted field.
"""
if out is None:
......@@ -313,13 +314,13 @@ class Field(object):
x : Field
x must live on the same domain as `self`.
spaces : None, int or tuple of ints (default: None)
spaces : None, int or tuple of int (default: None)
The dot product is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
out : float, complex, either scalar (for full dot products)
float, complex, either scalar (for full dot products)
or Field (for partial dot products)
"""
if not isinstance(x, Field):
......@@ -343,7 +344,7 @@ class Field(object):
Returns
-------
norm : float
float
The L2-norm of the field values.
"""
return np.sqrt(np.abs(self.vdot(x=self)))
......@@ -353,7 +354,8 @@ class Field(object):
Returns
-------
The complex conjugated field.
Field:
The complex conjugated field.
"""
return Field(self._domain, self.val.conjugate())
......
......@@ -34,8 +34,8 @@ def get_slice_list(shape, axes):
axes: tuple
Axes which should not be iterated over.
Returns
-------
Yields
------
list
The next list of indices and/or slice objects for each dimension.
......
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