Skip to content
Snippets Groups Projects
Commit d575f4fb authored by Jan Caron's avatar Jan Caron
Browse files

Renamed plotting commands to *_plot()

parent 4570a75c
No related branches found
No related tags found
No related merge requests found
......@@ -274,8 +274,8 @@ class DataSet(object):
mlab.axes(plot)
return plot
def display_phase(self, mag_data=None, title='Phase Map',
cmap='RdBu', limit=None, norm=None):
def phase_plots(self, mag_data=None, title='Phase Map',
cmap='RdBu', limit=None, norm=None):
"""Display all phasemaps saved in the :class:`~.DataSet` as a colormesh.
Parameters
......@@ -301,17 +301,17 @@ class DataSet(object):
None
"""
self._log.debug('Calling display_phase')
self._log.debug('Calling phase_plots')
if mag_data is not None:
phase_maps = self.create_phase_maps(mag_data)
else:
phase_maps = self.phase_maps
[phase_map.display_phase('{} ({})'.format(title, self.projectors[i].get_info()),
cmap=cmap, limit=limit, norm=norm)
[phase_map.phase_plot('{} ({})'.format(title, self.projectors[i].get_info()),
cmap=cmap, limit=limit, norm=norm)
for (i, phase_map) in enumerate(phase_maps)]
def display_combined(self, mag_data=None, title='Combined Plot', cmap='RdBu', limit=None,
norm=None, gain='auto', interpolation='none', grad_encode='bright'):
def combined_plots(self, mag_data=None, title='Combined Plot', cmap='RdBu', limit=None,
norm=None, gain='auto', interpolation='none', grad_encode='bright'):
"""Display all phasemaps and the resulting color coded holography images.
Parameters
......@@ -347,12 +347,12 @@ class DataSet(object):
None
"""
self._log.debug('Calling display_combined')
self._log.debug('Calling combined_plots')
if mag_data is not None:
phase_maps = self.create_phase_maps(mag_data)
else:
phase_maps = self.phase_maps
for (i, phase_map) in enumerate(phase_maps):
phase_map.display_combined('{} ({})'.format(title, self.projectors[i].get_info()),
cmap, limit, norm, gain, interpolation, grad_encode)
phase_map.combined_plot('{} ({})'.format(title, self.projectors[i].get_info()),
cmap, limit, norm, gain, interpolation, grad_encode)
plt.show()
......@@ -40,7 +40,7 @@ class PhaseMap(object):
corresponding holographic contour map are provided. Holographic contour maps are created by
taking the cosine of the (optionally amplified) phase and encoding the direction of the
2-dimensional gradient via color. The directional encoding can be seen by using the
:func:`~.make_color_wheel` function. Use the :func:`~.display_combined` function to plot the
:func:`~.make_color_wheel` function. Use the :func:`~.combined_plot` function to plot the
phase map and the holographic contour map next to each other.
Attributes
......@@ -591,8 +591,8 @@ class PhaseMap(object):
phase = np.loadtxt(filename, delimiter='\t', skiprows=2)
return cls(a, phase)
def display_phase(self, title='Phase Map', cbar_title=None, cmap='RdBu', limit=None,
norm=None, axis=None, cbar=True, show_mask=True, show_conf=True):
def phase_plot(self, title='Phase Map', cbar_title=None, cmap='RdBu', limit=None,
norm=None, axis=None, cbar=True, show_mask=True, show_conf=True):
"""Display the phasemap as a colormesh.
Parameters
......@@ -624,7 +624,7 @@ class PhaseMap(object):
The axis on which the graph is plotted and the colorbar.
"""
self._log.debug('Calling display_phase')
self._log.debug('Calling phase_plot')
# Take units into consideration:
phase = self.phase * self.UNITDICT[self.unit]
if limit is None:
......@@ -671,8 +671,8 @@ class PhaseMap(object):
# Return plotting axis:
return axis
def display_phase3d(self, title='Phase Map', cmap='RdBu'):
"""Display the phasemap as a 3-D surface with contourplots.
def phase3d_plot(self, title='Phase Map', cmap='RdBu'):
"""Display the phasemap as a 3D surface with contourplots.
Parameters
----------
......@@ -688,7 +688,7 @@ class PhaseMap(object):
The axis on which the graph is plotted.
"""
self._log.debug('Calling display_phase3d')
self._log.debug('Calling phase3d_plot')
# Take units into consideration:
phase = self.phase * self.UNITDICT[self.unit]
# Create figure and axis:
......@@ -707,8 +707,8 @@ class PhaseMap(object):
# Return plotting axis:
return axis
def display_holo(self, title=None, gain='auto', axis=None, grad_encode='bright',
interpolation='none'):
def holo_plot(self, title=None, gain='auto', axis=None, grad_encode='bright',
interpolation='none'):
"""Display the color coded holography image.
Parameters
......@@ -734,7 +734,7 @@ class PhaseMap(object):
The axis on which the graph is plotted.
"""
self._log.debug('Calling display_holo')
self._log.debug('Calling holo_plot')
# Calculate gain if 'auto' is selected:
if gain == 'auto':
gain = 4 * 2 * np.pi / (np.abs(self.phase).max() + 1E-30)
......@@ -789,10 +789,10 @@ class PhaseMap(object):
# Return plotting axis:
return axis
def display_combined(self, sup_title='Combined Plot', phase_title='Phase Map', holo_title=None,
cbar_title=None, cmap='RdBu', limit=None, norm=None, gain='auto',
interpolation='none', grad_encode='bright', cbar=True, show_mask=True,
show_conf=True):
def combined_plot(self, sup_title='Combined Plot', phase_title='Phase Map', holo_title=None,
cbar_title=None, cmap='RdBu', limit=None, norm=None, gain='auto',
interpolation='none', grad_encode='bright', cbar=True, show_mask=True,
show_conf=True):
"""Display the phase map and the resulting color coded holography image in one plot.
Parameters
......@@ -838,19 +838,19 @@ class PhaseMap(object):
The axes on which the graphs are plotted.
"""
self._log.debug('Calling display_combined')
self._log.debug('Calling combined_plot')
# Create combined plot and set title:
fig = plt.figure(figsize=(15, 7))
fig.suptitle(sup_title, fontsize=20)
# Plot holography image:
holo_axis = fig.add_subplot(1, 2, 1, aspect='equal')
self.display_holo(title=holo_title, gain=gain, axis=holo_axis, interpolation=interpolation,
grad_encode=grad_encode)
self.holo_plot(title=holo_title, gain=gain, axis=holo_axis, interpolation=interpolation,
grad_encode=grad_encode)
# Plot phase map:
phase_axis = fig.add_subplot(1, 2, 2, aspect='equal')
fig.subplots_adjust(right=0.85)
self.display_phase(title=phase_title, cbar_title=cbar_title, cmap=cmap, limit=limit,
norm=norm, axis=phase_axis, cbar=cbar, show_mask=show_mask,
show_conf=show_conf)
self.phase_plot(title=phase_title, cbar_title=cbar_title, cmap=cmap, limit=limit,
norm=norm, axis=phase_axis, cbar=cbar, show_mask=show_mask,
show_conf=show_conf)
# Return the plotting axes:
return phase_axis, holo_axis
......@@ -99,14 +99,14 @@ class Main(QMainWindow, UI_MainWindow):
self.phase_mapper = PhaseMapperRDFC(kernel)
self.phase_map = self.phase_mapper(self.projector(self.mag_data))
self.canvasPhase.figure.axes[0].clear()
self.phase_map.display_phase(axis=self.canvasPhase.figure.axes[0], cbar=False)
self.phase_map.phase_plot(axis=self.canvasPhase.figure.axes[0], cbar=False)
if self.checkBoxSmooth.isChecked():
interpolation = 'bilinear'
else:
interpolation = 'none'
self.canvasHolo.figure.axes[0].clear()
self.phase_map.display_holo(axis=self.canvasHolo.figure.axes[0], gain=gain,
interpolation=interpolation)
self.phase_map.holo_plot(axis=self.canvasHolo.figure.axes[0], gain=gain,
interpolation=interpolation)
self.canvasPhase.draw()
self.canvasHolo.draw()
......
......@@ -77,8 +77,8 @@ class Main(QMainWindow, UI_MainWindow):
show_conf = self.checkBox_conf.isChecked()
self.canvas.figure.axes[0].clear()
self.canvas.figure.axes[0].hold(True)
self.phase_map.display_phase('PhaseMap', axis=self.canvas.figure.axes[0],
show_mask=show_mask, show_conf=show_conf, cbar=False)
self.phase_map.phase_plot('PhaseMap', axis=self.canvas.figure.axes[0],
show_mask=show_mask, show_conf=show_conf, cbar=False)
self.canvas.draw()
def update_mask(self):
......
......@@ -43,9 +43,9 @@ def reconstruction_2d_from_phasemap(filename, b_0=1, lam=1E-3, max_iter=100, ram
if ar_dens is None:
ar_dens = np.max(dim) // 128
mag_data_rec.quiver_plot('Reconstructed Distribution', ar_dens=ar_dens)
phase_map.display_combined('Input Phase')
phase_map.combined_plot('Input Phase')
phase_map -= fwd_model.ramp(index=0)
phase_map.display_combined('Input Phase (ramp corrected)')
phase_map.combined_plot('Input Phase (ramp corrected)')
phase_map_rec = pm(mag_data_rec)
title = 'Reconstructed Phase'
if ramp_order >= 0:
......@@ -54,10 +54,10 @@ def reconstruction_2d_from_phasemap(filename, b_0=1, lam=1E-3, max_iter=100, ram
if ramp_order >= 1:
print('ramp:', ramp)
title += ', (Fitted Ramp: (u:{:.2g}, v:{:.2g}) [rad/nm]'.format(*ramp)
phase_map_rec.display_combined(title)
phase_map_rec.combined_plot(title)
difference = (phase_map_rec.phase - phase_map.phase).mean()
(phase_map_rec - phase_map).display_phase('Difference (mean: {:.2g})'.format(difference))
(phase_map_rec - phase_map).phase_plot('Difference (mean: {:.2g})'.format(difference))
if ramp_order is not None:
fwd_model.ramp(0).display_combined('Fitted Ramp')
fwd_model.ramp(0).combined_plot('Fitted Ramp')
# Return reconstructed magnetisation distribution and cost function:
return mag_data_rec, cost
......@@ -71,7 +71,7 @@ def reconstruction_3d_from_magdata(filename, b_0=1, lam=1E-3, max_iter=100, ramp
fwd_model.finalize()
# Plot input:
if plot_input:
data.display_phase()
data.phase_plots()
# Plot results:
if plot_results:
data.display_mask(ar_dens=ar_dens)
......
......@@ -28,5 +28,5 @@ mag_data = py.VectorData(a, magnitude)
mag_data.save_to_hdf5('magdata_dat_{}'.format(filename.replace('.dat', '.hdf5')), overwrite=True)
mag_data.quiver_plot3d(ar_dens=4, coloring='amplitude')
mag_data.quiver_plot3d(ar_dens=4, coloring='angle')
py.pm(mag_data).display_combined(interpolation='bilinear')
py.pm(mag_data).combined_plot(interpolation='bilinear')
plt.show()
......@@ -124,5 +124,5 @@ a *= 10
mag_data = pr.VectorData(a, magnitude)
mag_data.save_to_hdf5('magdata_vtk_{}'.format(filename.replace('.vtk', '.hdf5')), overwrite=True)
# Plot stuff:
pr.pm(mag_data).display_combined()
pr.pm(mag_data).combined_plot()
plt.show()
......@@ -55,5 +55,5 @@ confidence = np.where(np.asarray(im_conf) >= threshold, 1, 0)
# Create and save PhaseMap object:
phase_map = pr.PhaseMap(a, phase, mask, confidence, unit='rad')
phase_map.save_to_hdf5(filename, overwrite=True)
phase_map.display_combined()
phase_map.combined_plot()
plt.show()
......@@ -41,5 +41,5 @@ if path_mask is not None:
# Create and save PhaseMap object:
phase_map = py.PhaseMap(a, phase, mask, confidence=None, unit='rad')
phase_map.save_to_hdf5(filename, overwrite=True)
phase_map.display_combined()
phase_map.combined_plot()
plt.show()
......@@ -37,5 +37,5 @@ mask = np.where(np.asarray(im_mask) >= threshold, True, False)
# Create and save PhaseMap object:
phase_map = pr.PhaseMap(a, phase, mask, confidence=None, unit='rad')
phase_map.save_to_hdf5(filename, overwrite=True)
phase_map.display_combined()
phase_map.combined_plot()
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment