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
2 changes: 1 addition & 1 deletion py4DSTEM/datacube/virtualimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def get_calibrated_detector_geometry(
), "No calibration found - set a calibration or set `centered` and `calibrated` to False"
return g
else:
assert isinstance(calibration, Calibration)
# assert isinstance(calibration, Calibration)
cal = calibration

# Get calibration metadata
Expand Down
10 changes: 5 additions & 5 deletions py4DSTEM/process/diffraction/flowlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def make_flowline_rainbow_image(
def make_flowline_rainbow_legend(
im_size=np.array([256, 256]),
sym_rotation_order=2,
theta_offset=0.0,
theta_offset_degrees=0.0,
white_background=False,
return_image=False,
radial_range=np.array([0.45, 0.9]),
Expand All @@ -813,7 +813,7 @@ def make_flowline_rainbow_legend(
Args:
im_size (np.array): Size of legend image in pixels.
sym_rotation_order (int): rotational symmety for colouring
theta_offset (float): Offset the anglular coloring by this value in radians.
theta_offset_degrees (float): Offset the anglular coloring by this value in radians.
white_background (bool): For either color or greyscale output, switch to white background (from black).
return_image (bool): Return the image array.
radial_range (np.array): Inner and outer radius for the legend ring.
Expand All @@ -827,17 +827,17 @@ def make_flowline_rainbow_legend(
# Coordinates
x = np.linspace(-1, 1, im_size[0])
y = np.linspace(-1, 1, im_size[1])
ya, xa = np.meshgrid(-y, x)
ya, xa = np.meshgrid(y, x)
ra = np.sqrt(xa**2 + ya**2)
ta = np.arctan2(ya, xa) + theta_offset
ta = np.arctan2(ya, xa) + np.deg2rad(theta_offset_degrees)
ta_sym = ta * sym_rotation_order

# mask
mask = np.logical_and(ra > radial_range[0], ra < radial_range[1])

# rgb image
z = mask * np.exp(1j * ta_sym)
hue_start = -90
hue_start = 0
amp = np.abs(z)
vmin = np.min(amp)
vmax = np.max(amp)
Expand Down
50 changes: 40 additions & 10 deletions py4DSTEM/process/polar/polar_peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ def find_peaks_single_pattern(
)

# output
peaks_prom[a0, 0] = p_annular[0]
# scipy's peak_prominences returns length-1 arrays here; index into
# them explicitly, since numpy >= 2.0 no longer allows assigning a
# size-1 array to a scalar element.
peaks_prom[a0, 0] = p_annular[0][0]
peaks_prom[a0, 1] = sigma_annular[0]
peaks_prom[a0, 2] = p_radial[0]
peaks_prom[a0, 2] = p_radial[0][0]
peaks_prom[a0, 3] = sigma_radial[0]

# if needed, remove peaks using prominance criteria
Expand Down Expand Up @@ -310,12 +313,29 @@ def find_peaks_single_pattern(
ct = np.cos(t)
st = np.sin(t)

fig, ax = plt.subplots(figsize=figsize)

cmap = kwargs.pop("cmap", "gray")
vmax = kwargs.pop("vmax", 1)
vmin = kwargs.pop("vmin", 0)
show(im_plot, figax=(fig, ax), cmap=cmap, vmax=vmax, vmin=vmin, **kwargs)

if "figax" in kwargs:
fig, ax = kwargs["figax"]
show(
im_plot,
cmap=cmap,
vmax=vmax,
vmin=vmin,
**kwargs,
)
else:
fig, ax = plt.subplots(figsize=figsize)
show(
im_plot,
figax=(fig, ax),
cmap=cmap,
vmax=vmax,
vmin=vmin,
**kwargs,
)

# peaks
ax.scatter(
Expand Down Expand Up @@ -780,6 +800,7 @@ def model_radial_background(
refine_model=True,
plot_result=True,
figsize=(8, 4),
returnfig=False,
):
"""
User provided radial background model, of the form:
Expand Down Expand Up @@ -883,11 +904,20 @@ def background_model(q, *coefs):

# plotting
if plot_result:
self.plot_radial_background(
q_pixel_units=False,
plot_background_model=True,
figsize=figsize,
)
if returnfig:
fig, ax = self.plot_radial_background(
q_pixel_units=False,
plot_background_model=True,
figsize=figsize,
returnfig=returnfig,
)
return fig, ax
else:
self.plot_radial_background(
q_pixel_units=False,
plot_background_model=True,
figsize=figsize,
)


def refine_peaks(
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/visualize/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def show(
):
cal = ar.calibration
er = ".calibration attribute must be a Calibration instance"
assert isinstance(cal, Calibration), er
# assert isinstance(cal, Calibration), er
if isinstance(ar, DiffractionSlice):
scalebar = {
"Nx": ar.data.shape[0],
Expand Down
Loading