pizurscan API Reference
Modules
pizurscan.InputValidator module
- pizurscan.InputValidator.extract_scan_pars()
Extracts the scan parameters from a JSON file.
- Returns:
A dictionary containing the input parameters for the scanning process.
- Return type:
dict
- pizurscan.InputValidator.input_validator()
Validates the scan parameters extracted from a JSON file and terminates the program if any validation error occurs.
- Returns:
A dictionary containing the input parameters for the scanning process.
- Return type:
dict
- pizurscan.InputValidator.validate(scan_pars)
Validates all the input parameters of scan_pars.
- Parameters:
scan_pars (dict) – A dictionary containing the input parameters for the scanning process.
- Raises:
ValueError – If any of the input parameters is invalid.
- pizurscan.InputValidator.validate_acceleration(acceleration)
Validates the acceleration attribute to ensure that it is within the range [0, 20] mm/s^2.
- Parameters:
acceleration (float) – The acceleration of the scan motion in mm/s^2.
- Raises:
ValueError – If the acceleration value is out of range [0, 20] mm/s^2.
- pizurscan.InputValidator.validate_scan_edges(scan_edges)
Validates the scan edges.
- Parameters:
scan_edges (list) – A list containing the starting and final points of the scan.
- Raises:
ValueError – If the scan edges are out of range [0, 102].
- pizurscan.InputValidator.validate_stepsize(scan_edges, stepsize)
Validates the step size of the scanning process.
- Parameters:
scan_edges (list) – A list containing the starting and final points of the scan.
stepsize (float) – The step size between scan points.
- Raises:
ValueError – If the step size is out of range [0.0005, 102], or the starting point plus step size are out of range.
- pizurscan.InputValidator.validate_type(type)
Validates the type of the scanning process.
- Parameters:
type (str) – Type of the scan, either “continuous” or “discrete”.
- Raises:
ValueError – If the type is not “continuous” or “discrete”.
- pizurscan.InputValidator.validate_velocity(velocity)
Validates the velocity attribute to ensure that it is within the range [0, 10] mm/s.
- Parameters:
velocity (float) – The velocity of the scan motion in mm/s.
- Raises:
ValueError – If the velocity value is out of range [0, 10] mm/s.
pizurscan.InputProcessor module
- pizurscan.InputProcessor.delta_calculator(scan_edges)
Calculate the absolute value of the distance between the scan edges.
Parameters:
- scan_edgeslist[float]
The edges of the scan range.
Returns:
- deltafloat
Absolute value of the distance between scan edges.
- pizurscan.InputProcessor.duration_calculator(delta, vel, acc)
Calculate the duration of the triggered data acquisition for a continuous scan.
Parameters:
- deltafloat
The distance between the scan edges.
- velfloat
The velocity of the stepper.
- accfloat
The acceleration of the stepper.
Returns:
- durationfloat
The duration of the triggered data acquisition.
- pizurscan.InputProcessor.evaluate_2D_daq_pars(scan_pars)
Process input data for a 2D scan to determine the number of rows, columns, and duration of the triggered data acquisition for the Zurich lock-in.
Parameters:
- scan_parsdict
- A dictionary containing scan parameters, including:
- scan_edgeslist[float]
The edges of the scan range for the main axis.
- stepsizefloat
The step size for motion of the main axis stepper.
- accelerationfloat
The acceleration of the main axis stepper.
- velocityfloat
The velocity of the main axis stepper.
- servo_scan_edgeslist[float]
The edges of the scan range for the servo axis.
- servo_stepsizefloat
The step size for motion of the servo axis stepper.
- servo_accelerationfloat
The acceleration of the servo axis stepper.
- servo_velocityfloat
The velocity of the servo axis stepper.
- sampling_freqfloat
The sampling frequency of the Zurich lock-in.
- typestr
The type of scan: ‘continuous’ or ‘discrete’.
- main_axisstr
The main axis for the scan: ‘master’ or ‘servo’.
Returns:
- daq_parsdict
- A dictionary containing data acquisition parameters, including:
- daq_columnsint
The number of columns for the data acquisition.
- daq_rowsint
The number of rows for the data acquisition.
- durationfloat
The duration of the triggered data acquisition.
- modestr
The data acquisition mode: ‘Linear’ for continuous scan, ‘Exact (on-grid)’ for discrete scan.
- trigger_typestr
The trigger type, always set to ‘HW trigger’.
- trigger_edgestr
The trigger edge.
- holdofffloat
The holdoff time for the trigger.
- out_columnsint
The number of columns for the output data.
- out_rowsint
The number of rows for the output data.
- pizurscan.InputProcessor.evaluate_daq_pars(scan_pars)
Process input data for a 1D scan to return the complete DAQ parameters that suit the scan parameters.
Parameters:
- scan_parsdict
- A dictionary containing scan parameters, including:
- stepsizefloat
The step size for motin of the stepper
- accelerationfloat
The acceleration of the stepper.
- velocityfloat
The velocity of the stepper.
- sampling_freqfloat
The sampling frequency of the Zurich lock-in
- typestr
The type of scan: ‘continuous’ or ‘discrete’.
- scan_edgeslist[float]
The edges of the scan range.
Returns:
- daq_parsdict
- A dictionary containing data acquisition parameters, including:
- daq_columnsint
The number of columns for the data acquisition.
- daq_rowsint
The number of rows for the data acquisition.
- durationfloat
The duration of the triggered data acquisition.
- modestr
The data acquisition mode; ‘Linear’ for continuous scan, ‘Exact (on-grid)’ for discrete scan.
- trigger_typestr
The trigger type, always set to ‘HW trigger’.
- trigger_edgestr
The trigger edge.
- holdofffloat
The holdoff time for the trigger.
- pizurscan.InputProcessor.rows_columns_continuous(delta, stepsize)
Calculate the number of rows and columns for a continuous scan with a PI controller and Zurich lock-in.
Parameters:
- deltafloat
The distance between the scan edges.
- stepsizefloat
The step size for the motion of the stepper.
Returns:
- N_rowsint
The number of rows for the data acquisition.
- N_colsint
The number of columns for the data acquisition.
- pizurscan.InputProcessor.rows_columns_discrete(delta, stepsize, sampl_freq)
Calculate the number of rows and columns for a discrete scan with a PI controller and Zurich lock-in.
Parameters:
- deltafloat
The distance between the scan edges.
- stepsizefloat
The step size for the motion of the stepper.
- sampl_freqfloat
The sampling frequency of the Zurich lock-in.
Returns:
- N_rowsint
The number of rows for the data acquisition.
- N_colsint
The number of columns for the data acquisition.
pizurscan.OutputProcessor module
- pizurscan.OutputProcessor.evaluate_2D_targets(scan_pars)
Evaluate the target positions for a 2D scan.
Args: - scan_pars (dict): A dictionary containing scan parameters.
Returns: - targets (ndarray): A NumPy array containing the target positions for the primary axis. - servo_targets (ndarray): A NumPy array containing the target positions for the secondary axis.
- pizurscan.OutputProcessor.evaluate_averaged_data(N_rows, N_cols, raw_data)
Average the input data in case of a 1D discrete scan. Raw data is divided into chunks of dimension N_cols, over which an average is performed. The output avg_data is in one-to-one relation with the spatial coordinates.
Args: - N_rows (int): The number of rows that was set in the daq. - N_cols (int): The number of columns that was set in the daq. - raw_data (ndarray): A NumPy array containing the raw data.
Returns: - avg_data (ndarray): A NumPy array containing the averaged data.
- pizurscan.OutputProcessor.evaluate_target_positions(scan_edges, stepsize)
Evaluate the partition of the target points for a 1D scan.
Args: - scan_edges (list): A list containing the scan range. - stepsize (float): The step size of the stepper.
Returns: - targets (ndarray): A NumPy array containing the target positions.
- pizurscan.OutputProcessor.get_raw_data(filename)
Read raw data from the input file and return the third column, which contains the values of the measured signal.
Args: - filename (str): The name of the input file.
Returns: - raw_data (ndarray): A NumPy array containing the third column of the input file.
- pizurscan.OutputProcessor.save_2D_data_file(primary, secondary, out_data, N_rows, N_cols)
Save the cleaned 2D data to a file named “cleaned_2D_data.txt” in the current directory.
Args: - primary (ndarray): A NumPy array containing the target positions for the primary axis. - secondary (ndarray): A NumPy array containing the target positions for the secondary axis. - out_data (ndarray): A NumPy array containing the cleaned data. - N_rows (int): The number of rows in the cleaned data. - N_cols (int): The number of columns in the cleaned data.
- pizurscan.OutputProcessor.save_data_file(targets, avg_data)
Save the cleaned 1D data to a file named “cleaned_1D_data.txt” in output folder.
Args: - targets (ndarray): A NumPy array containing the target positions. - avg_data (ndarray): A NumPy array containing the averaged data.
- pizurscan.OutputProcessor.save_processed_2D_data(filename, scan_pars, daq_pars)
Process the 2D data and save it to a file named “cleaned_2D_data.txt” in the current directory.
Args: - filename (str): The name of the input file. - scan_pars (dict): A dictionary containing scan parameters. - daq_pars (dict): A dictionary containing data acquisition parameters.
- pizurscan.OutputProcessor.save_processed_data(filename, scan_pars, daq_pars)
Process the 1D data, averaging it if necessary (discrete scan), and save it to a file named “cleaned_1D_data.txt” that is stored in the “output” folder.
Args: - filename (str): The name of the input file. - scan_pars (dict): A dictionary containing scan parameters. - daq_pars (dict): A dictionary containing data acquisition parameters.
pizurscan.PI_commands module
- class pizurscan.PI_commands.Stepper(controller_id, axis_id)
Bases:
objectRepresents an axis connected to a PI controller.
This class provides methods for connecting to and controlling the axis, including referencing the stage to a known position, moving the stage, querying the position, and configuring the output trigger.
- Parameters:
controller_ID (str) – The ID of the PI controller to connect to.
axis_ID (str) – The ID of the axis to control.
- pidevice
The underlying PI device object.
- Type:
GCSDevice
- controller_ID
The ID of the PI controller this axis is connected to.
- Type:
str
- axis_ID
The ID of this axis.
- Type:
str
- close_connection()
Close the connection and reset the axis property
- connect_pidevice()
Finds the plugged devices, activates the I/O interface to select the device of interest and eventually connects to the selected device.
- disable_out_trigger(trigger_type)
Configures and disable the output trigger for a given axis.
- Parameters:
trigger_type (int) – Type of trigger to be output (6 == in Motion, 1 = Line trigger).
- enable_out_trigger(trigger_type)
Configures and activate the output trigger for a given axis.
- Parameters:
trigger_type (int) – Type of trigger to be output (6 == in Motion, 1 = Line trigger).
- get_acceleration()
Gets and returns the acceleration of the device
- Return type:
A float object defining the acceleration of motion
- get_curr_pos()
Returns the current position of the axis
- Return type:
A float object with the current position of the stage
- get_velocity()
Get and returns the velocity of the device
- Returns:
velocity – Float defining the velocity of motion
- Return type:
float
- move_stage_to_ref(refmode)
Moves the selected controller towards the reference position.
- Parameters:
refmode (str) – String defining the referencing position.
- move_stage_to_target(target)
Moves the device to target position
- Parameters:
target (float) – Float defining the target position
- select_device(devices)
Displays the list of devices and prompts the user to select one.
- Parameters:
devices (list) – List object with the connected devices (as strings)
Returns –
-------- –
connected. (A string object with the name of the pi device to be) –
- set_acceleration(acceleration)
Set the acceleration of motion in the ROM of the controller
- Parameters:
acceleration (float) – Float defining the acceleration of motion
- set_deceleration(deceleration)
Set the deceleration of motion in the ROM of the controller
- Parameters:
deceleration (float) – Float defining the deceleration of motion
- set_velocity(velocity)
Set the velocity of motion in the ROM of the controller
- Parameters:
velocity (float) – Float defining the velocity of motion
- startup_USB_device(device)
Connects to the specified device.
- Parameters:
device (str) – A string object with the name of the pi device to be connected.
- class pizurscan.PI_commands.StepperChain(controller_id: str, axis_id: int)
Bases:
objectHandles the connection with two pidevices, making use of the Stepper class to control a USB daisy chain of two devices.
- controller_id
The ID of the controller.
- Type:
str
- axis_id
The ID of the axis.
- Type:
int
- connect_daisy(dev_indices)
Connects master and servo to form a daisy chain.
- reference_both_stages(ref_modes)
References both stages.
- configure_both_trig(trigger_types)
Configures the output trigger modes of the two devices.
- close_daisy_chain_connection()
Close all connections on daisy chain and daisy chain connection itself.
- connect_daisy_chain()
Connects the master and servo in the daisy chain.
This method initializes the daisy chain configuration, connects the master and servo devices, performs startup procedures, and sets up the axis for operation.
- get_daisy_chain_id()
Get the ID of the daisy chain.
- Returns:
daisy_chain_id – The ID of the daisy chain.
- Return type:
int
- open_daisy_chain()
Opens the connection with the daisy chain. This method opens a daisy chain configuration using the first plugged device.
- reference_both_stages(ref_modes) None
References both stages.
Parameters: ref_modes (List[str]): List of two strings defining the referencing modes.