Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.4 #11

Merged
merged 11 commits into from
Jun 21, 2017
Prev Previous commit
Next Next commit
Changed powdersim() to allow for 'custom' peak profile (based on Voigt)
  • Loading branch information
LaurentRDC committed Jun 20, 2017
commit 49becdaab7432b08bfa3d9fee7ab166ea6b2f21b
11 changes: 6 additions & 5 deletions skued/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
__license__ = 'MIT'
__version__ = '0.4.4' # TODO: automatic versioning?

from .array_utils import repeated_array, mirror
from .affine import (affine_map, change_basis_mesh, change_of_basis, is_basis,
is_rotation_matrix, minimum_image_distance,
rotation_matrix, transform, translation_matrix,
translation_rotation_matrix)
from .array_utils import mirror, repeated_array
from .parallel import pmap, preduce
from .plot_utils import spectrum_colors
from .quantities import lorentz, electron_wavelength, interaction_parameter
from .affine import (affine_map, transform, change_of_basis, is_basis, translation_matrix,
is_rotation_matrix, rotation_matrix, translation_rotation_matrix,
change_basis_mesh, minimum_image_distance)
from .quantities import electron_wavelength, interaction_parameter, lorentz
from .voigt import gaussian, lorentzian, pseudo_voigt
19 changes: 9 additions & 10 deletions skued/simulation/powdersim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ..voigt import pseudo_voigt
import numpy as np

def powdersim(crystal, scattering_length, broadening = True, **kwargs):
def powdersim(crystal, scattering_length, fwhm_g = 0.01, fwhm_l = 0.02, **kwargs):
"""
Simulates polycrystalline diffraction pattern.

Expand All @@ -15,9 +15,10 @@ def powdersim(crystal, scattering_length, broadening = True, **kwargs):
Crystal from which to diffract.
scattering_length : `~numpy.ndarray`, shape (N,)
Range of scattering length over which to compute the diffraction pattern [2pi/Angs].
broadening: bool, optional
If True (default), returned pattern will display Voigt-related broadening.

fwhm_g, fwhm_l : float, optional
Full-width at half-max of the Gaussian and Lorentzian parts of the Voigt profile.
See `skued.pseudo_voigt` for more details.

Returns
-------
pattern : `~numpy.ndarray`, shape (N,)
Expand All @@ -27,12 +28,10 @@ def powdersim(crystal, scattering_length, broadening = True, **kwargs):
scatt_length = np.sqrt(Gx**2 + Gy**2 + Gz**2)/(4*np.pi)
intensities = np.absolute(crystal.structure_factor((Gx, Gy, Gz)))**2

psf = pseudo_voigt(scattering_length, center = np.mean(scattering_length), fwhm_g = fwhm_g, fwhm_l = fwhm_l)

pattern = np.zeros_like(scattering_length)
if broadening:
for s, I in zip(scatt_length, intensities):
pattern += I * pseudo_voigt(scattering_length, s, 0.01, 0.02)
else:
for s, I in zip(scatt_length, intensities):
pattern += I * pseudo_voigt(scattering_length, s, 1e-5, 1e-5)
for s, i in zip(scatt_length, intensities):
pattern += i * pseudo_voigt(scattering_length, s, fwhm_g, fwhm_l)

return pattern