Epics Scanning in IDL

This is documentation (of sorts) for ESCAN, a data collection program for Epics that is especially useful for EXAFS data collection.

ESCAN is written in IDL, by Matt Newville. It is a pretty terrible piece of software, but can be made to collect EXAFS data. A newer version is in the works, but has been in the works for years, so don't hold your breath.

Getting Escan

First, you'll need IDL. Escan won't work with the IDL virtual machine -- you need a real version of IDL.

The source code (tar gzip file) is EscanIDL.tar.gz

You'll also need the IDL Epics interface, and a pile of other IDL code. I think that all of this is included in IDL_Setup.tar.gz , but I could be wrong (please let me know!!)

You may also want Mark Rivers' Epics / IDL code from http://cars9.uchicago.edu/software/idl

What does Escan do?

Escan provides a way to define, load, and execute scans. It can do simple 1-D scans, 2-D scans (maps), and EXAFS scans (where energy is changed with a variable step size). Escan uses the Epics SScan Record to execute a scan, and provides a higher level graphical user interface into the scan record.

Starting Escan

To run escan, start IDL , then type escan:

~> idl
IDL Version 6.2 .....
IDL> escan

This should immediately bring up a graphical Directory Browser, with which you can pick a working directory -- where scan parameter files live, and where the data will be collected.

If you get error messages, and don't see two windows pop up with titles "Epics Scan Setup" and "Epics Scan Viewer", you should work on figuring out what's wrong.

The Scan Parameter File

The main configuration for a scan is held in a scan parameter file, myscan.scn. The '.scn' suffix is not required, but preferred. By default, Escan will look for a file called 'default.scn' and prompt you with a directory broswer for one if it cannot find one.

Thus, to get started, 'default.scn' is very important. After you have one, making others will be easy to do with the Escan GUI.

The scan parameter file maps the conceptual scan parameters to the actual Epics Process Variables. The format is horrible (I know). A typical scan file is default.scn and will have several sections, discussed below. I recommend starting with this file, and editing it.

The first section looks like this:

;Scan Parameters% v1.1
 prefix%       13IDC:
 scanner%      13XRM:edb:
 shutter_pv%   13IDA:eps_mbbi4
 shutter_open% 13IDA:eps_bo3
 shutter_clos% 13IDA:eps_bo4
 beam_ok_pv%   13IDA:mono_pid1Locked
 datafile%     u_xanes.001
 monitorfile%  scan_pvs.dat
 dimension%           1
 save_med%            0
 save_dead%           0
 current_scan%        1
;scan  1 %

The file here is just "keyword% value".

The most important keyword is "prefix" which is the base name of the Epics SScan Record to use. Here, '13IDC:scan1' will be used for 1-D scans, and '13IDC:scan2' will be used as well for 2-D scans.

The 'scanner' prefix points to a simple Epics database record that I wrote -- I think it's not critical to start with, but I'll post it soon.

The next few keywords point to Epics PVs for how to tell and control the x-ray shutter and whether it is OK to carry on with the scan "beam OK". Again, these should not be needed. The datafile gives the name of the data file, though this is only the default -- the user will be able to change it. The monitorfile value lists the name of a file that contains names of PVs to save at the top of the data file as "extra information".

The rest is unimportant for now. Following this section is a really ugly section like:

;scan  1 %
  scanpv%   13IDC:scan1
  type%     EXAFS
  drives%           2         0         0         0
  n_regions%       3
  is_rel%          0
  delays%        0.250000     0.000000
  is_kspace%     0.000     0.000     0.000     0.000     0.000
  params%       6539.000    0.0000000     1.000000    0.0000000    0.0000000    0.00000
00    0.0000000    0.0000000    0.0000000    0.0000000    0.0000000
  time%

that you can completely ignore.

Towards the bottom are three important sections:

;motors%           36
   13IDA:E:Energy.VAL  | Energy
   13XRM:m1.VAL  | Scan X
   13XRM:m2.VAL  | Scan Y (vert)
   13XRM:m3.VAL  | Sample Theta
   13XRM:m4.VAL  | Stage X
   13XRM:m6.VAL  | Stage Y
   13XRM:m5.VAL  | Stage Z

This lists the motors (Positioners) that can be scanned, and that will show up in the list of scannable motors. This list can be very long, but it's helpful to have a restricted list. (And different scan files can have different motors defined). The '36' there is completely useless. The Positioner named "Energy" is used for EXAFS scans -- if this is not in eV, you might have to alter some of the IDL code.

The next section describes the detectors to use:

;detgroups%           3
   Scaler    | 13IDC:scaler1 | .CNT | .TP | 8 | 0 | 1
   mcaVortex | 13XRM:mca1 | EraseStart | .PRTM | 1 | 1 | 1

This is a little trickier. Each line goes like this:

  Detector Class | Base PV |  Trigger  | Count Time | Number of Elements | Is Mca? | Use in Scan ?

Detector Class should be either Scaler, mcaSomething, or MED (multi-element detector). For a scaler (That's using the Epics Scaler record), the Trigger used will be '13IDC:scaler1.CNT', and the acquisition time wiill be set with '13IDC:scaler1.TP'. There may be up to 8 scalers that could be saved.

For the mcaVortex (a single-element MCA), the PVs are put together in a similar way.

The value 'Is Mca?' is used to parse up and look for ROI names and settings, and the Vlue of 'Use in Scan?' will dictate whether or not to Trigger that detector at all during the scan.

The last section lists the actual detector values saved at each point in the scan. It's less important here, because you'll set this graphically with escan.

Actually, you can also set the detector "groups" graphically too, but it's so important to get right, that it's useful to know how to get default.scn correct.

Defining New Scans with Escan

When Escan starts, it will load default.scn, and the user should be close to ready to take data.

Overall Setup

For a Epics Scan, you need to set

1. the "scan dimension" (1 for simple scans, 2 for maps), 1. which Positioners to move during the scan, 1. how to move those Positioners, 1. which detectors to use, 1. how long to count 1. what values from those detectors to save.

Selecting Scan Modes, Dimensions, etc

Escan has two scan modes: Motor scans are "simple scans" where one positioner is moved in constant steps. Motor scans can have multiple segments, each with different step sizes and/or acquisition time, but this feature is rarely used.

EXAFS scans scan Energy in eV, can have three segments, and the final segment can step in constant energy or constant k and have the collection time increase by a power of k.

Multi-Dimensional Scans consist of an "Inner Scan" called scan1 that is run repeatedly as the Position for the "Outer Scan" (scan2) is changed. Generally, that means a 2-D map, but you can also take EXAFS scans at different points along a line (or move some other Epics Positioner such as Sample Temperature).

Selecting Detectors

Running Scans

To run a scan, you have to hit "load scan" in Epics Scan Setup, then hit 'Start Scan' in the scan viewer.

Pre-Scan Commmands

Macros, or Running Escan Programmatically

Reading Escan Data Files

Software/EscanIDL (last edited 2009-10-09 19:50:22 by localhost)