Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/diffraction_utils/data_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(

# Run the various parsers to initialize non-trivial attributes.
self.probe_energy = self._parse_probe_energy()
self.probe_wavelength = self._calc_probe_wavelength()
self.default_axis_name = self._parse_default_axis_name()
self.default_signal_name = self._parse_default_signal_name()
self.default_axis = self._parse_default_axis()
Expand Down Expand Up @@ -149,6 +150,12 @@ def _parse_probe_energy(self):
The energy of the probe particle, in eV.
"""

@abstractmethod
def _calc_probe_wavelength(self):
"""
The energy of the probe particle, in eV.
"""

@abstractmethod
def _parse_default_signal(self) -> np.ndarray:
"""
Expand Down Expand Up @@ -326,7 +333,7 @@ def _try_to_find_files(filenames: List[str], additional_search_paths: List[str])
firstfile = filenames[0].split("/")[-1]
# assume if first file is found that paths are good
if os.path.exists(localpath / firstfile):
found_files = [localpath / file.split("/")[-1] for file in filenames]
found_files = [str(localpath / file.split("/")[-1]) for file in filenames]
return found_files

# This function was written to handle strings, not pathlib.Paths.
Expand Down
17 changes: 2 additions & 15 deletions src/diffraction_utils/diffractometers/diamond_i07.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import numpy as np
from scipy.constants import Planck, elementary_charge, speed_of_light
from scipy.spatial.transform import Rotation

from ..diffractometer_base import DiffractometerBase
Expand All @@ -18,16 +17,6 @@
INSB_LATTICE_PARAMETER = 6.479 # In Å.


def _energy_to_wavelength(energy_in_ev):
"""
Converts the incident beam energy into wavelength in Å.

Args:
Energy of the probe particle in electron volts.
"""
return Planck * speed_of_light / (energy_in_ev * elementary_charge) * 1e10


class I07Diffractometer(DiffractometerBase):
"""
Implementation of DiffractometerBase for the diffractometer in Diamond's I07
Expand Down Expand Up @@ -199,16 +188,14 @@ def _insb_111_theta(self):
Returns the scattering theta of the InSb (111) reflection. Needed to
calculate the incident beam orientation in the DCD setup.
"""
wavelength = _energy_to_wavelength(self.data_file.probe_energy)
d_111 = INSB_LATTICE_PARAMETER / np.sqrt(3)
return np.arcsin(wavelength / (2 * d_111)) * 180 / np.pi
return np.arcsin(self.data_file.probe_wavelength / (2 * d_111)) * 180 / np.pi

@property
def _insb_220_theta(self):
"""
Returns the scattering theta of the InSb (220) reflection. Needed to
calculate the incident beam orientation in the DCD setup.
"""
wavelength = _energy_to_wavelength(self.data_file.probe_energy)
d_220 = INSB_LATTICE_PARAMETER / np.sqrt(8)
return np.arcsin(wavelength / (2 * d_220)) * 180 / np.pi
return np.arcsin(self.data_file.probe_wavelength / (2 * d_220)) * 180 / np.pi
Loading
Loading