From 3345b0198724352c5c65652fd1520751ca2a4244 Mon Sep 17 00:00:00 2001 From: Georgios Varnavides Date: Tue, 2 Jan 2024 12:09:18 -0800 Subject: [PATCH] remove redundant figax viz functions --- ...tive_mixedstate_multislice_ptychography.py | 65 --------------- .../iterative_mixedstate_ptychography.py | 61 -------------- .../iterative_multislice_ptychography.py | 65 --------------- .../phase/iterative_overlap_tomography.py | 83 ------------------- .../iterative_singleslice_ptychography.py | 61 -------------- 5 files changed, 335 deletions(-) diff --git a/py4DSTEM/process/phase/iterative_mixedstate_multislice_ptychography.py b/py4DSTEM/process/phase/iterative_mixedstate_multislice_ptychography.py index 43f08a157..863eeb35e 100644 --- a/py4DSTEM/process/phase/iterative_mixedstate_multislice_ptychography.py +++ b/py4DSTEM/process/phase/iterative_mixedstate_multislice_ptychography.py @@ -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, diff --git a/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py b/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py index accab6714..398cd679b 100644 --- a/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py +++ b/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py @@ -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, diff --git a/py4DSTEM/process/phase/iterative_multislice_ptychography.py b/py4DSTEM/process/phase/iterative_multislice_ptychography.py index 0db30f4cb..573a16873 100644 --- a/py4DSTEM/process/phase/iterative_multislice_ptychography.py +++ b/py4DSTEM/process/phase/iterative_multislice_ptychography.py @@ -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, diff --git a/py4DSTEM/process/phase/iterative_overlap_tomography.py b/py4DSTEM/process/phase/iterative_overlap_tomography.py index 1ccbf50b1..37a2ee9b1 100644 --- a/py4DSTEM/process/phase/iterative_overlap_tomography.py +++ b/py4DSTEM/process/phase/iterative_overlap_tomography.py @@ -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, diff --git a/py4DSTEM/process/phase/iterative_singleslice_ptychography.py b/py4DSTEM/process/phase/iterative_singleslice_ptychography.py index 42f5956cf..e94d196c9 100644 --- a/py4DSTEM/process/phase/iterative_singleslice_ptychography.py +++ b/py4DSTEM/process/phase/iterative_singleslice_ptychography.py @@ -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,