polyTEM.crystal_peaks.flow_fieldsΒΆ

Functions

choose_file(path, file_number, file_type[, ...])

Display all files in the specified directory and number them in order.

color_by_angle(theta[, inverse])

Assigns r, g, b values based on input angle. Inputs: theta: angle in degrees. Can be a single value or an array. Outputs: tuple of r, g, b values, each of which has the same shape as the input values.

define_subgrid(a1_shape, a1_spacing, ...)

This function returns six functions that allow for easy conversion between cartesian coordinates, row-column coordinates, and subgrids within row-column coordinates.

determine_peaks(intensity_matrix, cutoff, ...)

Returns a matrix of peak positions derived from a matrix of diffraction data.

draw_scalebar(ax, length)

get_filenames(path, file_type[, extension])

Provide a list of files in the specified directory, containing the specified file_type string

get_vector(theta, length)

Returns the 2d vector of the specified length at the specified angle in degrees

load_q_intensity_matrix(big_data_path, ...)

Loads a numpy matrix with the correct data using my (Luke's) naming conventions.

normalize_and_reshape_intensity_matrix(...)

plot_flow_fields(datacube, peaks_matrix, ...)

Plot flow Fields, By Luke Balhorn and Camila.

plot_graded_lines(trimmed_lines, red, green, ...)

Plots lines with non-constant RGBA or Width values. Inputs: trimmed_lines: (4 x m x n) matrix, which contains the (x, y, theta, is_active) values for each point m along each line n. This is the output of the trim_lines function. red: color value between 0 and 1 green: color value between 0 and 1 blue: color value between 0 and 1 alpha: transparency value between 0 and 1, where 1 is fully opaque and 0 is fully transparent. Interestingly, transparency does not seem to increase rendering time. width: line width. The value is not capped but is usually on the order of 1.

plot_solid_lines(propagated_lines[, ...])

Plots lines with a constant color and width. Inputs: propagated_lines: (4 x m x n) matrix, which contains the (x, y, theta, is_active) values for each point m along each line n. is_active is a binary value which is true if the line is still being drawn at that point. min_length: lines shorter than this will not be drawn sparsity: values greater than 1 reduce the number of lines drawn for speed and readability purposes. Outputs: fig: matplotlib.pyplot figure produces by this function.

prepare_intensity_matrix(matrix[, rotate])

prepare_line_data(trimmed_lines, ...)

Combines data from trimmed lines and normalized intensities to give the angle, intensity, and other parameters at each point in the trimmed lines.

propagate_lines(line_seeds, peak_matrix, ...)

Lines are extended in both direction from each line seed to create a more readable image.

read_metadata_from_filename(filename)

scale_values(values[, vmin, brightness, ...])

Rescales data such as intensity, q, or similar to values suitable for linewidth, alpha, or similar.

seed_lines(peak_matrix, step_size[, ...])

Uses the peak matrix to produce a 3xn matrix of x, y, angle values to act as the start of lines that will be drawn.

shift_mask(mask, target_array_shape, shift)

Moves a mask by an integer number of spaces in each direction. This allows a shape such as an ellipse to be drawn at any point on a matrix, and is faster than methods like np.roll. Inputs: mask: output of an np.where() function that you would like to move target_array_shape: shape of the array that was used in the np.where() function shift: tuple or numpy array of the number of spaces to move in each direction. Ouputs: formatted_mask: shifted mask in the same format as the original mask.

smooth(array, smoothing_length)

Smooth a 2D array along axis 1 using a moving average.

trim_lines(propagated_lines, ...[, ...])

Trims lines created by the propagate_lines function for purposes of readability, rendering speed, and homogeneous line density. Inputs: propagated_lines: (4 x m x n) matrix, which contains the (x, y, theta, is_active) values for each point m along each line n. is_active is a boolean value which is true if the line is still being drawn at that point. intensity_matrix_shape: dimensions provided by intensity_matrix.shape step_size: real space distance between points in the intensity matrix, i.e. 10nm line_spacing: minimum distance between two lines before they start to overlap. Note that some overlaps may be allowed. spacing_resolution: higher values reduce geometric artifacts that cause greater spacing at certain angles. angle_spacing_degrees: minimum angular distance between two crossing lines before those lines count as overlapping. max_overlap_fraction: fraction of line that can overlap with already-drawn lines. If the line overlaps by more than this it is not drawn. min_length: lines with less points than the minimum length are not drawn verbose: Boolean. When true, extra troubleshooting information is shown, including the space-filling process. Outputs: trimmed_lines: matplotlib.pyplot figure drawn by the function.

Classes

ProgressBar(total_tasks[, interval])