Skip to content

Commit

Permalink
Code breaking deletion, awaits merge of pyxem#98
Browse files Browse the repository at this point in the history
  • Loading branch information
pc494 committed Aug 27, 2020
1 parent cfabe72 commit 1efec39
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions diffsims/generators/library_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,80 +136,6 @@ def get_diffraction_library(

return diffraction_library


def _generate_lookup_table(recip_latt, reciprocal_radius: float, unique: bool = True):
"""Generate a look-up table with all combinations of indices,
including their reciprocal distances and the angle between
them.
Parameters
----------
recip_latt : :class:`diffpy.structure.lattice.Lattice`
Reciprocal lattice
reciprocal_radius : float
The maximum g-vector magnitude to be included in the library.
unique : bool
Return a unique list of phase measurements
Returns
-------
indices : np.array
Nx2x3 numpy array containing the miller indices for
reflection1, reflection2
measurements : np.array
Nx3 numpy array containing len1, len2, angle
"""
miller_indices, coordinates, distances = get_points_in_sphere(
recip_latt, reciprocal_radius
)

# Create pair_indices for selecting all point pair combinations
num_indices = len(miller_indices)
pair_a_indices, pair_b_indices = np.mgrid[:num_indices, :num_indices]

# Only select one of the permutations and don't pair an index with
# itself (select above diagonal)
upper_indices = np.triu_indices(num_indices, 1)
pair_a_indices = pair_a_indices[upper_indices].ravel()
pair_b_indices = pair_b_indices[upper_indices].ravel()

# Mask off origin (0, 0, 0)
origin_index = num_indices // 2
pair_a_indices = pair_a_indices[pair_a_indices != origin_index]
pair_b_indices = pair_b_indices[pair_b_indices != origin_index]

pair_indices = np.vstack([pair_a_indices, pair_b_indices])

# Create library entries
angles = get_angle_cartesian_vec(
coordinates[pair_a_indices], coordinates[pair_b_indices]
)
pair_distances = distances[pair_indices.T]
# Ensure longest vector is first
len_sort = np.fliplr(pair_distances.argsort(axis=1))
# phase_index_pairs is a list of [hkl1, hkl2]
phase_index_pairs = np.take_along_axis(
miller_indices[pair_indices.T], len_sort[:, :, np.newaxis], axis=1
)
# phase_measurements is a list of [len1, len2, angle]
phase_measurements = np.column_stack(
(np.take_along_axis(pair_distances, len_sort, axis=1), angles)
)

if unique:
# Only keep unique triplets
measurements, measurement_indices = np.unique(
phase_measurements, axis=0, return_index=True
)
indices = phase_index_pairs[measurement_indices]
else:
measurements = phase_measurements
indices = phase_index_pairs

return measurements, indices


class VectorLibraryGenerator:
"""Computes a library of diffraction vectors and pairwise inter-vector
angles for a specified StructureLibrary.
Expand Down

0 comments on commit 1efec39

Please sign in to comment.