AlignComponents v1

../_images/AlignComponents-v1_dlg.png

AlignComponents dialog.

Summary

Align a component by minimising difference to an offset workspace

Properties

Name Direction Type Default Description
CalibrationTable Input TableWorkspace Mandatory Calibration table, currently only uses difc
MaskWorkspace Input MatrixWorkspace   Mask workspace
InstrumentFilename Input string   Instrument filename. Allowed extensions: [‘.xml’]
Workspace Input Workspace   Workspace containing the instrument to be calibrated.
FitSourcePosition Input boolean False Fit the source position, changes L1 (source to sample) distance.Uses entire instrument. Occurs before Components are Aligned.
FitSamplePosition Input boolean False Fit the sample position, changes L1 (source to sample) and L2 (sample to detector) distance.Uses entire instrument. Occurs before Components are Aligned.
ComponentList Input str list   Comma separated list on instrument components to refine.
Xposition Input boolean False Refine Xposition
MinXposition Input number -0.1 Minimum relative X bound (m)
MaxXposition Input number 0.1 Maximum relative X bound (m)
Yposition Input boolean False Refine Yposition
MinYposition Input number -0.1 Minimum relative Y bound (m)
MaxYposition Input number 0.1 Maximum relative Y bound (m)
Zposition Input boolean False Refine Zposition
MinZposition Input number -0.1 Minimum relative Z bound (m)
MaxZposition Input number 0.1 Maximum relative Z bound (m)
EulerConvention Input string YZX Euler angles convention used when calculating and displaying angles,eg XYZ corresponding to alpha beta gamma. Allowed values: [‘ZXZ’, ‘XYX’, ‘YZY’, ‘ZYZ’, ‘XZX’, ‘YXY’, ‘XYZ’, ‘YZX’, ‘ZXY’, ‘XZY’, ‘ZYX’, ‘YXZ’]
AlphaRotation Input boolean False Refine rotation around first axis, alpha
MinAlphaRotation Input number -10 Minimum relative alpha rotation (deg)
MaxAlphaRotation Input number 10 Maximum relative alpha rotation (deg)
BetaRotation Input boolean False Refine rotation around seconds axis, beta
MinBetaRotation Input number -10 Minimum relative beta rotation (deg)
MaxBetaRotation Input number 10 Maximum relative beta rotation (deg)
GammaRotation Input boolean False Refine rotation around third axis, gamma
MinGammaRotation Input number -10 Minimum relative gamma rotation (deg)
MaxGammaRotation Input number 10 Maximum relative gamma rotation (deg)

Description

This algorithm will take a calibration in the form of a diffractioncalibration workspace from the output of for example GetDetOffsetsMultiPeaks v1 or CalibrateRectangularDetectors v1 and minimize the difference between the DIFC of the instrument and calibration workspace by moving and rotating instrument components.

The resulting calibrated geometry can be exported by ExportGeometry v1.

ComponentList

The ComponentList can include any instrument component that can be moved and rotated by MoveInstrumentComponent v1 and RotateInstrumentComponent v1. For example in POWGEN you can list bank46 or Column4 (which includes banks 42-46) or Group3 (which all the banks in Column 3 and 4). In the case of a component group it is treated as one object and not individual banks. In some instruments you can also specify individual tubes or pixel, e.g. bank20/tube3 and bank20/tube3/pixel7, although that is not the intention of the algorithm. You can list multiple components which will be refined in turn (e.g. in the Align the Y rotation of bank26 and bank46 in POWGEN usage example below).

Masking

The only masking that is on taken into account when minimising the difference in DIFC is the masking in the workspace of the MaskWorkspace property of AlignComponents.

Fitting Sample/Source

When fitting the sample or source position it uses the entire instrument and moves in the directions that you select. All rotation options are ignored. You can use a masking workspace to mask part of the instrument you don’t want to use to align the sample/source position (e.g. in the Align sample position in POWGEN usage example below).

The source and sample positions (in that order) are aligned before an components are aligned.

Usage

Example - Align the Y and Z position of bank26 in POWGEN:

ws = LoadEmptyInstrument(Filename="POWGEN_Definition_2015-08-01.xml")
LoadCalFile(InputWorkspace=ws,
      CalFilename="PG3_golden.cal",
      MakeGroupingWorkspace=False,
      MakeOffsetsWorkspace=True,
      MakeMaskWorkspace=True,
      WorkspaceName="PG3")
component="bank26"
print("Start position is {}".format(ws.getInstrument().getComponentByName(component).getPos()))
AlignComponents(CalibrationTable="PG3_cal",
        Workspace=ws,
        MaskWorkspace="PG3_mask",
        Yposition=True, ZPosition=True,
        ComponentList=component)
ws=mtd['ws']
final_pos = ws.getInstrument().getComponentByName(component).getPos()
print("Final position is [{:.2f}.{:.2f},{:.2f}]".format(final_pos[0],final_pos[1],final_pos[2]))

Output:

Start position is [1.54436,0.863271,-1.9297]
Final position is [1.54.0.85,-1.95]

Example - Align the Y rotation of bank25 and bank46 in POWGEN:

ws = LoadEmptyInstrument(Filename="POWGEN_Definition_2015-08-01.xml")
LoadCalFile(InputWorkspace=ws,
      CalFilename="PG3_golden.cal",
      MakeGroupingWorkspace=False,
      MakeOffsetsWorkspace=True,
      MakeMaskWorkspace=True,
      WorkspaceName="PG3")
components="bank25,bank46"
bank25Rot = ws.getInstrument().getComponentByName("bank25").getRotation().getEulerAngles()
bank46Rot = ws.getInstrument().getComponentByName("bank46").getRotation().getEulerAngles()
print("Start bank25 rotation is [{:.3f}.{:.3f},{:.3f}]".format(bank25Rot[0], bank25Rot[1], bank25Rot[2]))
print("Start bank46 rotation is [{:.3f}.{:.3f},{:.3f}]".format(bank46Rot[0], bank46Rot[1], bank46Rot[2]))
AlignComponents(CalibrationTable="PG3_cal",
        Workspace=ws,
        MaskWorkspace="PG3_mask",
        EulerConvention="YZX",
        AlphaRotation=True,
        ComponentList=components)
ws=mtd['ws']
bank25Rot = ws.getInstrument().getComponentByName("bank25").getRotation().getEulerAngles()
bank46Rot = ws.getInstrument().getComponentByName("bank46").getRotation().getEulerAngles()
print("Final bank25 rotation is [{:.3f}.{:.3f},{:.3f}]".format(bank25Rot[0], bank25Rot[1], bank25Rot[2]))
print("Final bank46 rotation is [{:.2f}.{:.3f},{:.3f}]".format(bank46Rot[0], bank46Rot[1], bank46Rot[2]))

Output:

Start bank25 rotation is [-24.089.0.179,9.030]
Start bank46 rotation is [-41.092.0.061,17.795]
Final bank25 rotation is [-24.089.0.179,9.030]
Final bank46 rotation is [-37.40.0.061,17.795]

Example - Align sample position in POWGEN:

ws = LoadEmptyInstrument(Filename="POWGEN_Definition_2015-08-01.xml")
LoadCalFile(InputWorkspace=ws,
      CalFilename="PG3_golden.cal",
      MakeGroupingWorkspace=False,
      MakeOffsetsWorkspace=True,
      MakeMaskWorkspace=True,
      WorkspaceName="PG3")
# Mask banks that don't have calibration data
MaskBTP(Workspace='PG3_mask', Instrument='POWGEN',
        Bank='22-25,42-45,62-66,82-86,102-105,123,124,143,144,164,184,204')
print("Start sample position is {}".format(ws.getInstrument().getSample().getPos().getZ()))
AlignComponents(CalibrationTable="PG3_cal",
      Workspace=ws,
      MaskWorkspace="PG3_mask",
      FitSamplePosition=True,
      Zposition=True)
print("Final sample position is {:.3f}".format(mtd['ws'].getInstrument().getSample().getPos().getZ()))

Output:

Start sample position is 0.0
Final sample position is 0.028

Categories: AlgorithmIndex | Diffraction

Source

Python: AlignComponents.py (last modified: 2018-10-05)