Skip to content

Function overview

tincotema edited this page Dec 6, 2023 · 3 revisions

List of useful functions

General functions

psave

pickle binary dump:

mcpw.mcstas_wrapper.psave(obj, file_path)

pload

pickle binary load (returns a object):

obj = mcpw.mcstas_wrapper.pload(file_path)

scan_name

function to determine if a set of mcvariables triggers a Scan returns the name of the variable to scan or 'False'

'str' = mcpw.mcstas_wrapper.scan_name(mcvar)

scan

returns the scan object if one was set in the mcvariable dict otherwise 'None'

obj = mcpw.mcstas_wrapper.scan(mcvar)

mcplot

the original mcplot function

mcpw.mcstas_wrapper.mcpot(var,mcvar)

return_detector

custom function to get detector output and optionally plot them directly by handing over a matplotlib axis:

array, dict = mcpw.mcstas_wrapper.return_detector(var,mcvar, detector = "name"[, N=-1, plot=axis])

dict contains more information about the detector

mcvar_list

returns a list of mcvar dicts corresponding to scans or var_list. if neither is given, the output has length 1 with the original mcvar dict.

array = mcpw.mcstas_wrapper.mcvar_list(mcvar [,var_list=[]])
1D detector:

array shape: x = array[0] y = array[1] y_err = array[2] N = array[3]

dict contains: title, xlabel, ylabel, xvar, yvar, xlimits, values, statistics, signal

2D detector:

array shape: I = array[0] (2D array) I_err = array[1] (2D array) N = array[2] (2D array)

dict contains: title, xlabel, ylabel, zlabel, xvar, yvar, zvar, xylimits, values, statistics, signal

ploting

By handing over a matplotlib.axes.Axes object, the detector image will be plotted on this axis. For 1D axes.errorbar() and 2D axes.imshow() will be used. xlabel, ylable, title and in case of 2D, the xy scale, will be set accordingly to the additional information provided in the detector file.

Special function custom():

If this function exists in the python file and the mode is set to custom, the compile steps are executed and then the custom function is executed, followed by the analyse function. This is highly advanced. You need to make sure that the check_for_detector_output function, psave function, and other critical functions are executed. This function takes the place of the run_instrument() function as well as all save functions.