hop.scripts package¶
Submodules¶
hop.scripts.prepare_files_for_robot module¶
Apply a number of corrections to the magnet x and y positions in a given Hector robot file, then write these updated positions in a file which can be read in by the Hector robot. .. rubric:: Example
- This script should be run as::
$ python prepare_files_for_robot.py /path/to/robot/file /path/to/robot/shifts/file
The output is a robot file with “_CorrectionsApplied.csv” appended to the input filename
- hop.scripts.prepare_files_for_robot.apply_corrections(df, robot_shifts_file, offset=0.0, T_observed=None, T_configured=None, plate_radius=226.0, alpha=1.2e-06, robot_centre=[324.47, 297.834], apply_telecentricity_correction=True, apply_metrology_calibration=True, apply_roll_correction=True, apply_rotation_correction=True, verbose=True, permagnet_theta_correction=True, metrology_sign='negative', rotation_axis_misalignment_sign='positive', apply_barrel_rotation_to_all_magnets=True, barrel_rotation_sign='positive')[source]¶
Apply a number of corrections to the magnet positions. The corrections are: * A radial shift inwards or outwards applied to all circular magnets to account for a difference in temperature between the plate at the time it was configured and the plate at the time it will be observed. Note that this offset can be entered in millimetres, or otherwise two temnperatures and a coefficient of thermal expansion can be given instead. * A correction on the position of each circular magnet based on its radial position in one of four telecentricity annuli. The circular magnet is moved inwards to account for the fact the light is not truly plane-parallel across the plate. * A correction on the position of all magnets based on accurate calibration of the position and rotation of the plate using the pre-defined metrology markers. This correction can be decomposed into a shift of the plate centre, a shear term and a rotation. The derived correction is fit to the measurements in the robot_shifts_file. * A correction on North/South position of all magnets based on the roll of the robot arm as it places each object. The extension of the robot arm to the far corner of the plate induces a small torque which affects its ability to place a magnet accurately. This torque has been measured and fitted with quadratic function which depends on the y value (in robot coordinates) of the magnet and is applied to its x value. For corrections which are applied to only the circular magnets, we then calculate the position of the rectangular magnets again to ensure that the distance between them is always 27.2mm. :param filename: A Hector Robot file containing information about 27 circular and 27 rectnagular magnets to be placed on the plate. :type filename: str :param offset: A radial offset (in mm) to be applied to all circular magnets. Negative values are towards the plate centre, positive values are away from the plate centre. The default is 0.0 :type offset: float, optional :param T_observed: The temperature (in Celsius or Kelvin) at which the plate will be observed at. Default is None. :type T_observed: float, optional :param T_configured: The temperature (in Celsius or Kelvin) at which the plate was configured at. Default is None. :type T_configured: float, optional :param plate_radius: The radius of the plate in mm, for claculating the thermal expansion. Default is 226.0 :type plate_radius: float, optional :param alpha: The coefficient of thermal expansion of invar. Default is 1.2e-6 :type alpha: float, optional :param robot_centre: A two element list comntaing the x and y coordinates of the plate centre in the coordinates of the robot. You really shouldn’t change this unless you have a very good reason! Default is [324.470,297.834] :type robot_centre: list, optional :param robot_shifts_file: The location of the metrology measurements file. Default is ‘robot_shifts_abs.csv’ :type robot_shifts_file: str, optional :param : The location of the metrology measurements file. Default is ‘robot_shifts_abs.csv’ :type : str, optional :param apply_telecentricity_correction: Whether or not to apply the telecentricity correction to the magnets. In all reasonable circumstances this should be True! Default is True. :type apply_telecentricity_correction: bool, optional :param apply_metrology_calibration: Whether or not to apply the metrology-based calibration correction. Should always be True. Default is True :type apply_metrology_calibration: bool, True :param apply_roll_correction: Whether or not to apply the robot roll correction. Should always be True. Default is True. :type apply_roll_correction: bool, True :param apply_rotation_correction: Whether or not to apply the correction for the different alignments of the robot cylinder and pickup arm. Should always be True, default is True. :type apply_rotation_correction: bool, True :param verbose: Print information about the corrections to the screen. Default is True. :type verbose: bool, True
- hop.scripts.prepare_files_for_robot.correct_parking_positions_file(filename, robot_shifts_file, T_observed=None, T_configured=None, plate_radius=226.0, alpha=1.2e-06, robot_centre=[324.47, 297.834], apply_metrology_calibration=True, apply_roll_correction=True, verbose=True, apply_barrel_rotation_to_all_magnets=True, barrel_rotation_sign='positive')[source]¶
Apply the necessary corrections to the x and y parking positions of the Hector magnets. We then write this file out to a new one with the exact same format
- hop.scripts.prepare_files_for_robot.correct_robot_file(filename, offset=0.0, T_observed=None, T_configured=None, plate_radius=226.0, alpha=1.2e-06, robot_centre=[324.47, 297.834], robot_shifts_file='./robot_shifts_abs.csv', apply_telecentricity_correction=True, apply_metrology_calibration=True, apply_roll_correction=True, apply_rotation_correction=True, verbose=True, metrology_sign='negative', rotation_axis_misalignment_sign='positive', apply_barrel_rotation_to_all_magnets=True, barrel_rotation_sign='positive')[source]¶
Apply the necessary corrections to the x and y positions of magnets in a Hector Robot file. We also read in and update its header
- hop.scripts.prepare_files_for_robot.update_parking_positions(robotFile_fromLabView, updated_parkingPositions_filename)[source]¶
Replace the x and y centre values in the robot output file (”*_CorrectionsApplied_DATE_TIME_STAMP.csv”) with the updated parking positions generated by running “correct_parking_positions_file” routine :param robot file name: The name of the Labview output robot file :type robot file name: str :param updated parking positions file name: The file containing the metrology corrected parking positions generated by running “correct_parking_positions_file” routine :type updated parking positions file name: str
hop.scripts.robot_corrections module¶
This module contains various functions which correct the magnet x and y positions before the robot places them on the Hector plate.
- hop.scripts.robot_corrections.apply_offsets_to_magnets(df, offset, robot_centre, apply_telecentricity_correction=True, verbose=True)[source]¶
Apply the radial and telecentricity offsets to the circular magnets, then calculate the corresponding positions of the rectangular magnets.
- Parameters
df (dataframe) – A dataframe made from reading in the robot file
offset (float) – A given offset distance in mm to move each magnet in the radial direction. Positive is outwards.
robot_centre (list) – A two element list containing the plate centre in robot coordinates.
apply_telecentricity_correction (bool, optional) – If True, apply the telescentricity correction term
verbose (bool, optional) – If True, print information to the screen.
- Returns
The updated dataframe containing positions with the offsets applied
- Return type
dataframe
- hop.scripts.robot_corrections.calculate_radial_offset(circular_magnet, radial_offset, robot_centre, apply_telecentricity_correction=True, verbose=True)[source]¶
Given an x and y coordinate, calculate the total radial offsets to apply based on a temperature change and a fixed telecentricity correction
- hop.scripts.robot_corrections.calculate_rectangular_magnet_centre_coordinates(x, y, rm_angle)[source]¶
The rectangular magnets always have to be 27.2 mm from their circular magnets, and at the appropriate angle
- hop.scripts.robot_corrections.calculate_telecentricity_correction(magnet, robot_centre, verbose=True)[source]¶
Find the required offset in the position of the circular magnets based on their telecentricity annulus
- hop.scripts.robot_corrections.perform_metrology_calibration(input_coords, input_theta_d, robot_centre, robot_shifts_file, verbose=True, permagnet_theta_corr=True, sign='negative')[source]¶
Apply a correction based on the measured metrology of the robot. Written by Barnaby Norris.
- hop.scripts.robot_corrections.pick_up_arm_rotation_correction(robot_centre_x, robot_centre_y, rot_platePlacing, sign='positive')[source]¶
Correct for the errors in magnet position introduced by the different centres of rotation of the robot cylinder and the pickup arm.
First written by Stefania Barsanti, May 2022. Edited by Sam Vaughan, May/June 2022
- Parameters
robot_centre_x (float) – Magnet x coordinate
robot_centre_y (float) – Magnet y coordinate
rot_platePlacing (float) – Theta coordinate of robot arm when placing each magnet. Should be from the rot_platePlacing column in the robot file
sign (str) – Must be “positve” or “negative”. Apply a factor of +/- 1 to swap the direction of this correction.
- Returns
The new magnet x coordinate and y coordinate
- Return type
tuple
hop.scripts.robot_file_input_output module¶
- hop.scripts.robot_file_input_output.read_parking_positions_file(filename)[source]¶
Read in the oddly formatted parking positions file. Be very sure to get the right lines here, or error if things aren’t as expected. Don’t just guess line numbers!
- hop.scripts.robot_file_input_output.read_standard_robot_file(filename)[source]¶
Read in a standard robot file and return a pandas dataframe