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
23 changes: 17 additions & 6 deletions src/quantem/diffraction/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from quantem.diffraction.diffraction_tomography import (
DiffractionTomography as DiffractionTomography,
)
from quantem.diffraction.show_diffraction_tomography import (
show_diffraction_tomography as show_diffraction_tomography,
)
from quantem.diffraction.show_diffraction_tilts import (
show_diffraction_tilts as show_diffraction_tilts,
)
Expand All @@ -15,9 +12,23 @@
from quantem.diffraction.simulate_diffraction_tomography import (
SimDiffractionTomography as SimDiffractionTomography,
)
from quantem.diffraction.show_diffraction_tomography_6d import (
DiffractionTomographyViewer as DiffractionTomographyViewer,
)
from quantem.diffraction.show_diffraction_patterns import (
show_diffraction_patterns as show_diffraction_patterns,
)

# the anywidget viewers need the optional "widgets" extra, so they are
# imported on first use rather than with the package
_LAZY = {
"show_diffraction_tomography": "quantem.diffraction.show_diffraction_tomography",
"DiffractionTomographyViewer": "quantem.diffraction.show_diffraction_tomography_6d",
}


def __getattr__(name):
if name in _LAZY:
import importlib

value = getattr(importlib.import_module(_LAZY[name]), name)
globals()[name] = value
return value
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
7 changes: 4 additions & 3 deletions src/quantem/diffraction/full_diffraction_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _rotate_complex_volume_zxz(
kx, ky, kz = cls._make_reciprocal_grids(shape, dk)
k_grid = torch.stack(torch.broadcast_tensors(kx, ky, kz), axis=-1)

rot = Rotation.from_euler("zxz", zxz)
rot = Rotation.from_euler("ZXZ", zxz)
k_source = rot.inv().apply(k_grid.reshape(-1, 3)).reshape(*volume.shape, 3)
coords = torch.stack(
[
Expand Down Expand Up @@ -1158,11 +1158,12 @@ def projection_axes(

`u_proj` is the fast-scan direction, `v_proj` the slow-scan direction,
and `w_proj` the beam direction. The sample is rotated by the given
ZXZ Euler angles relative to the (lab, beam-down-z) frame; the lab
intrinsic Z-X-Z (Bunge) Euler angles, scipy "ZXZ", relative to
the (lab, beam-down-z) frame; the lab
axes (1,0,0), (0,1,0), (0,0,1) are then expressed in the sample frame.
"""
zxz_arr = self._resolve_zxz_deg(tilt_x_deg, zxz_deg)
rot = Rotation.from_euler("zxz", zxz_arr, degrees=True)
rot = Rotation.from_euler("ZXZ", zxz_arr, degrees=True)
# Lab→sample mapping: apply the inverse rotation to lab basis vectors.
u_proj = torch.tensor(rot.inv().apply([1.0, 0.0, 0.0]))
v_proj = torch.tensor(rot.inv().apply([0.0, 1.0, 0.0]))
Expand Down
2 changes: 1 addition & 1 deletion src/quantem/diffraction/show_diffraction_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def show_view(tilt_idx, power, vmin, vmax):
if disp_vmax <= disp_vmin:
disp_vmax = disp_vmin + 1e-12

R_sample = Rotation.from_euler("zxz", [0.0, tilt, 0.0], degrees=True)
R_sample = Rotation.from_euler("ZXZ", [0.0, tilt, 0.0], degrees=True)

fs = figsize if figsize is not None else ((11, 5.5) if show_3d else (5.5, 5.5))
fig = plt.figure(figsize=fs, dpi=dpi)
Expand Down
2 changes: 1 addition & 1 deletion src/quantem/diffraction/simulate_diffraction_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _make_au_structure_factor(
amp_scale = 1j * phase_scale

rot = (
Rotation.from_euler("zxz", torch.tensor(zxz_deg, dtype=torch.float32), degrees=True)
Rotation.from_euler("ZXZ", torch.tensor(zxz_deg, dtype=torch.float32), degrees=True)
if zxz_deg is not None
else None
)
Expand Down
Loading