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: (1) *.mac contains a set of instructions to move the motors; (2)one or more *.ini containing 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: if the same name is used twice, the instructions will be overwritten and only one set will be executed. 
# Scan Type
ScanType = EXAFS | XSW
MomentumTransfer = 0.1
XSWmode = Theta | Phi
ThetaZero = 0.05
PhiZero = -90
ScanType depends on your experimental needs.
  • Normal EXAFS or XANES acquisition require the "EXAFS" tag and nothing else (move to the following section).
  • For energy scans to be collected at constant MomentumTransfer (q), "XSW" should be used instead. For XSW scans, you have to specify the value of q (MomentumTransfer), of the angular geometry (XSWmode) and the offset angle (ThetaZero or PhiZero).
# 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:

  • the movements are executed line by line;

  • the detectors moves away from the samples (safe movement!) going to higher values;

  • if the detector is close to your sample (< 50 mm), use the correct order of movements so to keep the detector as far as possible until the end of the movements. Particular care is needed when moving from one sample to another (there might be screws taller than your samples!).

Moving from point A to point B? Consider this: high values of 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! 
In this case the order can be:

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. One can activate one or more detectors, choose the BMS channel to be read, and set the acquisition time.
To activate a detector, set its value to True. The available detectors are Keithley (diode) or Bruker (fluorescence detector). 
Syntax:

AcquireKeithely = True | False
AcquireBruker = True | False

The AcquisitionTime must be set in seconds.
If you are not sure on which BMS channel you must use, ask the beamline staff.

# 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 

Investigation must be filled with the proposal number (and nothing else).
Experiment and dataset are sub-folders names that have to be used. Do not use blank spaces.
For the rootfilename, enter your string of choice. A timestamp will be added automatically to the string to avoid overwriting.

The file for each scan will be saved as RootFileName_yyyy-mm-dd_hh-mm.h5 and as a smaller .txt. The txt version contains the crucial information for each scan, while many more details are enclosed in the h5 files.

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.
This file carries the information about the start/stop energies. If you have already run a scan, you will find an output_file.ini saved in the same folder as your files: you can use this one as a template.
For details on the meaning of Energy-ith, please check here.



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!

Last Updated on Thursday, 19 September 2024 17:00