<commit_before>import numpy as np
from pymicro.crystal.lattice import HklPlane, Lattice
from pymicro.crystal.microstructure import Orientation
from pymicro.xray.xray_utils import *
from pymicro.xray.dct import add_to_image

def select_lambda(hkl, orientation, Xu=np.array([1., 0., 0.]), verbose=False):
    '''
    Compute the wavelength corresponding to the first order reflection
    of a given lattice plane.

    :param hkl: The given lattice plane.
    :param orientation: The orientation of the crystal lattice.
    :param Xu: The unit vector of the incident X-ray beam (default along the X-axis).
    :param bool verbose: activate verbose mode (default False).
    :returns tuple: A tuple of the wavelength value (keV) and the corresponding Bragg angle (radian).
    '''
    (h, k, l) = hkl.miller_indices()
    dhkl = hkl.interplanar_spacing()
    Gc = hkl.scattering_vector()
    Bt = orientation.orientation_matrix().transpose()
    Gs = Bt.dot(Gc)
    # compute the theta angle between X and the scattering vector which is theta + pi/2
    theta = np.arccos(np.dot(Xu, Gs / np.linalg.norm(Gs))) - np.pi / 2
    # find the lambda selected by this hkl plane
    the_energy = lambda_nm_to_keV(2 * dhkl * np.sin(theta))
    if verbose:
        print('\n** Looking at plane %d%d%d **' % (h, k, l))
        print('scattering vector in laboratory CS', Gs)
        print('glancing angle between incident beam and the hkl plane is %.1f deg' % (theta * 180 / np.pi))
        print('corresponding energy is %.1f' % the_energy)
    return (the_energy, theta)


def build_list(lattice=None, max_miller=3):<commit_msg>updated select_lambda docstring<commit_after>import numpy as np
from pymicro.crystal.lattice import HklPlane, Lattice
from pymicro.crystal.microstructure import Orientation
from pymicro.xray.xray_utils import *
from pymicro.xray.dct import add_to_image


def select_lambda(hkl, orientation, Xu=np.array([1., 0., 0.]), verbose=False):
    """
    Compute the wavelength corresponding to the first order reflection
    of a given lattice plane in the specified orientation.

    :param hkl: The given lattice plane.
    :param orientation: The orientation of the crystal lattice.
    :param Xu: The unit vector of the incident X-ray beam (default along the X-axis).
    :param bool verbose: activate verbose mode (default False).
    :returns tuple: A tuple of the wavelength value (keV) and the corresponding Bragg angle (radian).
    """
    (h, k, l) = hkl.miller_indices()
    dhkl = hkl.interplanar_spacing()
    Gc = hkl.scattering_vector()
    Bt = orientation.orientation_matrix().transpose()
    Gs = Bt.dot(Gc)
    # compute the theta angle between X and the scattering vector which is theta + pi/2
    theta = np.arccos(np.dot(Xu, Gs / np.linalg.norm(Gs))) - np.pi / 2
    # find the lambda selected by this hkl plane
    the_energy = lambda_nm_to_keV(2 * dhkl * np.sin(theta))
    if verbose:
        print('\n** Looking at plane %d%d%d **' % (h, k, l))
        print('scattering vector in laboratory CS', Gs)
        print('glancing angle between incident beam and the hkl plane is %.1f deg' % (theta * 180 / np.pi))
        print('corresponding energy is %.1f' % the_energy)
    return (the_energy, theta)


def build_list(lattice=None, max_miller=3):
{'fraction_non_alphanumeric': 0.10311165344722392, 'fraction_numerical': 0.007321537522879805, 'mean_word_length': 3.5290055248618786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1835493', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1019, 'n_words': 361}