Skip to content

Commit

Permalink
remove redundant figax viz functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gvarnavi committed Jan 2, 2024
1 parent 1275dab commit 3345b01
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1241,71 +1241,6 @@ def reconstruct(

return self

def _visualize_last_iteration_figax(
self,
fig,
object_ax,
convergence_ax,
cbar: bool,
padding: int = 0,
**kwargs,
):
"""
Displays last reconstructed object on a given fig/ax.
Parameters
--------
fig: Figure
Matplotlib figure object_ax lives in
object_ax: Axes
Matplotlib axes to plot reconstructed object in
convergence_ax: Axes, optional
Matplotlib axes to plot convergence plot in
cbar: bool, optional
If true, displays a colorbar
padding : int, optional
Pixels to pad by post rotating-cropping object
"""
cmap = kwargs.pop("cmap", "magma")

if self._object_type == "complex":
obj = np.angle(self.object)
else:
obj = self.object

rotated_object = self._crop_rotate_object_fov(
np.sum(obj, axis=0), padding=padding
)
rotated_shape = rotated_object.shape

extent = [
0,
self.sampling[1] * rotated_shape[1],
self.sampling[0] * rotated_shape[0],
0,
]

im = object_ax.imshow(
rotated_object,
extent=extent,
cmap=cmap,
**kwargs,
)

if cbar:
divider = make_axes_locatable(object_ax)
ax_cb = divider.append_axes("right", size="5%", pad="2.5%")
fig.add_axes(ax_cb)
fig.colorbar(im, cax=ax_cb)

if convergence_ax is not None and hasattr(self, "error_iterations"):
errors = np.array(self.error_iterations)
kwargs.pop("vmin", None)
kwargs.pop("vmax", None)
errors = self.error_iterations

convergence_ax.semilogy(np.arange(len(errors)), errors, **kwargs)

def _visualize_last_iteration(
self,
fig,
Expand Down
61 changes: 0 additions & 61 deletions py4DSTEM/process/phase/iterative_mixedstate_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,67 +1077,6 @@ def reconstruct(

return self

def _visualize_last_iteration_figax(
self,
fig,
object_ax,
convergence_ax: None,
cbar: bool,
padding: int = 0,
**kwargs,
):
"""
Displays last reconstructed object on a given fig/ax.
Parameters
--------
fig: Figure
Matplotlib figure object_ax lives in
object_ax: Axes
Matplotlib axes to plot reconstructed object in
convergence_ax: Axes, optional
Matplotlib axes to plot convergence plot in
cbar: bool, optional
If true, displays a colorbar
padding : int, optional
Pixels to pad by post rotating-cropping object
"""
cmap = kwargs.pop("cmap", "magma")

if self._object_type == "complex":
obj = np.angle(self.object)
else:
obj = self.object

rotated_object = self._crop_rotate_object_fov(obj, padding=padding)
rotated_shape = rotated_object.shape

extent = [
0,
self.sampling[1] * rotated_shape[1],
self.sampling[0] * rotated_shape[0],
0,
]

im = object_ax.imshow(
rotated_object,
extent=extent,
cmap=cmap,
**kwargs,
)

if cbar:
divider = make_axes_locatable(object_ax)
ax_cb = divider.append_axes("right", size="5%", pad="2.5%")
fig.add_axes(ax_cb)
fig.colorbar(im, cax=ax_cb)

if convergence_ax is not None and hasattr(self, "error_iterations"):
kwargs.pop("vmin", None)
kwargs.pop("vmax", None)
errors = self.error_iterations
convergence_ax.semilogy(np.arange(len(errors)), errors, **kwargs)

def _visualize_last_iteration(
self,
fig,
Expand Down
65 changes: 0 additions & 65 deletions py4DSTEM/process/phase/iterative_multislice_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,71 +1221,6 @@ def reconstruct(

return self

def _visualize_last_iteration_figax(
self,
fig,
object_ax,
convergence_ax,
cbar: bool,
padding: int = 0,
**kwargs,
):
"""
Displays last reconstructed object on a given fig/ax.
Parameters
--------
fig: Figure
Matplotlib figure object_ax lives in
object_ax: Axes
Matplotlib axes to plot reconstructed object in
convergence_ax: Axes, optional
Matplotlib axes to plot convergence plot in
cbar: bool, optional
If true, displays a colorbar
padding : int, optional
Pixels to pad by post rotating-cropping object
"""
cmap = kwargs.pop("cmap", "magma")

if self._object_type == "complex":
obj = np.angle(self.object)
else:
obj = self.object

rotated_object = self._crop_rotate_object_fov(
np.sum(obj, axis=0), padding=padding
)
rotated_shape = rotated_object.shape

extent = [
0,
self.sampling[1] * rotated_shape[1],
self.sampling[0] * rotated_shape[0],
0,
]

im = object_ax.imshow(
rotated_object,
extent=extent,
cmap=cmap,
**kwargs,
)

if cbar:
divider = make_axes_locatable(object_ax)
ax_cb = divider.append_axes("right", size="5%", pad="2.5%")
fig.add_axes(ax_cb)
fig.colorbar(im, cax=ax_cb)

if convergence_ax is not None and hasattr(self, "error_iterations"):
errors = np.array(self.error_iterations)
kwargs.pop("vmin", None)
kwargs.pop("vmax", None)
errors = self.error_iterations

convergence_ax.semilogy(np.arange(len(errors)), errors, **kwargs)

def _visualize_last_iteration(
self,
fig,
Expand Down
83 changes: 0 additions & 83 deletions py4DSTEM/process/phase/iterative_overlap_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,89 +1343,6 @@ def reconstruct(

return self

def _visualize_last_iteration_figax(
self,
fig,
object_ax,
convergence_ax,
cbar: bool,
projection_angle_deg: float,
projection_axes: Tuple[int, int],
x_lims: Tuple[int, int],
y_lims: Tuple[int, int],
**kwargs,
):
"""
Displays last reconstructed object on a given fig/ax.
Parameters
--------
fig: Figure
Matplotlib figure object_ax lives in
object_ax: Axes
Matplotlib axes to plot reconstructed object in
convergence_ax: Axes, optional
Matplotlib axes to plot convergence plot in
cbar: bool, optional
If true, displays a colorbar
projection_angle_deg: float
Angle in degrees to rotate 3D array around prior to projection
projection_axes: tuple(int,int)
Axes defining projection plane
x_lims: tuple(float,float)
min/max x indices
y_lims: tuple(float,float)
min/max y indices
"""

cmap = kwargs.pop("cmap", "magma")

asnumpy = self._asnumpy

if projection_angle_deg is not None:
rotated_3d_obj = self._rotate(
self._object,
projection_angle_deg,
axes=projection_axes,
reshape=False,
order=2,
)
rotated_3d_obj = asnumpy(rotated_3d_obj)
else:
rotated_3d_obj = self.object

rotated_object = self._crop_rotate_object_manually(
rotated_3d_obj.sum(0), angle=None, x_lims=x_lims, y_lims=y_lims
)
rotated_shape = rotated_object.shape

extent = [
0,
self.sampling[1] * rotated_shape[1],
self.sampling[0] * rotated_shape[0],
0,
]

im = object_ax.imshow(
rotated_object,
extent=extent,
cmap=cmap,
**kwargs,
)

if cbar:
divider = make_axes_locatable(object_ax)
ax_cb = divider.append_axes("right", size="5%", pad="2.5%")
fig.add_axes(ax_cb)
fig.colorbar(im, cax=ax_cb)

if convergence_ax is not None and hasattr(self, "error_iterations"):
errors = np.array(self.error_iterations)
kwargs.pop("vmin", None)
kwargs.pop("vmax", None)
errors = self.error_iterations
convergence_ax.semilogy(np.arange(errors.shape[0]), errors, **kwargs)

def _visualize_last_iteration(
self,
fig,
Expand Down
61 changes: 0 additions & 61 deletions py4DSTEM/process/phase/iterative_singleslice_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,67 +1077,6 @@ def reconstruct(

return self

def _visualize_last_iteration_figax(
self,
fig,
object_ax,
convergence_ax: None,
cbar: bool,
padding: int = 0,
**kwargs,
):
"""
Displays last reconstructed object on a given fig/ax.
Parameters
--------
fig: Figure
Matplotlib figure object_ax lives in
object_ax: Axes
Matplotlib axes to plot reconstructed object in
convergence_ax: Axes, optional
Matplotlib axes to plot convergence plot in
cbar: bool, optional
If true, displays a colorbar
padding : int, optional
Pixels to pad by post rotating-cropping object
"""
cmap = kwargs.pop("cmap", "magma")

if self._object_type == "complex":
obj = np.angle(self.object)
else:
obj = self.object

rotated_object = self._crop_rotate_object_fov(obj, padding=padding)
rotated_shape = rotated_object.shape

extent = [
0,
self.sampling[1] * rotated_shape[1],
self.sampling[0] * rotated_shape[0],
0,
]

im = object_ax.imshow(
rotated_object,
extent=extent,
cmap=cmap,
**kwargs,
)

if cbar:
divider = make_axes_locatable(object_ax)
ax_cb = divider.append_axes("right", size="5%", pad="2.5%")
fig.add_axes(ax_cb)
fig.colorbar(im, cax=ax_cb)

if convergence_ax is not None and hasattr(self, "error_iterations"):
kwargs.pop("vmin", None)
kwargs.pop("vmax", None)
errors = self.error_iterations
convergence_ax.semilogy(np.arange(len(errors)), errors, **kwargs)

def _visualize_last_iteration(
self,
fig,
Expand Down

0 comments on commit 3345b01

Please sign in to comment.