-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit for the baseline package This package includes the code that was used in the publication of : L. P. René de Cotret and B. J. Siwick, A general method for baseline-removal in ultrafast electron powder diffraction data using the dual-tree complex wavelet transform, Struct. Dyn. 4 (2016) * Initial documentation for the baseline package * Removed links to PyUp and saythanks * Added installation of NumPy before setup.py can be run on Appveyor * Revert "Added installation of NumPy before setup.py can be run on Appveyor" This reverts commit dd4ab54. * FIX: appveyor builds failing fue to numpy not being * Removed TOX dependency in Appveyor CI * FIX: Install numpy & friends from conda on appveyor CI * FIX: remove optional installation of conda * FIX: typo in appveyor.yml * FIX: Escape characters * FIX: Yet another typo * f * Installation of skimage through conda * UTF-8 encoding * appveyor.yml typo * build_sphinx command * Not installign the right python version * f * 23rd time's the charm * Refactoring of the baseline package Iterative baseline functions are pretty similar, and they now share a common implementation for the 1D case. * Documentation setup based on SHAMPOO * DOC: updated documentation to reflect the pywavelets dependency * Sphinx RTD theme added * Appveyor testing via unittest * FIX: appveyor.yml typo * FIX: Python 3.5 install from Miniconda3s * FIX: Appveyor.yml typo * CI overhaul - Removed travis CI - switched Appveyor testing to a modified version of Astropy's CI-Helpers * FIX: appveyor os not found * FIX: code climate and readme * Angular average and tutorial (#3) * Continuous integration and documentation (#2) * Initial commit for the baseline package This package includes the code that was used in the publication of : L. P. René de Cotret and B. J. Siwick, A general method for baseline-removal in ultrafast electron powder diffraction data using the dual-tree complex wavelet transform, Struct. Dyn. 4 (2016) * Initial documentation for the baseline package * Removed links to PyUp and saythanks * Added installation of NumPy before setup.py can be run on Appveyor * Revert "Added installation of NumPy before setup.py can be run on Appveyor" This reverts commit dd4ab54. * FIX: appveyor builds failing fue to numpy not being * Removed TOX dependency in Appveyor CI * FIX: Install numpy & friends from conda on appveyor CI * FIX: remove optional installation of conda * FIX: typo in appveyor.yml * FIX: Escape characters * FIX: Yet another typo * f * Installation of skimage through conda * UTF-8 encoding * appveyor.yml typo * build_sphinx command * Not installign the right python version * f * 23rd time's the charm * Refactoring of the baseline package Iterative baseline functions are pretty similar, and they now share a common implementation for the 1D case. * Documentation setup based on SHAMPOO * DOC: updated documentation to reflect the pywavelets dependency * Sphinx RTD theme added * Appveyor testing via unittest * FIX: appveyor.yml typo * FIX: Python 3.5 install from Miniconda3s * FIX: Appveyor.yml typo * CI overhaul - Removed travis CI - switched Appveyor testing to a modified version of Astropy's CI-Helpers * FIX: appveyor os not found * FIX: code climate and readme * Initial commit * pseudo-voigt and friends * DOC: angular_average tutorial * DOC: References * DOC: baseline tutorial * API: angular_average returns intensity and radius * DOC: angular_average tutorial * Plot utils: spectrum (rainbow) colors * Parallel utils: pmap Parallel map that reduces to the use of map() for a single process. * Structure package (#4) * Affine transforms module First commit for the affine transforms module, containing functions to create affine transforms and transform points and other transforms. * Initial commit for the core structure package * Atom class tutorial * structure tutorial enhancements Added an example of crystal potential
- Loading branch information
1 parent
878a514
commit ea27d46
Showing
46 changed files
with
3,268 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ nose==1.3.7 | |
coverage==4.3.1 | ||
codecov==2.0.5 | ||
Sphinx>=1.5.1 | ||
cython>=0.25 | ||
cython>=0.25 | ||
matplotlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
.. include:: ../references.txt | ||
|
||
.. _image_analysis_tutorial: | ||
|
||
*********************** | ||
Image Analysis Tutorial | ||
*********************** | ||
|
||
Due to the high electron cross-section, background signals (or baseline) are | ||
much more of a problem for electron diffraction than equivalent X-ray experiments. | ||
|
||
Contents | ||
======== | ||
|
||
* :ref:`symmetry` | ||
|
||
.. _symmetry: | ||
|
||
Angular average of polycrystalline diffraction patterns | ||
======================================================= | ||
|
||
First, we create a test image:: | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from skued import gaussian | ||
|
||
image = np.zeros( (256, 256) ) | ||
xc, yc = image.shape[0]/2, image.shape[1]/2 # center | ||
|
||
extent = np.arange(0, image.shape[0]) | ||
xx, yy = np.meshgrid(extent, extent) | ||
image += gaussian([xx, yy], center = [xc, yc], fwhm = 200) | ||
image /= image.max() # Normalize max to 1 | ||
image += np.random.random(size = image.shape) | ||
|
||
plt.imshow(image) | ||
plt.show() | ||
|
||
.. plot:: | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from skued import gaussian | ||
image = np.zeros( (256, 256) ) | ||
xc, yc = image.shape[0]/2, image.shape[1]/2 # center | ||
extent = np.arange(0, image.shape[0]) | ||
xx, yy = np.meshgrid(extent, extent) | ||
image += gaussian([xx, yy], center = [xc, yc], fwhm = 100) | ||
image /= image.max() | ||
image += np.random.random(size = image.shape) | ||
plt.imshow(image) | ||
plt.show() | ||
|
||
|
||
... and we can easily compute an angular average:: | ||
from skued.image_analysis import angular_average | ||
|
||
radius, intensity = angular_average(image, (xc, yc)) | ||
|
||
plt.plot(radius, intensity) | ||
|
||
.. plot:: | ||
|
||
from skued.image_analysis import angular_average | ||
from skued import gaussian | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from skued import gaussian | ||
image = np.zeros( (256, 256) ) | ||
xc, yc = image.shape[0]/2, image.shape[1]/2 # center | ||
extent = np.arange(0, image.shape[0]) | ||
xx, yy = np.meshgrid(extent, extent) | ||
image += gaussian([xx, yy], center = [xc, yc], fwhm = 200) | ||
image /= image.max() | ||
image += np.random.random(size = image.shape) | ||
radius, intensity = angular_average(image, (xc, yc)) | ||
plt.plot(radius, intensity) | ||
plt.show() | ||
|
||
We can also get the standard error in the mean of this average:: | ||
|
||
extras = dict() | ||
radius, intensity = angular_average(image, (xc, yc), extras = extras) | ||
|
||
plt.errorbar(radius, intensity, yerr - extras['error']) | ||
|
||
.. plot:: | ||
|
||
from skued.image_analysis import angular_average | ||
from skued import gaussian | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from skued import gaussian | ||
image = np.zeros( (256, 256) ) | ||
xc, yc = image.shape[0]/2, image.shape[1]/2 # center | ||
extent = np.arange(0, image.shape[0]) | ||
xx, yy = np.meshgrid(extent, extent) | ||
image += gaussian([xx, yy], center = [xc, yc], fwhm = 200) | ||
image /= image.max() | ||
image += np.random.random(size = image.shape) | ||
extras = dict() | ||
radius, intensity = angular_average(image, (xc, yc), extras = extras) | ||
plt.errorbar(radius, intensity, yerr = extras['error']) | ||
plt.show() | ||
|
||
As expected, the points close to the center and very far from it display as higher | ||
amount of noise due to the number of points used in the averaging. | ||
|
||
:ref:`Return to Top <image_analysis_tutorial>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ We currently have the following tutorials: | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
structure | ||
baseline | ||
image_analysis |
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
docs/source/tutorials/plots/powder_dt_baseline_progression.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from skued import gaussian | ||
from skued.baseline import baseline_dt | ||
|
||
s, intensity = np.load('powder.npy') | ||
|
||
# Double exponential inelastic background and substrate effects | ||
background = 75 * np.exp(-7 * s) + 55 * np.exp(-2 * s) | ||
substrate1 = 0.8 * gaussian(s, center = s.mean(), fwhm = s.mean()/4) | ||
substrate2 = 0.9 * gaussian(s, center = s.mean()/2.5, fwhm = s.mean()/4) | ||
|
||
signal = intensity + background + substrate1 + substrate2 | ||
|
||
for l in range(5): | ||
baseline = baseline_dt(signal, level = l, max_iter = 100) | ||
plt.plot(s, baseline, color = 'r', label = 'Baseline level {}'.format(l)) | ||
|
||
plt.plot(s, signal, 'k-', label = 'Diffraction') | ||
|
||
plt.title('Diffraction pattern of rutile VO$_2$') | ||
plt.xlabel('Scattering angle (1/$\AA$)') | ||
plt.ylabel('Diffracted intensity (counts)') | ||
plt.xlim([s.min(), s.max()]) | ||
plt.ylim([0, 100]) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
s, intensity = np.load('powder.npy') | ||
plt.plot(s, intensity, 'k-') | ||
plt.title('Background-subtracted diffraction pattern of rutile VO$_2$') | ||
plt.xlabel('Scattering angle (1/$\AA$)') | ||
plt.ylabel('Diffracted intensity (counts)') | ||
plt.xlim([s.min(), s.max()]) | ||
plt.ylim([0, 20]) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from skued import gaussian | ||
|
||
s, intensity = np.load('powder.npy') | ||
|
||
# Double exponential inelastic background and substrate effects | ||
background = 75 * np.exp(-7 * s) + 55 * np.exp(-2 * s) | ||
substrate1 = 0.8 * gaussian(s, center = s.mean(), fwhm = s.mean()/4) | ||
substrate2 = 0.9 * gaussian(s, center = s.mean()/2.5, fwhm = s.mean()/4) | ||
|
||
plt.plot(s, intensity + background + substrate1 + substrate2, 'k-', | ||
label = 'Diffraction') | ||
plt.plot(s, background + substrate1 + substrate2, 'r-', | ||
label = 'Baseline') | ||
|
||
plt.legend() | ||
|
||
plt.title('Diffraction pattern of rutile VO$_2$') | ||
plt.xlabel('Scattering angle (1/$\AA$)') | ||
plt.ylabel('Diffracted intensity (counts)') | ||
plt.xlim([s.min(), s.max()]) | ||
plt.ylim([0, 100]) | ||
plt.show() |
Oops, something went wrong.