spec

Software for Diffraction

2.3.4.2. - Data Arrays



The second kind of array is the data array. While associative arrays are indexed by arbitrary strings or numbers and can store either strings or numbers, data arrays are indexed by consecutive integers (starting from zero, as is the C convention) and hold a specific data type, such as short integer, float, double, etc.

Data arrays must be specifically declared and dimensioned using the array keyword (unlike associative arrays, which can come into existence when used in an expression). The arrays can have one or two dimensions. The mca_get() and image_get() functions can directly fill arrays with data from one- or two-dimensional detectors.

Data arrays can be used in expressions containing the standard arithmetic operators to perform simultaneous operations on each element of the array. In addition, a subarray syntax provides a method for performing assignments, operations and functions on only portions of the array.

The functions array_read(), array_dump(), array_copy(), array_op(), array_plot(), array_fit() and array_pipe() handle special array operations. The functions fmt_read() and fmt_write() transfer array data to and from binary-format data files. The functions mca_get(), mca_put(), image_get() and image_put() accept array arguments.

The print command will print data arrays in a concise format on the screen, giving a count of repeated columns and rows, rather than printing each array element.

Array data can be placed in shared memory, making the data accessible to other processes, such as image-display or data-crunching programs. The shared arrays can both be read and written by the other processes. The implementation includes a number of special aids for making the processes work smoothly with spec.

The data values of data-array elements are not saved in the user's state file, unlike associative array elements.