Skip to content

Commit

Permalink
DOC: refined sphinx directives
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Jul 15, 2017
1 parent 67a8c2d commit f3502bc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
8 changes: 4 additions & 4 deletions docs/source/tutorials/baseline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Scikit-ued offers two ways of removing the background.
Iterative Baseline Determination using the Discrete Wavelet Transform
=====================================================================

The procedure and rational for the :code:`baseline_dwt` routine is described in detail in:
The procedure and rational for the :func:`baseline_dwt` routine is described in detail in:

Galloway et al. 'An Iterative Algorithm for Background Removal in Spectroscopy by Wavelet
Transforms', Applied Spectroscopy pp. 1370 - 1376, September 2009.
Expand Down Expand Up @@ -140,7 +140,7 @@ Here is a usage example for the data presented above::
Iterative Baseline Determination using the Dual-Tree Complex Wavelet Transform
==============================================================================

In the case of 1D data (or along a 1D axis), there is a more performant alternative to :code:`baseline_dwt`. The
In the case of 1D data (or along a 1D axis), there is a more performant alternative to :func:`baseline_dwt`. The
**dual-tree complex wavelet transform** improves on the discrete wavelet transform in many ways.
Therefore, the method presented in this section should be preferred.

Expand Down Expand Up @@ -201,7 +201,7 @@ Here is a usage example for the data presented above::
ax.legend()
plt.show()

The :code:`baseline_dt` routine will usually be more accurate than its :code:`baseline_dwt` counterpart.
However, :code:`baseline_dwt` can be applied to 1D and 2D data.
The :func:`baseline_dt` routine will usually be more accurate than its :func:`baseline_dwt` counterpart.
However, :func:`baseline_dwt` can be applied to 1D and 2D data.

:ref:`Return to Top <baseline_tutorial>`
22 changes: 11 additions & 11 deletions docs/source/tutorials/image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in-memory. In this case, it makes sense to assemble processing pipelines instead
of working on the data all at once.

Consider the following snippet to combine 50 images
from an iterable :code:`source`::
from an iterable :data:`source`::

import numpy as np

Expand All @@ -36,13 +36,13 @@ from an iterable :code:`source`::
avg = np.average(images, axis = 2)

If the :code:`source` iterable provided 1000 images, the above routine would
If the :data:`source` iterable provided 1000 images, the above routine would
not work on most machines. Moreover, what if we want to transform the images
one by one before averaging them? What about looking at the average while it
is being computed?

Scikit-ued provides some functions that can make streaming processing possible. These
function will have an 'i' prefix (for :code:`iterator`). Let's look at an example::
function will have an 'i' prefix (for :func:`iter`). Let's look at an example::

import numpy as np
from skued.image import ialign, iaverage
Expand All @@ -52,10 +52,10 @@ function will have an 'i' prefix (for :code:`iterator`). Let's look at an exampl
aligned = ialign(stream)
averaged = iaverage(aligned)

At this point, the generators :code:`map`, :code:`ialign`, and :code:`iaverage` are 'wired'
At this point, the generators :func:`map`, :func:`ialign`, and :func:`iaverage` are 'wired'
but will not compute anything until it is requested. We can use the function
:code:`last` to get at the final average, but we could also look at the average
step-by-step by calling :code:`next`::
:func:`last` to get at the final average, but we could also look at the average
step-by-step by calling :func:`next`::

from skued import last

Expand All @@ -81,7 +81,7 @@ memory usage; this allows the use of multiple processes in parallel::
Example: averaging with error
------------------------------

It is possible to combine :code:`iaverage` and :code:`isem` into a single stream using :code:`itertools.tee`.
It is possible to combine :func:`iaverage` and :func:`isem` into a single stream using :func:`itertools.tee`.
Here is a recipe for it::

def iaverage_with_error(images, weights):
Expand Down Expand Up @@ -118,15 +118,15 @@ it is important to align patterns to a reference.

The procedure of detecting, or registering, the translation between two similar images is usually
done by measuring the cross-correlation between images. When images are very similar, this procedure
is fine; take a look at scikit-image's :code:`skimage.feature.register_translation` for example.
is fine; take a look at scikit-image's :func:`skimage.feature.register_translation` for example.

However, diffraction patterns all have a fixed feature: the position of the beam-block. Therefore, some pixels
in each diffraction pattern must be ignored in the computation of the cross-correlation.

Setting the 'invalid pixels' to 0 will not work, at those will correlate with the invalid pixels from the reference. One must use
the **masked normalized cross-correlation** through scikit-ued's :code:`mnxc2`.
the **masked normalized cross-correlation** through scikit-ued's :func:`mnxc2`.

All of this is taken care of in scikit-ued's :code:`diff_register` function. Let's look at some polycrystalline Chromium:
All of this is taken care of in scikit-ued's :func:`diff_register` function. Let's look at some polycrystalline Chromium:

.. plot::

Expand Down Expand Up @@ -233,7 +233,7 @@ the center of those concentric rings is important. Let's load a test image:

This is a noisy diffraction pattern of polycrystalline vanadium dioxide.
Finding the center of such a symmetry pattern can be done with the
:code:`powder_center` routine::
:func:`powder_center` routine::
from skued.image import powder_center
ic, jc = powder_center(im, mask = mask)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Polycrystalline Diffraction Simulation
The simplest diffraction simulation available in scikit-ued is polycrystalline
diffraction simulation.

All you need is a :code:`Crystal` object and a range of scattering length, defined from
All you need is a :class:`Crystal` object and a range of scattering length, defined from
scattering angles `s` as :math:`s = \sin{\theta}/\lambda`::
import matplotlib.pyplot as plt
Expand Down
56 changes: 28 additions & 28 deletions docs/source/tutorials/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Contents

.. _atom:

The :code:`Atom` Class
======================
The basis of structure manipulations is to manipulate atoms. :code:`Atom` objects are in the
The :class:`Atom` Class
=======================
The basis of structure manipulations is to manipulate atoms. :class:`Atom` objects are in the
category of `Transformable` objects, meaning that their coordinates can be transformed
according to any affine transform.

Expand All @@ -28,10 +28,10 @@ To create an atom, simply provide its element and coordinates::

copper = Atom(element = 'Cu', coords = [0,0,0])

:code:`Atom` objects are hashable; this means that they can be stored in a :code:`set`. Therefore,
a list of atoms can be reduced into unique atoms using a :code:`set`.
:class:`Atom` objects are hashable; this means that they can be stored in a :func:`set`. Therefore,
a list of atoms can be reduced into unique atoms using a :func:`set`.

One important feature of the :code:`Atom` class is the possibility to compute the electrostatic
One important feature of the :class:`Atom` class is the possibility to compute the electrostatic
potential across meshes::

import numpy as np
Expand Down Expand Up @@ -64,20 +64,20 @@ After plot formatting:

.. _crystal:

The :code:`Crystal` Class
=========================
The :class:`Crystal` Class
==========================
Diffraction experiments relying on the redundancy of crystals to get good experimental signals;
hence, handling crystal models is the main feature of the :code:`skued.structure` subpackage.
hence, handling crystal models is the main feature of the :mod:`skued.structure` subpackage.

Constructing a :code:`Crystal` object from a file or database
-------------------------------------------------------------
Creating a :code:`Crystal` object can be done most easily from a Crystal Information File (CIF, .cif)::
Constructing a :class:`Crystal` object from a file or database
--------------------------------------------------------------
Creating a :class:`Crystal` object can be done most easily from a Crystal Information File (CIF, .cif)::
from skued.structure import Crystal

TiSe2 = Crystal.from_cif('tise2.cif')

Scikit-ued also has an internal database of CIF files. Valid names are stored in :code:`Crystal.builtins` and can be
Scikit-ued also has an internal database of CIF files. Valid names are stored in :attr:`Crystal.builtins` and can be
constructed like so::

assert 'Au' in Crystal.builtins
Expand All @@ -88,21 +88,21 @@ and the structure file will be taken care of by scikit-ued::
bacteriorhodopsin = Crystal.from_pdb('1fbb')

Another convenient way to construct a :code:`Crystal` is through the `Crystallography Open Database <http://www.crystallography.net/cod/>`_::
Another convenient way to construct a :class:`Crystal` is through the `Crystallography Open Database <http://www.crystallography.net/cod/>`_::

# Default is the latest revision
vo2 = Crystal.from_cod(1521124)

# Revisions are accessible as well
old_vo2 = Crystal.from_cod(1521124, revision = 140771)

Constructing a :code:`Crystal` object by hand
---------------------------------------------
If you don't have a file on hand, or want to create an idealized crystal, consider building a :code:`Crystal`
Constructing a :class:`Crystal` object by hand
----------------------------------------------
If you don't have a file on hand, or want to create an idealized crystal, consider building a :class:`Crystal`
object by hand.

To do this, you need:
1. iterable of :code:`Atom` objects, with coordinates. These atoms can either be the full unit cell
1. iterable of :class:`Atom` objects, with coordinates. These atoms can either be the full unit cell
or the asymmetric unit cell;
2. three lattice vectors;
3. Symmetry operators (optional). These symmetry operators will be applied to the atoms to generate
Expand All @@ -124,25 +124,25 @@ That's it!

Crystal attributes
------------------
The :code:`Crystal` object provides some interfaces for easy structure manipulation. First, a :code:`Crystal` is an iterable::
The :class:`Crystal` object provides some interfaces for easy structure manipulation. First, a :class:`Crystal` is an iterable::

from skued.structure import graphite

for atm in graphite: #Loops over atoms in the unit cell
print(atm.element, atm.coords)

Note that iterating over the :code:`crystal.atoms` attribute may or may not be equivalent to
:code:`iter(crystal)`, due to the way crystals are defined.
Note that iterating over the :attr:`crystal.atoms` attribute may or may not be equivalent to
:data:`iter(crystal)`, due to the way crystals are defined.

:code:`Crystal` objects also provide interoperability with :code:`spglib`::
:class:`Crystal` objects also provide interoperability with :mod:`spglib`::

import spglib

spglib.get_symmetry_dataset(cell = graphite.spglib_cell, symprec = 1e-4)

Lattice vectors and reciprocal space
-------------------------------------
Once a :code:`Crystal` object is ready, you can manipulate the lattice parameters via the underlying :code:`Lattice`
Once a :class:`Crystal` object is ready, you can manipulate the lattice parameters via the underlying :class:`Lattice`
super-class. Let's use the built-in example of graphite::

from skued.structure import graphite
Expand All @@ -161,7 +161,7 @@ The unit cell volume (and by extensions, density) is also accessible:

Scattering utilities
--------------------
:code:`Crystal` objects have a few methods that make life easier when dealing with scattering data and modeling.
:class:`Crystal` objects have a few methods that make life easier when dealing with scattering data and modeling.

The conversion between Miller indices and scattering vectors is available::

Expand All @@ -174,7 +174,7 @@ Arrays of Miller indices can be generated for all Miller indices that fall below

h, k, l = graphite.bounded_reflections(12) # All reflections below 12 Angs^-1

In this example, :code:`h`, :code:`k`, and :code:`l` are arrays of integers; each combined row is a reflection.
In this example, :data:`h`, :data:`k`, and :data:`l` are arrays of integers; each combined row is a reflection.

Static structure factor calculation is also possible, both for a single reflection and arrays of reflections::

Expand All @@ -191,7 +191,7 @@ Static structure factor calculation is also possible, both for a single reflecti
Atomic potential
----------------
The crystal electrostatic potential (the scattering potential leading to electron diffraction) can be
computed from a :code:`Crystal`::
computed from a :class:`Crystal`::

import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -221,8 +221,8 @@ After plot formatting:
plt.xlabel('y-direction ($\AA$)')
plt.show()

Note that while the :code:`graphite` crystal only has four atoms in its unitcell, the :code:`graphite.potential` method
will process the meshes :code:`xx`, :code:`yy`, and :code:`zz` through the :code:`skued.minimum_image_distance` function
Note that while the :data:`graphite` crystal only has four atoms in its unitcell, the :meth:`graphite.potential` method
will process the meshes :data:`xx`, :data:`yy`, and :data:`zz` through the :func:`skued.minimum_image_distance` function
to implement the **minimum-image distance convention** for periodic boundary conditions All this to say that the potential
is computed for a seemingly-infinite crystal.

Expand Down

0 comments on commit f3502bc

Please sign in to comment.