WrightTools.kit module

General-purpose tool kit.


Handle communication with an INI file.

Spline(xi, yi[, k, s, ignore_nans])


TimeStamp([at, timezone])

Class for representing a moment in time.


Context manager for timing code.

closest_pair(arr[, give])

Find the pair of indices corresponding to the closest elements in an array.

diff(xi, yi[, order])

Take the numerical derivative of a 1D array.

discover_dimensions(arr, cols)

Discover the dimensions of a flattened multidimensional array.

enforce_mask_shape(mask, shape)

Reduce a boolean mask to fit a given shape.

fft(xi, yi[, axis])

Take the 1D FFT of an N-dimensional array and return “sensible” properly shifted arrays.

flatten_list(items[, seqtypes, in_place])

Flatten an irregular sequence.

fluence(power_mW, color, beam_radius, …[, …])

Calculate the fluence of a beam.

get_index(lis, argument)

Find the index of an item, given either the item or index as an argument.


Get path matching a name.

glob_handler(extension[, folder, identifier])

Return a list of all files matching specified inputs.

intersperse(lis, value)

Put value between each existing item in list.


Given a set of arrays, return the joint shape.

leastsqfitter(p0, datax, datay, function[, …])

Conveniently call scipy.optmize.leastsq().


Reduce a boolean mask, removing all false slices in any dimension.

mono_resolution(grooves_per_mm, slit_width, …)

Calculate the resolution of a monochromator.

nm_width(center, width[, units])

Given a center and width, in energy units, get back a width in nm.


Determine if a set of arrays are orthogonal.


s -> (s0,s1), (s1,s2), (s2, s3), …


Remove nans in a set of 1D arrays.


Take a list of nD arrays and return a new list of nD arrays.

smooth_1D(arr[, n, smooth_type])

Smooth 1D data using a window function.


Turn a string into a valid python identifier.

svd(a[, i])

Singular Value Decomposition.

symmetric_sqrt(x[, out])

Compute the ‘symmetric’ square root: sign(x) * sqrt(abs(x)).


Generate a Timestamp object from a RFC3339 formatted string.

unique(arr[, tolerance])

Return unique elements in 1D array, within tolerance.

valid_index(index, shape)

Get a valid index for a broadcastable shape.

zoom2D(xi, yi, zi[, xi_zoom, yi_zoom, …])

Zoom a 2D array, with axes.