Macros at XRF
A Macro is a set of instructions which are run sequentially. You can use it to run different types of scan and/or to move from one sample to another.
Each macro needs at least two configuration files: a *.mac file and a e *.ini file.
The .mac file defines a series of scans that will be executed in the exact order as they are defined in the file. A mac file contains a set of instructions to move the motors (Sample positioner, HOS, slits, etc.) and should point to the appropriate ini file for each scan. The ini file contains the configuration parameters for each energy scan.
Templates for both files are available in Desktop (template_macro.mac and template_energy.ini).
Preparing the Macro
Keep in mind that the instructions are executed line by line.
A preview is available here, details are reported on the side of each section:
Template_macro.mac
[UniqueIdentifier] |
Each set of instructions is identified by a [UniqueIdentifier] written in square brackets: this identifier will not be saved anywhere, it is only used to distinguish the sets. Be sure to use unique names. |
# Scan Type ScanType = EXAFS | XSW MomentumTransfer = 0.1 XSWmode = Theta | Phi ThetaZero = 0.05 PhiZero = -90 |
ScanType depends on your experimental needs.
|
# Manipulator AxisX = 0.0 AxisY = 0.0 AxisZ = 5.0 AxisDetector = 50.0 AxisTheta = 0 AxisTheta2 = -89 AxisPhi = -90 |
AxisX moves the manipulator motor X to the specified position. The names for the other motors are: AxisTheta2 : 2Theta -> angle for diode detection AxisDiode : Diode_selector When writing this part keep in mind that:
Moving from point A to point B? Consider this: high values of Z mean the sample is close to the detector.
If theta = 0: and Z_B < Z_A, this should be your first move as it is the safest!
AxisZ = Z_B
AxisX = X_B
AxisY = Y_B
|
# HOS HosHor = -10. HosPitch = 5.0 HosVer = 1.0 |
Typical values are: HosHor = -10 for Energy>7 keV | +10 otherwise HosPitch = 5.0 for Energy>7 keV | contact staff for E<7 keV HosVer is usually set at the beginning of the experiment and is not moved afterwards. Contact the staff if needed. |
# EXIT_SLITS GapHOR = 0.2 GapVER = 0.5 CenterHOR = 0 CenterVER = 0 |
The values should be entered in mm. |
# Detectors AcquireDetector = True | False AcquireKeithley = True | False AcquireXPI = True | False DarkCurrent = True | False BMSChannel = 3 AcquisitionTime = 5 |
Here are the details for the acquisition.
In this section it is possible to choose the detectors to be used, the BMS channel to be read, and set the acquisition time. Syntax: AcquireKeithely = True | False AcquireBruker = True | False
The AcquisitionTime must be set in seconds. |
# Energy ElementEdge = Cu_K ScanConfFile = my_ini_file.ini |
ElementEdge must be entered using the element name followed by an underscore and the edge. ScanConfFile is the filename of the ini file, where the information about the energy points is stored. If this line is missing, no energy scan will be made, but the movements of the motors will be executed (useful when you want to combine additional movements of the motors!). |
# Storage Investigation = 20240605 Experiment = # subfolder name Dataset = # sub-sub-folder RootFileName = filename NumberOfScans = 3 |
Here one can set the folders and subfolders where the data is saved. Your data are available in the path: scratch4xrf/Investigation/Experiment/Dataset In this section you can also set the NumberOfScan, i.e. the repetitions of each energy scan. |
Template_energy.ini - i.e. your ScanConfFile
[Energy] Energy1 = 9500.0 Energy2 = 9560.0 Energy3 = 9630.0 Energy4 = 9680.0 Energy5 = 9846.0 DeltaEn1 = 3.0 DeltaEn3 = 0.3 DeltaK = 0.04 K_Max = 7.0 DetectorROI = [898,936] |
Here the details about the energy points are specified. |
You can choose to skip single parameters or entire sections of the Macro. Be aware that any parameter which is not specified is left as it was in the previous scan: to verify the current parameters, check the scan tool window (here more details).
Running the Macro
Open the terminal (right click of the mouse and Open in Terminal) in the same folder where the file.mac is saved.
Then type:
macro nameofthemacro.mac
To stop the macro (aborting the current acquisition) use CTRL+C in the terminal window.
NOTE: if you press the yellow button on the Scan Tool Window, only the current set of instructions will be terminated, the macro will resume from the following set!