Skip to content

Commit

Permalink
numpy is bewildering
Browse files Browse the repository at this point in the history
  • Loading branch information
smribet committed Sep 29, 2024
1 parent 242d35f commit ff0c72c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions py4DSTEM/tomography/tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def reconstruct(
num_points: int = 60,
progress_bar: bool = True,
zero_edges: bool = True,
baseline_thresh: float = 0,
baseline_thresh: float = 0.9,
):
"""
Main loop for reconstruct
Expand All @@ -306,7 +306,7 @@ def reconstruct(
zero_edges: bool
If True, zero edges along y and z
baseline_thresh: float
If not None, data is cropped below threshold
If not None, data is cropped below threshold. Value is fraction of max.
"""
device = self._device

Expand Down Expand Up @@ -855,7 +855,7 @@ def _reshape_4D_array_to_2D(
wx = qx0 - xF
wy = qy0 - yF

diffraction_patterns_reshaped[index] = (
dp_projected = (
(
(
(1 - wx)
Expand Down Expand Up @@ -895,8 +895,10 @@ def _reshape_4D_array_to_2D(
)
)
)
else:

diffraction_patterns_reshaped[index] = dp_projected

else:
diffraction_patterns_reshaped[index] = np.bincount(
ind_diffraction_ravel,
dp.ravel(),
Expand Down Expand Up @@ -1156,7 +1158,7 @@ def _forward(
device = self._device
obj = copy_to_device(self._object[x_index], device)

#TODO check sign
# TODO check sign
tilt = -xp.deg2rad(tilt_deg)

# solve for real space coordinates
Expand Down Expand Up @@ -1509,7 +1511,7 @@ def _constraints(self, zero_edges: bool, baseline_thresh: float):
zero_edges: bool
If True, zero edges along y and z
baseline_thresh: float
If not None, data is cropped below threshold
If not None, data is cropped below threshold. Value is fraction of max.
"""
if zero_edges:
xp = self._xp_storage
Expand All @@ -1526,6 +1528,7 @@ def _constraints(self, zero_edges: bool, baseline_thresh: float):
self._object[:, ind_zero] = 0

if baseline_thresh is not None:
baseline_thresh *= self._object.max()
xp = self._xp_storage
self._object = xp.clip(self._object - baseline_thresh, 0, np.inf)

Expand Down

0 comments on commit ff0c72c

Please sign in to comment.