Skip to content

Commit

Permalink
Merge fa085d2 into 200c26f
Browse files Browse the repository at this point in the history
  • Loading branch information
pc494 committed Sep 14, 2020
2 parents 200c26f + fa085d2 commit 01c4b8b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 27 deletions.
8 changes: 2 additions & 6 deletions diffsims/generators/diffraction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ def calculate_profile_data(
self,
structure,
reciprocal_radius=1.0,
magnitude_tolerance=1e-5,
minimum_intensity=1e-3,
minimum_intensity=1e-3
):
"""
Calculates a one dimensional diffraction profile for a structure.
Expand All @@ -205,9 +204,6 @@ def calculate_profile_data(
reciprocal_radius : float
The maximum radius of the sphere of reciprocal space to sample, in
reciprocal angstroms.
magnitude_tolerance : float
The minimum difference between diffraction magnitudes in reciprocal
angstroms for two peaks to be considered different.
minimum_intensity : float
The minimum intensity required for a diffraction peak to be
considered real. Deals with numerical precision issues.
Expand Down Expand Up @@ -269,7 +265,7 @@ def calculate_profile_data(
y.append(v[0])
hkls.append(k)

y = y / max(y) * 100
y = np.asarray(y) / max(y) * 100

return ProfileSimulation(x, y, hkls)

Expand Down
11 changes: 4 additions & 7 deletions diffsims/libraries/diffraction_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ def get_library_entry(self, phase=None, angle=None):
if phase is not None:
phase_entry = self[phase]
if angle is not None:
orientations = phase_entry["orientations"]
if isinstance(orientations, np.ndarray):
orientations = orientations.tolist()
orientation_index = _get_library_entry_from_angles(self, phase, angle)
else:
orientation_index = 0
else:
if angle is not None:
raise ValueError(
"To select a certain angle you must first specify a phase"
elif angle is not None:
raise ValueError(
"To select a certain angle you must first specify a phase"
)
else:
phase_entry = next(iter(self.values()))
orientation_index = 0

Expand Down
11 changes: 1 addition & 10 deletions diffsims/sims/diffraction_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,22 @@ class ProfileSimulation:
Magnitudes of scattering vectors.
intensities : array-like, shape [n_peaks, 1]
The kinematic intensity of the diffraction peaks.
Returns
-------
hkls: [{(h, k, l): mult}] {(h, k, l): mult} is a dict of Miller
indices for all diffracted lattice facets contributing to each
intensity.
"""

def __init__(self, magnitudes, intensities, hkls):
"""Initializes the ProfileSimulation object with data values for the
magnitudes, intensities, and hkls.
"""
self.magnitudes = magnitudes
self.intensities = intensities
self.hkls = hkls

def get_plot(self, g_max, annotate_peaks=True, with_labels=True, fontsize=12):

def get_plot(self,annotate_peaks=True, with_labels=True, fontsize=12):
"""Plots the diffraction profile simulation for the
calculate_profile_data method in DiffractionGenerator.
Parameters
----------
g_max : float
Maximum g-vector magnitude to plot.
annotate_peaks : boolean
If True, peaks are annotaed with hkl information.
with_labels : boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"grid",
[
pytest.param(
get_local_grid(resolution=30, center=(0, 1, 0), grid_width=35),
marks=pytest.mark.xfail(reason="Downstream bug"),
get_local_grid(resolution=30, center=(0,1,0), grid_width=35)
),
get_fundamental_zone_grid(space_group=20, resolution=20),
],
Expand Down
2 changes: 1 addition & 1 deletion diffsims/tests/test_sims/test_diffraction_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def profile_simulation():


def test_plot_profile_simulation(profile_simulation):
profile_simulation.get_plot(g_max=1)
profile_simulation.get_plot()


class TestDiffractionSimulation:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"tqdm>=0.4.9",
"transforms3d",
"diffpy.structure>=3.0.0", # First Python 3 support
"orix>=0.4.0",
"orix>=0.5.0",
"numba",
"psutil",
],
Expand Down

0 comments on commit 01c4b8b

Please sign in to comment.