Commit b0c8f349 authored by Matthijs's avatar Matthijs
Browse files

NB: maintaining a reference to the stackviewer object keeps it alive

parent 90226372
......@@ -88,5 +88,5 @@ def Phase_graphics(config, output):
def Phase_graphics_3d(config, output):
# TODO: do something smart
# TODO: combine 3D graphics and convergence plots
return 0
......@@ -88,18 +88,18 @@ class XYZStackViewer:
axcolor = None # 'lightgoldenrodyellow'
sliderlength = 0.17
subax1 = self.fig.add_axes([0.15, 0.1, sliderlength, 0.03], facecolor=axcolor)
self.ax1slider = Slider(subax1, 'Slice', 0 + limit_sliders[0], self.shape[0] - limit_sliders[0],
self.ax1slider = Slider(subax1, 'Slice', 0 + limit_sliders[0], -1 + self.shape[0] - limit_sliders[0],
valinit=self.indices[0], valstep=1, valfmt='%d')
self.ax1slider.on_changed(self.update_1)
subax2 = self.fig.add_axes([0.41, 0.1, sliderlength, 0.03], facecolor=axcolor)
self.ax2slider = Slider(subax2, 'Slice', 0 + limit_sliders[1], self.shape[0] - limit_sliders[1],
valinit=self.indices[0], valstep=1, valfmt='%d')
self.ax2slider = Slider(subax2, 'Slice', 0 + limit_sliders[1], -1 + self.shape[1] - limit_sliders[1],
valinit=self.indices[1], valstep=1, valfmt='%d')
self.ax2slider.on_changed(self.update_2)
subax3 = self.fig.add_axes([0.67, 0.1, sliderlength, 0.03], facecolor=axcolor)
self.ax3slider = Slider(subax3, 'Slice', 0 + limit_sliders[2], self.shape[0] - limit_sliders[2],
valinit=self.indices[0], valstep=1, valfmt='%d')
self.ax3slider = Slider(subax3, 'Slice', 0 + limit_sliders[2], -1 + self.shape[2] - limit_sliders[2],
valinit=self.indices[2], valstep=1, valfmt='%d')
self.ax3slider.on_changed(self.update_3)
self.fig.show()
......
......@@ -64,9 +64,10 @@ def data_processor(config):
config['u_0'] = inp * np.exp(1j * ph_init)
if config['dataprocessor_plotting']:
XYZStackViewer(inp, cmap='viridis')
XYZStackViewer(shifted_fft(inp).real)
# TODO: investigate why these viewers crash after a limited time
input_viewer = XYZStackViewer(inp, cmap='viridis')
config['input viewer'] = input_viewer # the reference keeps the matplotlib object alive
support_viewer = XYZStackViewer(shifted_fft(inp).real)
config['support viewer'] = support_viewer # the reference keeps the matplotlib object alive
# Other settings
config['fresnel_nr'] = 0
......
......@@ -166,18 +166,6 @@ class Phase(Problem):
# (self.config['Ny'] // 4, self.config["Nx"] // 4, self.config['Nz'] // 4)
self.output[key] = self.output[key][zmy:-zmy, zmx:-zmx, zmz:-zmz]
# # Old code, developed for 2D orbital imaging:
# yc, xc = int(self.config['Ny'] / 2), int(self.config["Nx"] / 2)
# for key in ['u', 'u1', 'u2']:
# self.output[key] = array_tools.roll_to_pos(self.output[key], yc, xc, move_maximum=True)
# self.output[key] = array_tools.roll_to_pos(self.output[key], yc, xc)
# # This sequence will work for objects *with a small support* even if they lie over the edge of the array
# if 'interpolate_result' in self.config and self.config['interpolate_result']:
# self.output[key] = interpolation.fourier_interpolate(self.output[key])
# if 'zoomin_on_result' in self.config and self.config['zoomin_on_result']:
# zmy, zmx = int(self.config['Ny'] / 4), int(self.config["Nx"] / 4)
# self.output[key] = self.output[key][zmy:-zmy, zmx:-zmx]
def show(self):
"""
Generates graphical output from the solution
......@@ -187,14 +175,14 @@ class Phase(Problem):
_graphics = getattr(Graphics, self.config['graphics_display'])
_graphics(self.config, self.output)
def save(self):
def save(self, save_dir=None):
"""
Saves inputs and outputs of the reconstruction procedure
Necessary inputs: save directory,
Necessary inputs: save directory. Takes from self.config is None is given
:return:
"""
# TODO: some basic procedure. perhaps just a python pickle? (of the config and output dictionaries)
# TODO: some basic saving procedure. perhaps just a python pickle? (of the config and output dictionaries)
raise NotImplementedError
......@@ -10,7 +10,7 @@ The "ProxOperators"-module contains various specific operators that do the actua
import numpy as np
from numpy import conj, dot, empty, ones, sqrt, sum, zeros, exp, nonzero, log, tile, shape, real, zeros_like, pi
# from pyfftw.interfaces.scipy_fftpack import fft2, ifft2
from numpy.fft import fft2, ifft2, ifft , fftshift, ifftshift# TODO: switch to scipy.fftpack? (is faster supposedly)
from numpy.fft import fft2, ifft2, ifft , fftshift, ifftshift
__all__ = ["P_diag", "P_parallel", "magproj", "Approx_P_JWST_Poisson", "P_amp", "P_SP", "Approx_PM_Gaussian",
"Approx_PM_Poisson", "P_S", "P_S_real", "P_sequential_hyperplane_odd", "P_sequential_hyperplane_even",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment