"Correlation Plots" Requirements

Authors:
Greg White, Chris Larrieu. First version 18th July 2007, Stanford Linear Accelerator Center
This version: $Id: CorrelationPlotsReq.html,v 1.3 2007/09/16 23:12:52 greg Exp $:
http://www.slac.stanford.edu/grp/lcls/controls/docs/physics/cp/CorrelationPlotsReq.html

Abstract

These are requirements for a new "Correlation Plots" feature of the Physics Applications suite. This feature will help users to perform ad hoc experiments on the accelerators of SLAC accelerator complex (primarily LCLS), by scanning one or two independent control points through an interval, and reading the resulting values from some others. In this way the system can be used to make measurements and find correlations in the apparent behavior of the accelerator.

Status of this Document

This section describes the status of this document at the time of its publication.

This is a draft and is intended to be reviewed both internally by the controls software section, and by potential users.


Basic Description of Correlation Plots

"Correlation Plots" (CP) is an interactive program which helps accelerator physicists1 to perform ad hoc experiments on the accelerators of SLAC accelerator complex (primarily LCLS), by scanning one or two independent control points (the "step", or "scanned" variable) through an interval, and reading the resulting values from some other dependent (or "sampled") variables. In this way the system can be used to make measurements and find correlations in the apparent behavior of the accelerator. One independent variable makes a 1-d scan, two independent variables may be scanned to make a 2-dimensional analysis (ie a surface plot). The system will include facilities to help in entering the names of variables, (both step and sampled), and range through which the independent variables' setpoints will be swept. It then conducts the data acquisition, paying attention to such things as settle time of magnets and klystrons, averaging, acquiring beam data on the same pulse, etc. When the measurements are completed the collected data can be viewed and plotted, and saved for later analysis.

Using CP it will be possible to make beam synchronous acquisitions using the LCLS event system (though not the SLC timing system, and so it will not support beam synchronous acq for a coordinated acquisition using both control systems of the same pulse).

Terms of Reference

The program described here will be based on the functionality of the SCP "Correlation Plots" facility [CRRREF] (and for continuity will also be referred to as "Correlation Plots", or simply "CP", until another name is decided on).

The XAL applications 1-d scan and 2-d scan may form the basis of Correlation Plots. Evaluation of them for suitability to implement Correlation Plots is part of this project.

Functional Requirements

This section deals with the required interactive functionality of CP. See below for non-functional, general and systemic requirements.

Scanned and Sampled Variables Understood by Correlation Plots

"variables" in the Correlation Plots sense, are most often the setpoint or readback values of a control system device. So they're often assigned to a process variable, and their value is the process variable's value. However, variables in CP may be assigned also from other more complex quantities, as described below.

As outlined above, there are basically two kinds of variable: stepped (sometimes called "scanned" since the acquisition 'scans' through a number of setpoints of this variable), and sampled - the variables whose values are acquired for each setpoint value .

When a variable name is entered, the user may use upper or lower case. CP should establish which is the proper name for actually making the acquisition, and replace, if necessary, what the user typed with the real name.

Scanned Variables

This section lists those types of control system control points which CP will be able to "step".

The following are listed in the order in which they would be matched, so that if all else fails they'll match "arbitrary" EPICS PV.

TIME
Simply a time interval, defined relative to the time the acquisition is started. Defined and recognized by: string "TIME". Step range: two numbers, the integer number of steps N, and the real number time increment between steps Δt, in seconds.

Action of stepping TIME is simply to wait (non-blocking) the Δt seconds.

MKB

A "multiknob", which is a file containing a list of devices (almost always magnets) whose values are to be changed by the "value" of the multiknob, times a coefficient for each device, which are also in the file.

Defined by: the name of the MKB file including .MKB extension. Step range is defined by 3 floats: start-value, increment, end-value-min. Recognised by: regexp .+(\.mkb)$, ie anything ending ".MKB".

Action of stepping a multiknob will be done initially through the AIDA API. The value of the step scan is used as the passed value of the MKB (and is subsequently used by the MKB software to scale all the magnets in the MKB file by the passed value times the coefficient in the file. That is, they're always treated as relative knobs. See [AIDA-MKB].

EPICS magnet

A single magnet controllable by the EPICS magnet control system. Defined by: the PV name of a magnet. Recognized as an EPICS magnet B-field PV by the name matching a regular expression like /(XCOR|YCOR|LGPS).+:BDES[\.VAL]/. Step range is defined by 3 floats: start-value, increment, end-value-min.

Additionally the user must be able to specify which trimming method (one of "trim" or "perturb") is to be used.

Action of stepping an EPICS magnet is to set the BDES by Channel Access, and affect trim operation by the trim method specified (Q: where can we find the API for EPICS magnet control?).

SLC Magnet

A single magnet controllable by the SLC magnet control system. Defined by: the AIDA name of an SLC magnet. Recognized as an SLC magnet B-field by the name matching regular expression (XCOR|YCOR|LGPS):.+//BDES. Step range is defined by 3 floats: start-value, increment, end-value-min.

Additionally the user must be able to specify which trimming method (one of "trim" or "perturb") is to be used (which is used to set the "MAGFUNC" Aida parameter for SLC magnet control).

Action of stepping an SLC magnet is to use the MAGNETSET//BDES AIDA instance, giving the AIDA name supplied by the user, and affect trim operation by calling DaObject.setDaValue; see [AIDA-MAG].

EPICS PV
An "arbitrary" EPICS PV may be stepped (if it's allowed by the underlying system, for instance by CA Security). This is the default case, if all step variable patterns above are not matched, CP will assume the variable is an EPICS PV. Defined by: the PV name, that is matching simply .+. Step range is defined by 3 floats: start-value, increment, end-value-min.

SLC Klystron

SLC Klystron PDES (desired phase) may be stepped. Defined by:The name of an SLC Klystron with PDES secondary. Recognised by: matching regexp KLYS:.*//PDES. Step range:defined by 3 floats: start-value, increment, end-value-min.

Step action: Use the AIDA SLC Klystron interface to change the PDES. That is, use AIDA name KLYSTRIM//PDES, with the first element of the passed DaValue being the name of the Klystron, as given by the user. See [AIDA-KLYS].

Sampled Variables

This subsection describes the variables whose value CP should be able to acquire.

TIME
seconds elapsed since start of acquisition
ATIM
seconds elapsed since midnight
LCLS EPICS Beam Synchronous device(s)

The readable data of some device types, such as BPMs, TOROiods, Faraday cups some in the LCLS EPICS system, should be read "synchronously". That is, synchronized to a beam pulse, so that the values acquired for those devices together are known to be synchronized to that beam pule. Where one or more such devices are entered as Sampled Variables, Correlation plots must collect them together, and use the Beam Synchronous Acquisition system API to acquire them on the same beam pulse.

Defined by:The EPICS BSA name of each device to be acquired synchronously. The list of beam synchronous devices is given in [BSALIST.

Recognized by: TODO: See how to recognize items in this list and only these items.

Acquired by:See Matlab BSA API in lieu of source EPICS API for a description of the BSA user interface [BSA].

There must be a way to enter the number of pulses to average, which will pertain to all the sampled variable devices entered which are to be treated as beam synchronous.

Acquisition of buffered (nrpos > 1) BPM readings is [I think] a 'later' item. Comments are invited on the priority of this functionality.

EPICS PV
An "arbitrary" EPICS record PV (in which case the .VAL channel is assumed) or a fully qualified channel name (for something other than .VAL).Recognised by: regexp .+:.+:.*^(//.*)$, that is, anything with two colons and not ending "//something", since that would make it AIDA.

Acquired value: The PV understood value as a float. Note that for this "arbitrary" PV there is no secondary status acquisition. If particular PV's must be acquired with respect to a given status, then they must be handled individually (so, if you're reading this spec, and you know of a PV who's value CP should be able to acquire, and that PV has associated with it a way to determine the status of the acquisition, and it is not listed above, please tell us).

SLC DB
An "arbitrary" SLC DB name acquired by AIDA (as opposed to acquired by EPICS as above). Recognised by: regexp (a-z){4}(:|\s+)(a-z){2}(0-9){2}(:|\s+)[1-9][0-9]{2,3}(//\s+)(a-z){3,4}, that is, the familiar "primary micro unit secondary" quadruplet, either space delimited or in the form primary:micro:unit//secondary. If the space delimited form is given, then it should be transformed to the AIDA instance//attribute syntax before attempting to check the name in the aida names system.

Acquired value:The value acquired via AIDA (by DaReference for better efficiency that DaValue), as a float.

Values, Errors and Status Associated with Each Sampled Variable

Value: Most varaibles likely to be acquired by CP are going to be real valued natively. It is sufficient to understand the value of each sampled variable as a float in the first instance. Array or "waveform" valued variables can be added later.

Error: The RMS error if the variable was "errorable" and N>1.

Status: A status value (whose definition is to be decided), for the read value of the variable at each acquisition cycle. This is likely to be an integer, or possibly a mask, by which CP understands the "reliability" of every acquired point of every variable.

The Acquisition Cycle

Naming help

Given a partial name (most significant characters) CP should provide intelligent name completion help. This should not swamp the user with all possible matches but rather search EPICS, AIDA, and its own directory service of special names, to find names which match the input so far, up to the next most significant separator (":" in the case of EPICS and AIDA names).

eg, if someone types in "LLRF ?" or "LLRF: ?" they should get simply "IN20 LI21 LI24 LI29" in reply, those tokens being the next most significant in the following name-part in the set of all possible names which match (informally) "LLRF:*:".

Auto Acq and Manual Acq

As well as the intuitive "auto" acquisition interface, in which correlation plots steps through the step variable values (either as fast as it can or according to the TIME range specification), it should also allow someone to manually specify when to take the next sample (by hitting a button).

Multiple samples per sample cycle

Some variables, such as beam synchronous variables, should be read a number of times for each acquisition cycle. Their value will the be the mean value, plus an associated 1 standard deviation. Call such variables "errorable". For such variables CP must take a single parameter for the aquistion as a whole, n, being the number of times all such errorable devices are sampled in each acquisition cycle.

Button and Data reload

A user should be able to save and reload a CP configuration - that is an "experimental setup". This would functionally take two forms (though in practice these two would probably be managed by the same facility):

  1. variable definition load. In this case a user want to save, and reload, the variable names in all of the cells.
  2. Data save and load - ability to save the data acquired for all variables in the last acquisition, and subsequently to load that data back. If the variable values included errorsthen the error values must be saved and reloaded also. Fit results need not be saved and loaded. It would be fine if this data export were implemented by the Textual Display SEAL application.

1D and 2D Acquisitions

Both "1d" (and single step variable) and "2d" (two step variables) should be supported. In 2d acquisitions one step variable (the "primary" sv) is slow-moving and the other ("secondary" stv) is fast-moving. Thereby, the data collected for any single sampled variables is a matrix, and plotted as a mesh (or surface) in the coordinate system of the primary vs secondary vs sampled-variable.

Plotting and Data Fitting

This section deals with the requirements for charting the results of data acquisitions.

1D Plots

For 1D scans the following plots must be supported at the least:

  1. one stv vs one sv
  2. one sv vs one sv

The values of sampled variables for which sampling errors were acquired (for instance, when averaging BPMS values over a number of beam position samples), must be displayed with error bars.

Fitting

At the minimum, fitting functionality should be to offer chi-sq linear and polynomial fits. If no errors, then unweighted fitting; if errors, then weighted fitting. ideally the Curve Fitting Toolbox from mathworks can be offered as the display and fitting engine.

Variable for Plot Selection of 1D scans

It must be very easy to select which variables (both step and sampled) to be plotted on each axis. Note that it is not true that users always want to plot the independent variables on the x-axis and dependent variables always on the y-axis.

  1. "plot pairs". For instance, in the SCP, one plot selection mode is "plot-pairs" in which two sampled variables can be selected to plot one-vs-the-other with a single button push on either one of them. A user can then plan which variables are put on which cells in order to facilitate easy plot selection.
  2. "all plots x" and "all plots y". Assign one stv or sv to one axis and then any selection of another cell plots the variable in that cell on the other axis.

The default should be that the primary step variable is assigned to the x-axis, and the user selects which sampled variable to plot on the y-axis.

2D Plots

For 2D scans, at least the mesh grid of stv1 vs stv2 vs svn must be plottable. There must obviously be some way to nominate which sv to plot.

Settle Time

The Settle Time is a period of time which CP should wait between the time it has stepped a step variable to a new value in the acquisition cycle and the time that CP should begin collecting data for the sampled variables. This gives, for instance, magnets, or klystrons, time to settle and feedback loop to take effect before the acquisition is made. The Settle Time must be enterable by the user, in seconds, for each of the step variables individually (that is, there may be 2 settle times, one for the inner step variable, and one for the outer).

Ramping

Magnets and klystrons, in particular, may cause beam disruption if they are moved to the starting value of the step range in "one go". Rather they should be ramped slowly to the point at which the acquisition should start, and, after the acquisition cycle has completed, ramped slowly back to their nominal value.

Tabular display and data edit facility

CP must be able to display all the data for an acquisition in tabular form. This functionality should also permit a user to "deselect" a given data point for a given variable, so that that point does not show up in successive plots.

Global and Non-Functional Requirements

Abort acquisition

CTRL-C. One must be able to interrupt an acquisition cycle, part way completed, and review the data collected so far as if the acquisition had completed normally.

API

CP must be useable both through its own GUI and as a data acquisition engine by other applications. The data acq API should not imply use of a specific GUI framework like Eclipse/SEAL - so it can be used by a simple batch Java app, or Swing/XAL.

Basis of CP

ECLIPSE SEAL or XAL 1d/2-d and XIO combination. See Scope and Goals below.

Scope and Goals

Evaluation of XAL 1-d and 2-d applications for suitability as basis of Correlation Plots, either as i) Correlation Plots being implemented as modifications to XAL 1-d and 2-d applications, or ii) in part (code from XAL 1-d and 2-d scan being used in Correlation Plots), iii) XAL 1-d & 2-d apps implemented only as SEAL launchable items, with CP developed as a separate application.

Out of Scope and Antirequirements

CP will not include the ability to step or read SLC control system variables other than those listed above. Specifically, it will not include facilities for making beam synchronous acquisition from the SLC control system.

No need to write fit parameters to disk during data save and reload.

There is no requirement for spreadsheet-like arithmetic, as in the SLC CP, in the first release.

Success Criteria

  1. XAL 1-d and 2-d evaluated and design for CP based on results of that evaluation.
  2. Fast user interface. This is both in terms of response, but also in terms of usability of the UI - it must be easy to set up the devices to partake in the acquisition, and be easy to identify which variables are to be plotted against one another
  3. Good error handling should the acquisition of a sampled variable fail. Good error messaging to let the user know why an acquisition failed. Short timeout for acq, so users don't have to wait long in human terms.
  4. Good plotting and fitting support.

Deliverables and Expected Calendar

  1. Eval. matlab plotting & fitting (done). Write short cost/benefit analysis, July 07
  2. Eval. XAL 1-d, 2-d and scan apps. Write short finding report, July 07
  3. Correlation Plots application delivered, Oct 07
  4. Correlation Plots help documentation, Oct 07
  5. Talk delivered to users on use of CP, Oct 07

Coordination of Activities

See Debbie Rogind, Mike Zelazny and Stephanie Allison re Beam Synchronous Acquisition.

Check requirements for step and sampled variables with Paul Emma, Pat Krecjik, Henrik Loos.

Forward References to Design

This section includes some issues which should be borne in mind during design.

Name Classification. Since CP will capable of acquisition of more than just EPICS PVs, it must include some facility for classification of names, so that it can distinguish sources. The order in which these are checked should be from specific variable type, to general.

  1. each specialized "device" that CP understands should be checked first
  2. generic EPICS PV understood as a float (using IRMIS?)
  3. generic AIDA "PV" understood as a float (using a revised version of "aidalist" that access aida nameserver directly)

Questions

  1. Should we support stepping an arbitrary SLC DB value? Note that it is not useful to set most SLC DB secondaries that are settable, unless some external action like "trim" is done additionally. Still, if it's useful to add this ability it can be done easily by AIDA

Glossary

variable
A "variable" is a steppable or acquirable entity. Roughly speaking variables are mostly control system devices, but TIME, the RMS of a beam orbit, etc, may also be variables.
Step variable (stv)
The stepped, or "independent" variable in an acquisition. For instance a variable such as a magnet device, which is stepped through a predefined range of values, where for each value to which it is stepped, all the sampled variables are sampled. The number of step variables is usually 1 (a "1D" scan), though there may be 2 (a "2D" scan). In a 2D scan, one step variable, the "secondary" is stepped through its range for each step value of the other "primary" step variable.
Sampled variable (sv)
An acquired, or "dependent", variable, as opposed to one that is stepped. There may be a large number of sampled variables in a Correlation Plots acquisition. The SCP can handle 160.
cell
A cell is the place on the screen where a variable is defined. It's the equivalent of a variable "button" in the SCP

References

CRRLIT
Correlation Plots Literature. http://www.slac.stanford.edu/grp/cd/soft/crr/
CRRHOMEREF
Correlation Plots homepage. http://www-mcc.slac.stanford.edu/%7Egreg/CORR_PLOTS.HTML
CRRPGREF
Correlation Plots Programmers Guide, Greg White, 1995. http://www-mcc.slac.stanford.edu/~greg/DOC/CRR/CRR_PROG_GUIDE.TXT
TEXTDISP
TextualDisplay Developer's Guide, Sergei Chevtsov, June 27, 2007. http://www.slac.stanford.edu/grp/lcls/controls/docs/physics/seal/textdisp_dev_guide.html.
AIDA-MKB
The Aida Multiknob API, http://www.slac.stanford.edu/grp/cd/soft/aida/slcMultiknobDpGuide.html
AIDA-MAG
The AIDA SLC Magnet API, http://www.slac.stanford.edu/grp/cd/soft/aida/slcMagnetDpGuide.html
AIDA-KLYS
The AIDA SLC Klystron API, http://www.slac.stanford.edu/grp/cd/soft/aida/slcKlysDpGuide.html
BSA
Beam synchronous acquisition, http://lcls-dev/tiki-index.php?page=Matlab_Programmers_Guide, Chapter 4.
BSALIST
An example list of Beam Synchronous acquirable devices, Excel spreadsheet, http://www.slac.stanford.edu/grp/lcls/controls/docs/physics/cp/BSANamesr-3.xls

1. Physicists will be used to mean any person performing a correlation experiment on the machine.