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

doc tweaks

parent 0193c903
...@@ -6,7 +6,7 @@ NIFTy's domain classes ...@@ -6,7 +6,7 @@ NIFTy's domain classes
**Abstract base class** **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:: .. toctree::
:maxdepth: 1 :maxdepth: 1
...@@ -21,7 +21,7 @@ associated with them, like position in space and volume factors), ...@@ -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). or *unstructured* (meaning that the data points have no associated manifold).
Unstructured domains can be described by instances of NIFTy's Unstructured domains can be described by instances of NIFTy's
:py:class:`UnstructuredDomain` class. :class:`UnstructuredDomain` class.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
...@@ -34,24 +34,24 @@ Unstructured domains can be described by instances of NIFTy's ...@@ -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. In contrast to unstructured domains, these domains have an assigned geometry.
NIFTy requires these domains to provide the volume elements of their grid cells. NIFTy requires these domains to provide the volume elements of their grid cells.
The additional methods are described in the abstract class The additional methods are described in the abstract class
:py:class:`StructuredDomain`. :class:`StructuredDomain`.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
StructuredDomain <../mod/nifty4.domains.structured_domain> 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. number of dimensions, which is supposed to be periodic in each dimension.
This domain can be constructed to represent either position or harmonic space. This domain can be constructed to represent either position or harmonic space.
:py:class:`HPSpace` and :py:class:`GLSpace` describe pixelisations of the :class:`HPSpace` and :class:`GLSpace` describe pixelisations of the
2-sphere; their counterpart in harmonic space is :py:class:`LMSpace`, which 2-sphere; their counterpart in harmonic space is :class:`LMSpace`, which
contains spherical harmonic coefficients. 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:: .. toctree::
:maxdepth: 1 :maxdepth: 1
......
...@@ -52,16 +52,12 @@ extensions = [ ...@@ -52,16 +52,12 @@ extensions = [
'numpydoc', 'numpydoc',
'sphinx.ext.autosummary', 'sphinx.ext.autosummary',
'sphinx.ext.napoleon', 'sphinx.ext.napoleon',
'sphinx.ext.coverage', # 'sphinx.ext.coverage',
'sphinx.ext.todo', # 'sphinx.ext.todo',
'sphinx.ext.mathjax', 'sphinx.ext.mathjax',
'sphinx.ext.viewcode' 'sphinx.ext.viewcode'
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
......
NIFTy -- Numerical Information Field Theory 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. 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. 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. 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. 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. 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 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>`_ .. [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>`_
Documentation
-------------
Welcome to NIFTy's documentation!
Contents Contents
........ ........
......
...@@ -2,7 +2,7 @@ Installation ...@@ -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. distributions, the "apt" lines will need slight changes.
NIFTy4 and its mandatory dependencies can be installed via:: NIFTy4 and its mandatory dependencies can be installed via::
...@@ -19,7 +19,7 @@ Plotting support is added via:: ...@@ -19,7 +19,7 @@ Plotting support is added via::
pip install --user matplotlib 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 pip install --user git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
First steps -- An informal introduction First steps -- An informal introduction
======================================= =======================================
NIFTy4 Tutorial
---------------
.. currentmodule:: nifty4 .. currentmodule:: nifty4
.. automodule:: nifty4 .. automodule:: nifty4
...@@ -42,61 +39,61 @@ Domains ...@@ -42,61 +39,61 @@ Domains
....... .......
One of the fundamental building blocks of the NIFTy4 framework is the *domain*. 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: A domain must be able to answer the following queries:
- its total number of data entries (pixels) - its total number of data entries (pixels)
- the shape of the array that is supposed to hold them - 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 Unstructured domains
.................... ....................
There are domains (e.g. the data domain) which have no geometry associated to the individual data values. 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 In NIFTy4 they are represented by the :class:`UnstructuredDomain` class, which is derived from
:py:class:`Domain`. :class:`Domain`.
Structured domains 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 - methods :meth:`~StructuredDomain.scalar_dvol`, :meth:`~StructuredDomain.dvol`, and :meth:`~StructuredDomain.total_volume` returning the pixel volume(s) and the total volume
- a :py:attr:`harmonic` property - 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 - (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 Examples for structured domains are
- :py:class:`RGSpace` (an equidistant Cartesian grid with a user-definable number of dimensions), - :class:`RGSpace` (an equidistant Cartesian grid with a user-definable number of dimensions),
- :py:class:`GLSpace` (a Gauss-Legendre grid on the sphere), and - :class:`GLSpace` (a Gauss-Legendre grid on the sphere), and
- :py:class:`LMSpace` (a grid storing spherical harmonic coefficients). - :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 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). 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. The tuple of domain on which a field lives is described by the :class:`DomainTuple` class.
A :py:class:`DomainTuple` object can be constructed from 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) - a tuple of such instances (possibly empty)
- another :py:class:`DomainTuple` object - another :class:`DomainTuple` object
.. _fields: .. _fields:
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) - a data type (e.g. numpy.float64)
- an array containing the actual values - an array containing the actual values
...@@ -107,8 +104,8 @@ Fields support arithmetic operations, contractions, etc. ...@@ -107,8 +104,8 @@ Fields support arithmetic operations, contractions, etc.
Linear Operators Linear Operators
................ ................
A linear operator (represented by NIFTy4's abstract :py:class:`LinearOperator` class) can be interpreted as an (implicitly defined) matrix. A linear operator (represented by NIFTy4's abstract :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. 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`: 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 ...@@ -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; 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. 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*. 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`; Operators with identical domain and target can be derived from :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. 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. 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 X = A*B.inverse*A.adjoint + C
f2 = X(f1) f2 = X(f1)
...@@ -146,11 +143,11 @@ Minimization ...@@ -146,11 +143,11 @@ Minimization
Most problems in IFT are solved by (possibly nested) minimizations of high-dimensional functions, which are often nonlinear. 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. 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. 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. 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 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 ...@@ -24,34 +24,22 @@ from .. import dobj
class LMSpace(StructuredDomain): class LMSpace(StructuredDomain):
"""NIFTy subclass for spherical harmonics components, for representations """NIFTy subclass for sets of spherical harmonic coefficients.
of fields on the two-sphere.
Its harmonic partner spaces are :class:`HPSpace` and :class:`GLSpace`.
Parameters Parameters
---------- ----------
lmax : int lmax : int
The maximum :math:`l` value of any spherical harmonics The maximum :math:`l` value of any spherical harmonic coefficient
:math:`Y_{lm}` that is represented in this Space. :math:`a_{lm}` that is represented by this object.
Must be >=0. Must be :math:`\ge 0`.
mmax : int *optional* mmax : int, optional
The maximum :math:`m` value of any spherical harmonics The maximum :math:`m` value of any spherical harmonic coefficient
:math:`Y_{lm}` that is represented in this Space. :math:`a_{lm}` that is represented by this object.
If not supplied, it is set to lmax. If not supplied, it is set to `lmax`.
Must be >=0 and <=lmax. Must be :math:`\ge 0` and :math:`\le` `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>`_
""" """
def __init__(self, lmax, mmax=None): def __init__(self, lmax, mmax=None):
...@@ -122,14 +110,14 @@ class LMSpace(StructuredDomain): ...@@ -122,14 +110,14 @@ class LMSpace(StructuredDomain):
@property @property
def lmax(self): def lmax(self):
""" Returns the maximum :math:`l` value of any spherical harmonic """ 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 return self._lmax
@property @property
def mmax(self): def mmax(self):
""" Returns the maximum :math:`m` value of any spherical harmonic """ 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 return self._mmax
......
...@@ -35,7 +35,7 @@ class Field(object): ...@@ -35,7 +35,7 @@ class Field(object):
Parameters Parameters
---------- ----------
domain : None, DomainTuple, tuple(Domain), or Domain domain : None, DomainTuple, tuple of Domain, or Domain
val : None, Field, data_object, or scalar val : None, Field, data_object, or scalar
The values the array should contain after init. A scalar input will The values the array should contain after init. A scalar input will
...@@ -45,7 +45,7 @@ class Field(object): ...@@ -45,7 +45,7 @@ class Field(object):
dtype : type dtype : type
A numpy.type. Most common are float and complex. A numpy.type. Most common are float and complex.
copy: boolean copy: bool
""" """
def __init__(self, domain=None, val=None, dtype=None, copy=False): def __init__(self, domain=None, val=None, dtype=None, copy=False):
...@@ -143,7 +143,7 @@ class Field(object): ...@@ -143,7 +143,7 @@ class Field(object):
Parameters Parameters
---------- ----------
random_type : String random_type : str
'pm1', 'normal', 'uniform' are the supported arguments for this 'pm1', 'normal', 'uniform' are the supported arguments for this
method. method.
...@@ -155,7 +155,7 @@ class Field(object): ...@@ -155,7 +155,7 @@ class Field(object):
Returns Returns
------- -------
out : Field Field
The output object. The output object.
""" """
domain = DomainTuple.make(domain) domain = DomainTuple.make(domain)
...@@ -187,7 +187,8 @@ class Field(object): ...@@ -187,7 +187,8 @@ class Field(object):
Returns 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 return self._domain.shape
...@@ -199,8 +200,8 @@ class Field(object): ...@@ -199,8 +200,8 @@ class Field(object):
Returns Returns
------- -------
out : int int
The dimension of the Field. the dimension of the Field.
""" """
return self._domain.size return self._domain.size
...@@ -225,7 +226,7 @@ class Field(object): ...@@ -225,7 +226,7 @@ class Field(object):
Returns Returns
------- -------
out : Field Field
The output object. An identical copy of 'self'. The output object. An identical copy of 'self'.
""" """
return Field(val=self, copy=True) return Field(val=self, copy=True)
...@@ -263,7 +264,7 @@ class Field(object): ...@@ -263,7 +264,7 @@ class Field(object):
power : number power : number
The pixels get weighted with the volume-factor**power. 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. Determines on which subspace the operation takes place.
out : Field or None out : Field or None
...@@ -273,7 +274,7 @@ class Field(object): ...@@ -273,7 +274,7 @@ class Field(object):
Returns Returns
------- -------
out : Field Field
The weighted field. The weighted field.
""" """
if out is None: if out is None:
...@@ -313,13 +314,13 @@ class Field(object): ...@@ -313,13 +314,13 @@ class Field(object):
x : Field x : Field
x must live on the same domain as `self`. 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 The dot product is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains. tuple. If None, it is carried out over all sub-domains.
Returns Returns
------- -------
out : float, complex, either scalar (for full dot products) float, complex, either scalar (for full dot products)
or Field (for partial dot products) or Field (for partial dot products)
""" """
if not isinstance(x, Field): if not isinstance(x, Field):
...@@ -343,7 +344,7 @@ class Field(object): ...@@ -343,7 +344,7 @@ class Field(object):
Returns Returns
------- -------
norm : float float
The L2-norm of the field values. The L2-norm of the field values.
""" """
return np.sqrt(np.abs(self.vdot(x=self))) return np.sqrt(np.abs(self.vdot(x=self)))
...@@ -353,6 +354,7 @@ class Field(object): ...@@ -353,6 +354,7 @@ class Field(object):
Returns Returns
------- -------
Field:
The complex conjugated field. The complex conjugated field.
""" """
return Field(self._domain, self.val.conjugate()) return Field(self._domain, self.val.conjugate())
......
...@@ -34,8 +34,8 @@ def get_slice_list(shape, axes): ...@@ -34,8 +34,8 @@ def get_slice_list(shape, axes):
axes: tuple axes: tuple
Axes which should not be iterated over. Axes which should not be iterated over.
Returns Yields
------- ------
list list
The next list of indices and/or slice objects for each dimension. 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