WrightTools.calibration module

Calibration.

class WrightTools.calibration.Calibration(axis_names, axis_units, points, values, name='calibration', note='')[source]

Bases: object

Container for unstructured calibration data.

__init__(axis_names, axis_units, points, values, name='calibration', note='')[source]

Create an unstructured calibration object.

Parameters:
  • points (list of lists) – List or list-like of lists. May be a 2D numpy array.
  • axis_units (list of strings) – Units for each axis.
  • values (1D array-like) – Corrections for each coordinate.
  • name (string (optional)) – Name of calibration. Default is ‘calibration’
  • note (string (optional)) – Note about calibration. Default is an empty string.
append(points, values, units='same')[source]

Add new data to the calibration.

Parameters:
  • points (list of lists) – List or list-like of lists. May be a 2D numpy array.
  • values (1D array-like) – Corrections for each coordinate.
  • units ('same' or list of strings (optional)) – Units of points. Default is ‘same’.
convert(axis_units)[source]

Convert axes to new units.

Parameters:axis_units (list of string) – New units for each axis.
get_positions(value, **kwargs)[source]

Get all valid coordinates.

Returns:All valid coordinates, defined for all axes. List may be empty.
Return type:list of dictionaries
get_value(positions, units='same')[source]

Get the value at some particular coordinate using linear interpolation.

Parameters:
  • positions (list of numbers) – Coordinate to evaluate at.
  • units ('same' or list of strings (optional)) – Units of positions. Default is ‘same’.
map_points(points, units='same')[source]

Map the points onto new points using interpolation.

Parameters:
  • points (int or array) – The number of new points (between current limits) or the new points themselves.
  • units (str (optional.)) – The input units if given as array. Default is same. Units of coset object are not changed.
plot(autosave=False, save_directory=None, file_name=None)[source]

Plot the calibration.

Parameters:
  • autosave (boolean (optional)) – Toggle automatic saving. Default is False.
  • save_directory (string or None) – Location to save file. If None (default), uses current working directory.
  • file_name (string (optional)) – Name for output image. If None (default), uses own name and a timestamp.
Returns:

  • output – Save path if autosave is True, fig object if autosave is False.
  • .. note:: Only works for one and two-dimensional calibrations at this time.

save(save_directory=None, file_name=None, plot=True, verbose=True)[source]

Save the calibration.

Parameters:
  • save_directory (string or None (optional)) – Directory to save to. If None (default), saves to current working directory.
  • file_name (string or None (optional)) – Name for output file. If None (default), uses own name and a timestamp.
  • plot (boolean (optional)) – Toggle saving a plot of the calibration as well. Default is True.
  • verbose (boolean (optional)) – Toggle talkback. Default is True.
Returns:

Full path to saved file.

Return type:

string

WrightTools.calibration.from_file(path)[source]

Generate a calibration object from a file.

Parameters:path (string) – Filepath.
Returns:
Return type:WrightTools.calibration.Calibration
WrightTools.calibration.get_label(name, units)[source]

Get label.

Parameters:
Returns:

Label.

Return type:

string