babelscan.babelscan

babelscan

babelscan object for holding many types of scan data

Class: Scan

class babelscan.babelscan.Scan(namespace, alt_names=None, default_values=None, **kwargs)[source]

Scan class Contains a namespace of data associated with names and a seperate dictionary of name associations, allowing multiple names to reference the same data.

namespace = {

‘data1’: [1,2,3], ‘data2’: [10,20,30]

} alt_names = {

‘xaxis’: ‘data1’, ‘yaxis’: ‘data2’,

} dh = Scan(namespace, alt_names) dh(‘xaxis’) >> returns [1,2,3]

Scan is usually inhereted by subclasses HdfScan, DatScan or CsvScan.

Parameters:
  • namespace – dict : dict of names and data {name: data}

  • alt_names – dict or None* : dict of alternative names to names in namespace

  • kwargs – key-word-argments as options shwon below, keywords and argmuents will be added to the namespace.

Options:

reload - True/False*, if True, reload mode is activated, reloading data on each operation label_name - str, add a name to use to automatically find the label label_command - str, format specifier for label, e.g. ‘{scan_number}’ title_name - str, add a name to use to automatically find the title title_command - str, format specifier for title, e.g. ‘#{scan_number} Energy={en:5.2f} keV’ scan_command_name - str, add a name to use to automatically find the scan command start_time_name - str, add a name to use to automatically find the start_time end_time_name - str, add a name to use to automatically find the end_time axes_name - str, add a name to use to automatically find the axes (xaxis) signal_name - str, add a name to use to automatically find the signal (yaxis) image_name - str, add a name to use to automatically find the detector image str_list - list of str, list of names to display when print(self) signal_operation - str, operation to perform on signal, e.g. ‘/Transmission’ error_function - func., operation to perform on signal to generate errors. e.g. np.sqrt debug - str or list of str, options for debugging, options:

‘namespace’ - displays when items are added to the namespace ‘eval’ - displays when eval operations are used

Functions add2namespace(name, data=None, other_names=None, hdf_address=None)

set data in namespace

add2strlist(names)

Add to list of names in str output

array(names, array_length=None)

Return numpy array of data with same length

axes()

Return default axes (xaxis) data

eval(operation)

Evaluate operation using names in dataset or in associated names

find_image(multiple=False)

Return address of image data in hdf file

get_plot_data(xname=None, yname=None, signal_op=None, error_op=None)

Return xdata, ydata, yerror, xname, yname

image(idx=None, image_address=None)

Load image from hdf file, works with either image addresses or stored arrays

image_roi(cen_h=None, cen_v=None, wid_h=31, wid_v=31)

Create new region of interest from detector images

image_roi_op(operation)

Create new region of interest (roi) from image data and return sum and maxval

image_roi_sum(cen_h=None, cen_v=None, wid_h=31, wid_v=31)

Create new region of interest

image_size()

Returns the image size

label(new_label=None)

Set or Return the scan label. The label is a short identifier for the scan, such as scan number

name(name)

Return corrected name from namespace

options(**kwargs)

Set or display options

reload_mode(mode=None)

Turns on reload mode - reloads the dataset each time

reset()

Reset the namespace

scan_command()

Returns scan command

show_namespace()

return str of namespace

signal()

Return default signal (yaxis) data

string(names, str_format=None)

Return formated string of data

string_format(operation)

Process a string with format specified in {} brackets, values will be returned.

title(new_title=None)

Set or Return the title

value(names, array_function=None)

Return single value of data

Class: MultiScan

class babelscan.babelscan.MultiScan(scan_list, variables=None)[source]

Class for holding multiple Scan objects