Delay Calibration

hxrsnd.plans.calibration.calibrate_motor(detector, detector_fields, motor, motor_fields, calib_motors, calib_fields, start, stop, steps, confirm_overwrite=True, *args, **kwargs)[source]

Performs a calibration scan using the inputted detector, motor, and calibration motors, then configures the motor using the resulting calibration.

Parameters:
detectorBeamDetector

Detector from which to take the value measurements

detector_fieldsiterable

Fields of the detector to measure

motorMotor

Main motor to perform the scan

calib_motorsiterable, Motor

Motor to calibrate each detector field with

startfloat

Starting position of motor

stopfloat

Ending position of motor

stepsint

Number of steps to take

confirm_overwritebool, optional

Prompt the user if this plan will overwrite an existing calibration

Returns:
configstuple of dict

Old configuration and the new configuration.

hxrsnd.plans.calibration.calibration_scan(detector, detector_fields, motor, motor_fields, calib_motors, calib_fields, start, stop, steps, first_step=0.01, average=None, filters=None, return_to_start=True, *args, **kwargs)[source]

Performs a calibration scan for the main motor and returns a correction table for the calibration motors.

This adds to calibration_scan by moving the motors to their original positions and and running the calibration calculation function. It returns the expected motor calibration given the results from the scan, as well as the dataframe from the scan with all the data.

Parameters:
detectorBeamDetector

Detector from which to take the value measurements

detector_fieldsiterable

Fields of the detector to measure

motorMotor

Main motor to perform the scan

calib_motorsiterable, Motor

Motor to calibrate each detector field with

startfloat

Starting position of motor

stopfloat

Ending position of motor

stepsint

Number of steps to take

first_stepfloat, optional

First step to take on each calibration motor when performing the correction

averageint, optional

Number of averages to take for each measurement

delayfloat, optional

Time to wait inbetween reads

tolerancefloat, optional

Tolerance to use when applying the correction to detector field

max_stepsint, optional

Limit the number of steps the correction will take before exiting

gradientsfloat, optional

Assume an initial gradient for the relationship between detector value and calibration motor position

return_to_startbool, optional

Move all the motors to their original positions after the scan has been completed

Returns:
df_calibrationpd.DataFrame

Dataframe containing the points to be used for the calibration by the calibration motors

df_calibration_scanpd.DataFrame

DataFrame containing the positions of the detector, motor, and calibration motor fields during the initial scan. The indices are the target motor positions.

scalinglist

List of the scaling values in units of motor egu / detector value used to calculate the calibration.

start_positionslist

List of starting positions used to perform the calibration calculation.

hxrsnd.plans.calibration.calibration_centroid_scan(detector, motor, calib_motors, start, stop, steps, calib_fields=None, *args, **kwargs)[source]

Performs a centroid scan producing a dataframe with the values of the detector, motor, and calibration motor fields.

Parameters:
detectorBeamDetector

Detector from which to take the value measurements

motorMotor

Main motor to perform the scan

calib_motorsiterable

Calibration motors

startfloat

Starting position of motor

stopfloat

Ending position of motor

stepsint

Number of steps to take

averageint, optional

Number of averages to take for each measurement

detector_fieldsiterable, optional

Fields of the detector to add to the returned dataframe

motor_fieldsiterable, optional

Fields of the motor to add to the returned dataframe

calib_fieldslist, optional

Fields of the of the calibration motors to add to the returned dataframe

Returns:
dfpd.DataFrame

DataFrame containing the detector, motor, and calibration motor fields at every step of the scan.

Raises:
ValueError

If the inputted number of calibration motors does not have the same length as the number of calibration fields.

hxrsnd.plans.calibration.detector_scaling_walk(df_scan, detector, calib_motors, first_step=0.01, average=None, filters=None, tolerance=1, delay=None, max_steps=5, system=None, drop_missing=True, gradients=None, *args, **kwargs)[source]

Performs a walk to to the detector value farthest from the current value using each of calibration motors, and then determines the motor to detector scaling

Using the inputted scan dataframe, the plan loops through each detector field, then finds the value that is farthest from the current value, and then performs a walk_to_pixel to that value using the corresponding calibration motor. Since the final absolute position does not matter so long as it is recorded, if a RuntimeError or LimitError is raised, the plan will simply use the current motor position for the scaling calculation.

Parameters:
df_scanpd.DataFrame

Dataframe containing the results of a centroid scan performed using the detector, motor, and calibration motors.

detectorDetector

Detector from which to take the value measurements

calib_motorsiterable, Motor

Motor to calibrate each detector field with

first_stepfloat, optional

First step to take on each calibration motor when performing the correction

averageint, optional

Number of averages to take for each measurement

delayfloat, optional

Time to wait inbetween reads

tolerancefloat, optional

Tolerance to use when applying the correction to detector field

max_stepsint, optional

Limit the number of steps the correction will take before exiting

drop_missingbool, optional

Choice to include events where event keys are missing

gradientsfloat, optional

Assume an initial gradient for the relationship between detector value and calibration motor position

Returns:
scalinglist

List of scales in the units of motor egu / detector value

start_positionslist

List of the initial positions of the motors before the walk

hxrsnd.plans.calibration.build_calibration_df(df_scan, scaling, start_positions, detector)[source]

Takes the scan dataframe, scaling, and starting positions to build a calibration table for the calibration motors.

The resulting dataframe will contain all the scan motor read fields as well as two columns for each calibration motor that has an absolute correction relative correction.

Parameters:
df_scanpd.DataFrame

Dataframe containing the results of a centroid scan performed using the detector, motor, and calibration motors.

scalinglist

List of scales in the units of motor egu / detector value

start_positionslist

List of the initial positions of the motors before the walk

detectorDetector

Detector from which to take the value measurements

Returns:
df_calibrationpd.DataFrame

Calibration dataframe that has all the scan motor fields and the corrections required of the calibration motors in both absolute and relative corrections.