view#

Define functions for plotting and viewing data of various types.

tike.view.complexHSV_to_RGB(img0)[source]#

Convert a complex valued array to RGB representation.

Takes a complex valued ND array, represents the phase as hue, magnitude as value, and saturation as all ones in a new (…, 3) shaped array. This is then converted to the RGB colorspace.

Assumes real valued inputs have a zero imaginary component.

Parameters

img0 (numpy.array) – A (…) shaped complex64 numpy array.

Returns

rgb_img – The (…, 3) shaped array which represents the input complex valued array in a RGB colorspace.

Return type

numpy.array

tike.view.plot_affine_transform(ax, t, color=(0.0, 0.0, 0.0, 1.0))[source]#

Draw a unit circle and principal axes transformed by t.

Draws an unfilled unit circle and the principal axes in the space defined by the transform t onto the axes, ax. The zero-th principal vector is a full arrow, and the first principal vector is a left-half arrow.

Any valid Matplotlib color may be specified.

Parameters
  • ax (matplotlib.axes.Axes) –

  • t (AffineTransform) –

  • color (Union[Tuple[float, float, float], str]) –

tike.view.plot_complex(Z, rmin=None, rmax=None, imin=None, imax=None)[source]#

Plot real and imaginary parts of a 2D image size by side.

Takes parameters rmin, rmax, imin, imax to scale the ranges of the real and imaginary plots.

tike.view.plot_cost_convergence(costs, times)[source]#

Plot a twined plot of cost vs iteration/cumulative-time

The plot is a semi-log line plot with two lines. One line shows cost as a function of iteration (bottom horizontal); one line shows cost as a function of cumulative wall-time (top horizontal).

Parameters
  • costs ((NUM_ITER, ), (NUM_ITER, NUM_BATCH, ) array-like) – The objective cost at each iteration.

  • times ((NUM_ITER, ) array-like) – The wall-time for each iteration in seconds.

Returns

  • ax1 (matplotlib.axes._subplots.AxesSubplot)

  • ax2 (matplotlib.axes._subplots.AxesSubplot)

tike.view.plot_eigen_weights(weights)[source]#

Plot stacked line plots of probe intensity weights by position.

tike.view.plot_footprint(theta, v, h)[source]#

Plot 2D projections of the trajectory for each pair of axes.

tike.view.plot_phase(Z, amin=None, amax=None)[source]#

Plot the amplitude and phase of a 2D image side by side.

Takes parameters amin, amax to scale the range of the amplitude. The phase is scaled to the range -pi to pi.

tike.view.plot_position_error(true, *args, indices=None)[source]#

Create a spaghetti plot of position errors.

Parameters
  • (N (args) – The true positions.

  • arraylike (2)) – The true positions.

  • (N – A sequence of positions.

  • arraylike – A sequence of positions.

tike.view.plot_positions(true, *args)[source]#

Plot 2D positions to current axis.

Optionally show the progression of scanning position movement. Draws a line from a starting triangle to an ending circle showing the path taken between with a line.

Parameters
  • (N (args) – True scan positions; marked with a plus.

  • 2) – True scan positions; marked with a plus.

  • (N – A sequence of positions; starts with triangle ends with a circle.

  • 2) – A sequence of positions; starts with triangle ends with a circle.

tike.view.plot_positions_convergence(true, *args)[source]#

Plot position error in 2D.

Shows the progression of scanning position movement toward the “true” position. Shifts the coordinates of each position, so the true positions are at the origin. Draws a line from a starting triangle to an ending circle showing the path taken between with a line.

Parameters
  • (N (args) – True scan positions; marked with a plus.

  • 2) – True scan positions; marked with a plus.

  • (N – A sequence of positions; starts with triangle ends with a circle.

  • 2) – A sequence of positions; starts with triangle ends with a circle.

tike.view.plot_probe_power(probe)[source]#

Draw a pie chart of relative power of each probe to the current axes.

The power of the probe is computed as the sum of absolute squares over all pixels in the probe.

Parameters

probe ((..., 1, 1, SHARED, WIDE, HIGH) complex64) – The probes to be analyzed.

tike.view.plot_probe_power_series(power)[source]#

Draw a stacked area chart of the probe power to the current axis.

Parameters
  • (N (power) – The power of M probes over N iterations.

  • M) – The power of M probes over N iterations.

tike.view.plot_sino_coverage(theta, v, h, dwell=None, bins=[16, 8, 4], probe_grid=[[1]], probe_shape=(0, 0))[source]#

Plot projections of minimum coverage in the sinogram space.

tike.view.plot_trajectories(theta, v, h, t)[source]#

Plot each trajectory as a function of time in the current figure.

Plots two subplots in the current figure. The top one shows horizonal and vertical position as a function of time and the bottom shows angular position as a function of time.

Returns

ax1, ax1b – Handles to the two axes

Return type

axes

tike.view.resize_complex_image(img0, scale_factor=(1, 1), interpolation=cv2.INTER_LINEAR)[source]#

Resize a complex image via interpolation.

Takes a M0 x N0 complex valued array, splits it up into real and imaginary, and resizes (interpolates) the horizontal and vertical dimensions, yielding a new array of size M1 x N1. The result can then be used for further plotting using e.g. imshow() or imsave() from matplotlib.

Parameters
  • img0 (numpy.array) – A M0 x N0 complex64 or complex128 numpy array.

  • scale_factor (2 element positive valued float tuple,) – ( horizontal resize/scale, vertical resize/scale )

  • interpolation (int) – cv.INTER_NEAREST = 0, cv.INTER_LINEAR = 1 cv.INTER_CUBIC = 2, cv.INTER_AREA = 3 cv.INTER_LANCZOS4 = 4

Returns

imgRS – The new M1 x N1 which has been resized according to the scale factors above.

Return type

numpy.array

tike.view.trajectory(x, y, connect=True, frame=None, pause=True, dt=1e-12)[source]#

Plot a 2D trajectory.