2.4.6. - Data Handling and Plotting Functions
array_op(cmd, arr [, args ...])
cmd
:
"fill"
- Fills the array
arr
with values. For a two-dimensional array,array_op("fill", arr, u, v)
produces for each elementarr[i][j] = u × i + v × j
With subarrays,i
andj
refer to the subarray index. Also,i
andj
always increase, even for reversed subarrays, soarray_op("fill", arr[-1:0][-1:0], 1, 1)
fillsarr
in reverse order. "contract"
- For
args
u
andv
, returns a new array with dimensions contracted by a factor ofu
in rows andv
in columns. Elements of the new array are formed by averaging everyu
elements of each row with everyv
elements of each column. If there are leftover rows or columns, they are averaged also. "min" or "gmin"
-
Returns the minimum value contained in the array.
"max" or "gmax"
-
Returns the maximum value contained in the array.
"i_at_min" or "i_at_gmin"
-
Returns the
index
number of the minimum value of the array.
For a two-dimensional array dimensioned as
D[N][M]
, the index number of elementD[i][j]
is(i × M) + j
. Ifarr
is a subarray, the index is with respect to the full array, although the minimum is the minimum value in the specified subarray. "i_at_max" or "i_at_gmax"
-
Returns the index number of the maximum value of the array.
See
"i_at_min"
for subarray considerations. "row_at_min" or "rmin"
-
Returns the row number containing the minimum value of the array.
If
arr
is a subarray, the row is with respect to the full array, although the minimum is the minimum value in the specified subarray. "row_at_max" or "rmax"
-
Returns the row number containing the maximum value of the array.
If
arr
is a subarray, the row is with respect to the full array, although the maximum is the maximum value in the specified subarray. "col_at_min" or "cmin"
-
Returns the column number containing the minimum value of the array.
If
arr
is a subarray, the column is with respect to the full array, although the minimum is the minimum value in the specified subarray. "col_at_max" or "cmax"
-
Returns the column number containing the maximum value of the array.
If
arr
is a subarray, the column is with respect to the full array, although the maximum is the maximum value in the specified subarray. "i_<=_value"
-
Returns the
index
number of the nearest element
of the array with a value at or less than
u
. For a two-dimensional array dimensioned asD[N][M]
, the index number of elementD[i][j]
is(i × M) + j
. Unlike"i_at_min"
,"i_at_max"
, etc., ifarr
is a subarray, the index is with respect to the subarray. "i_>=_value"
-
Returns the
index
number of the nearest element
of the array with a value at or greater than
u
, starting from the last element. For a two-dimensional array dimensioned asD[N][M]
, the index number of elementD[i][j]
is(i × M) + j
. Unlike"i_at_min"
,"i_at_max"
, etc., ifarr
is a subarray, the index is with respect to the subarray. "fwhm"
-
Requires two array arguments, each representing a single row
or single column.
Returns the full-width in the first array
at half the maximum value of the second array.
"cfwhm"
-
Requires two array arguments, each representing a single row
or single column.
Returns the center of the full-width
in the first array at half the maximum value of the second array.
"uhmx"
-
Requires two array arguments, each representing a single row
or single column.
Returns the value in the first array
corresponding to half the maximum value in the second array
and at a higher index.
"lhmx"
-
Requires two array arguments, each representing a single row
or single column.
Returns the value in the first array
corresponding to half the maximum value in the second array
and at a lower index.
"com"
-
Requires two array arguments, each representing a single row
or single column.
Returns the center of mass in the first array
with respect to the second array.
The value is the sum of the products of each element
of the first array and the corresponding element of the second array,
divided by the number of points.
"x_at_min"
-
Requires two array arguments, each representing a single row
or single column.
Returns the element in the first array
that corresponds to the minimum value in the second array.
"x_at_max"
-
Requires two array arguments, each representing a single row
or single column.
Returns the element in the first array
that corresponds to the maximum value in the second array.
"sum" or "gsum"
-
Returns the sum of the elements of the array.
If there is a third argument greater than zero,
the array is considered as a sequence of frames,
with the third argument the number of rows in each frame.
The return value is a new array with that number of rows
and the same number of columns as the original array.
Each element of the returned array is the sum
of the corresponding elements of each frame.
For example, if the original array is dimensioned
as
data[N][M]
, the return value forarr = array_op("sum", data, R)
is a new array of dimensionarr[N/R][M]
, where each elementarr[i][j]
is the sum ofk
from0
toR - 1
ofdata[i + k × N / R][j]
. "sumsq"
-
Returns the sum of the squares of the elements of the array.
If there is a third argument and it is greater than zero,
the interpretation is the same as above for
"sum"
, except the elements in the returned array are sums of squares of the elements in the original array. "transpose"
-
Returns a new array of the same type with the rows and columns switched.
"updated?"
-
Returns nonzero if the data in the array has been accessed for
writing since the last check, otherwise returns zero.
"rows"
-
Returns the number of rows in the array.
"cols"
-
Returns the number of columns in the array.
"row_wise"
-
With a nonzero third argument, forces the
array_dump()
,array_fit()
,array_pipe()
,array_plot()
andarray_read()
functions to treat the array as row-wise, meaning each row corresponds to a data point. With only two arguments, returns nonzero if the array is already set to row-wise mode. "col_wise"
-
As above, but sets or indicates the column-wise sense of the array.
"sort"
-
Returns an ascending sort of the array.
"swap"
-
Swaps the bytes of the named array.
The command can change big-endian short- or long-integer data
to little-endian and vice versa.
For most built-in data collection, spec automatically
swaps bytes as appropriate, but this function
is available for other cases that may come up.
"frame_size"
-
The number of rows in a frame.
The frame size is part of the shared array header
and may be useful to auxiliary programs,
although the value is maintained for non-shared arrays.
Note, setting the frame size to zero
will clear the
"frames"
tag. Setting the frame size to a non-zero value will set the"frames"
tag. "latest_frame"
-
The most recently updated frame.
The latest frame is part of the shared array header
and may be useful to auxiliary programs,
although the value is maintained for non-shared arrays.
"tag"
-
Shared arrays can be tagged with a type
that will be available to other processes accessing the array.
Usage is
array_op("tag", arr, arg)
wherearr
is the array andarg
is"mca"
,"image"
,"frames"
,"scan"
or"info"
. "untag"
-
Removes tag information.
"info"
-
Returns or sets the
info
field of a shared array segment.
The field can be contain up to 512 bytes of arbitrary
text.
When setting the field, if the string argument is
longer than 512 bytes, the first 512 bytes will be copied.
The function returns the number of bytes copied, -1 if
arr
is not a shared array or 0 ifarr
is a shared array that doesn't support the info field. The info field is included inSHM_VERSION
version 6 headers, added in spec release 6.00.08. "meta"
-
Returns or sets the
meta
area of a shared array segment.
With spec, the field can contain up to 8,192 bytes of arbitrary
text.
When setting the field, if the string argument is
longer than 8,192 bytes, the first 8,192 bytes will be copied.
The function returns the number of bytes copied, -1 if
arr
is not a shared array or 0 ifarr
is a shared array that doesn't support the meta field. The meta field is included inSHM_VERSION
version 6 headers, added in spec release 6.00.08.
array_dump([file, ] arr [, arr2 ...][, options ...])
arr
and optionally arrays
arr2
,
..., etc.
If the initial optional
file
argument is given,
the output is to the named file or device.
Otherwise, output is to all "on" output devices, most notably the screen.
The additional optional
options
arguments are strings
that control the formatting.
A format argument can specify a printf()-style format for the values. The default format is
"%.9g"
, which prints nine digits of precision using fixed point
or exponential format, whichever is more appropriate
to the value's magnitude.
Recognized format characters are
e
or
E
(exponential),
f
(fixed point),
g
or
G
(fixed or exponential based on magnitude),
d
(decimal integer),
u
(unsigned integer),
o
(octal integer),
x
or
X
(hexadecimal integer).
All formats accept standard options such as precision and field width.
For example,
"%15.8f"
uses fixed-point format with eight digits
after the decimal point and a fifteen-character-wide field.
For the integer formats, double values will be converted to integers.
Also, initial characters can be included in the format string,
for example,
"0x%08x"
is valid.
The option
"%D=c"
, specifies
an alternate delimiter character
c
to replace the default space character delimiter
that is placed between each element in a row of output.
For example, one might use a comma, a colon or the tab character
with
"%D=,"
, "%D=:"
or
"%D=\t"
, respectively.
Use
"%D="
for no delimiter.
Also, by default, the output is one data row per line. Thus, for one-dimensional row-wise arrays, all elements will be printed on one line, while one-dimensional column-wise array will have just one data element per line. For two-dimensional arrays, each line will contain one row of data. The number of elements per line can be controlled with the options
"%#[C|W]"
. For one-dimensional arrays, the number
#
is the number of elements
to print per line.
For two-dimensional arrays,
#
is the number of rows to print per line.
If an optional
W
is added, the number becomes
the number of elements to print per line,
which can split two-dimensional arrays at different points in the rows.
If an optional
C
is added to the option string,
a backslash will be added to each line where a row is split.
(The C-PLOT
scans.4
user function can properly interpret
such "continued" lines for one-dimensional MCA-type array data.)
Finally, the various options can be combined in a single string. For example,
array_dump(data, "%15.4f", "%D=:", "%8W")and
array_dump(data, "%15.4f%D=:%8W")work the same.
array_copy(dst, src [, ...])
dst
with
bytes from the source arrays or strings in the subsequent arguments.
The arrays can be of
different types, which allows creating a binary data stream of mixed types.
If a source argument is not a data array, the string value of the
argument is copied.
As an example of how
array_copy()
might be useful, consider a device
that sends and receives a binary stream consisting of four
floats followed by two integers then seven more floats.
Here is how to prepare a byte array containing the mixed
binary data types:
float array float_d[11] ulong array long_d[2] ubyte array ubyte_d[52] # ... assign values to float_d and long_d, then ... array_copy(ubyte_d, float_d[0:3], long_d, float_d[4:]) sock_put("host", ubyte_d)
Note, the source array is not erased prior to the copy. The above assignment could also be carried out as follows::
array_copy(ubyte_d[0:15,24:], float_d) array_copy(ubyte_d[16:], long_d)Four floats consume sixteen bytes. Two integers consume eight bytes. The subarray notation selects the first sixteen bytes of
ubyte_d
for the first four floats,
then skips eight bytes for where the integers will go, then copies the remainder
of the floats.
Since only as much data will be copied as is contained in the source array
and since the source arrays are fixed size, it is not necessary to
specify the final byte position in the destinations.
If the returned data uses the same format, floats and integers can be extracted using similar syntax:
sock_get("host", ubyte_d) array_copy(float_d, ubyte_d[0:15], ubyte_d[24:]) array_copy(long_d, ubyte_d[16:23])The function will only copy as many bytes as fit into the preallocated space of the destination array.
If the source arguments are not data arrays, spec will take the string value of the argument and copy the ASCII value of each byte to corresponding bytes in the destination. The terminating null byte is not copied. If the argument is a number, the string value of the number is what one would see on the display with the
print
command.
The function returns the updated array
dst
.
If
dst
is a subarray,
the full array is returned.
A -1 is returned if
dst
is not a
data array.
Note, this function allows arbitrary bytes to be copied to the elements of float and double arrays, which can result in undefined or not a number (NaN) values for those elements.
The
array_copy()
function appeared in spec release 6.00.07.
array_read(file, arr [, options])
file
,
and stuffs the data into the array
arr
.
For a row-wise array, the values on each line of the file
are assigned into successive columns for each row of the array.
If there are more items on a line in the file than columns in the array,
or if there are more points in the file than rows in the array, the extra
values are ignored.
For a column-wise array, each row of the data file
is assigned to successive columns of the array.
If
arr
is a string array, successive bytes from each line of the file
are assigned to elements of the array (as of spec release 6.04.05).
Lines beginning with the
#
character are ignored, except for the case where
arr
is
a string array.
There is no limit on the length of the input line.
Prior to spec release 6.03.05, the maximum
length was 2,048 characters.
The only currently recognized option is a
"C=#"
, where
#
is the starting column number
in the file to use when making assignments (as of spec release 6.03.05).
Returns -1 if the file can't be opened, otherwise returns the number of points (bytes in the case of a string array) read and assigned.
array_pipe(program [, args [, arr_out [, arr_in]]]))
array_plot(arr [, arr2 ...]))
arr
(and optional additional array arguments).
Depending on whether
arr
is a row-wise or column-wise array,
the first column or first row elements are used for
x.
Subsequent elements (up to a maximum of 64)
are plotted along the
y
axis.
If preceded by a call of
plot_cntl("addpoint")
and the ranges have not changed, only the last point in the array is drawn.
If preceded by a call of
plot_cntl("addline")
the current plot
will not be erased, and the plot ranges will not be changed.
The plotting area is not automatically erased
by a call of
array_plot()
- use
plot_cntl("erase")
for that.
The axis ranges are set using the
plot_range()
function.
See
plot_cntl()
for other options that affect drawing the plot.
array_fit(pars, arr [, arr2 ...])
arr
.
The fitted parameters are returned in the associative array
pars
.
The function returns the
chi-squared
value of the fit,
if the fit was successful.
A -1 is returned if the covariance matrix is singular.
The fit algorithm is along the same lines as the
lfit()
routine
in
Numerical Recipes
(W.H. Press, et al., Cambridge University Press, 1986, page 512).
plot_cntl(cmd)
cmd
is a string of comma- or space-delimited options.
The following options may be
preceded by a minus sign to turn the associated feature
off, nothing (or an optional plus
sign) to turn the feature on or a question mark to return a value of
one or a zero
that indicates whether the associated feature is currently on or off:
"xlog"
- Use a logarithmic
x
axis.
"ylog"
- Use a logarithmic
y
axis.
"xexact"
- Force
x-axis
minimum and maximum to be set to the scan endpoints
(as opposed to being rounded).
"colors"
- Enable the use of colors.
"dots"
- Draw graphics-mode points with large dots.
"lines"
- Connect graphics-mode points with lines.
"ebars"
- Draw vertical lines through each point of length equal to the twice the
square root of the
y
value.
"persist"
- Keep graphics mode on after ordinary user input.
"perpetual"
- Keep graphics mode on continuously (appropriate if using X windows, for example).
Other
plot_cntl()
options are:
"colors=bgnd:win:text:axis:symb:..."
- Assigns colors for drawing the various graphics-mode elements.
The values for
bgnd
(the background color of the area outside the axis),win
(the background color of the area inside the axis),text
(the color of the text),axis
(the color of the axis) andsymb
...
(the color of the plotting symbols) are integers. The first 10 colors are standardized according to the following table:0 background (normally white or black) 1 foreground (normally black or white) 2 blue 3 red 4 green 5 yellow 6 cyan 7 magenta 8 white 9 black
Other colors may be available depending on the particular device. You don't have to assign values to all colors. "colors[numb]"
- Returns the current color assignments,
where
numb
is a number between zero and 67. Numbers zero through three return the colors assigned to thebgnd
,win
,text
andaxis
elements respectively. Numbers from 4 through 67 return the colors assigned to the symbols for data elements zero through 63. "filternumb"
- Selects filter number
numb
, wherenumb
can be any of the numerals from 1 through 5. All plotting commands are directed to this filter. The default filter is filter 1. Each filter is associated with a separate process. On an X windows display, each filter is associated with a separate window. "title=string"
- On an X windows display,
the title given by string is used in
the
XSetWMName()
and
XSetWMIconName()
calls to set the window and icon labels.
With most X11 window managers, that means the title will appear in the
window's title bar.
"geometry=widthxheight+xoff+yoff"
- With the
x11
high-resolution plot windows,
sets the size and position of the window.
As with the conventional X11 syntax for specifying window geometry,
not all parts of the geometry string
are required.
"open"
- Turn on graphics mode.
If there is no graphics filter program
currently active for the current filter number (see above), the filter
program associated with the current
GTERM
variable is started. RecognizedGTERM
values arevga
,ega
,cga
,herc
,x11
, andsun
. "close"
- Turn off graphics mode, unless the perpetual or persistent mode
has been selected.
"kill"
- Turn off graphics mode and terminate graphics process.
"erase"
- Clear the graphics-mode screen (or the text screen
if graphics mode is off).
"addpoint"
- Before a call to
data_plot()
will cause the plot to be made with minimal redrawing. Used for updated plotting during scans. "addline"
- Before a call to
data_plot()
will prevent the current data from being erased and the new data from changing the ranges when the new data points are drawn. Used for plotting several data sets from different data groups on top of each other. "mca"
- Before a call to
data_plot()
will cause the data points to be displayed using a minimal redrawing algorithm, appropriate for displaying data actively being accumulated by an MCA-type device. The"dots"
and"ebars"
modes must be turned off for the algorithm to work effectively. "lp"
- Before a call to
data_plot()
will generate printing instructions appropriate for plotting on a 132-column printer.
plot_move(x, y [, string [, color ]])
x
and row
y
,
where column 0, row 0 is the upper left corner of the screen.
If the third argument
string
is present, it is written as a label at the given position.
If using color high-resolution graphics, the fourth
argument, if present, is the color to use to draw the label.
The background color for the entire label will be the background color
at the starting position.
If graphics mode is not on,
plot_move()
works just as
tty_move()
.
Returns
true . plot_range(xmin, xmax, ymin, ymax)
"auto"
, the corresponding range limit is determined automatically from the data
at the time the plot is drawn.
If any of the arguments is the string
"extend"
, the corresponding range limit is only changed if the current data
decrease the minimum
or increase the maximum.
Returns
true . splot_cntl(cmd)
spec can store data in up to 256 independent data arrays called groups. Each group is configured (see below) to have a particular number of data elements per point. For example, each point in a group could have elements for
H
, K
, L
, and
detector counts.
Alternatively, each point could have just
one element and be used to hold data obtained from an MCA.
Groups are configured using the
data_grp()
function.
A group can have up to 2048
elements per point.
The maximum number of points in a group is determined
by the product of the number of elements per point and the number of points.
That product can be no more than 65,536, and may be slightly
less depending on how the number of elements divides into 2048.
The maximum number of points for all groups is 262,144.
(These limits are arbitrary and are set to control the size of static
data arrays and auxiliary files.
If requested, CSS can make the limits
larger.)
When starting spec for the first time or with the -f (fresh) flag, one data group (group 0) is configured for 4096 points, with each point consisting of two elements.
When leaving spec, the current data group configuration and data points are saved.
spec has several functions to manipulate the internal data. These functions allow unary and binary arithmetic operations, math functions and analysis operations to be performed on all the elements of a group or among elements in different groups.
In the functions described below, if an element number is negative, the element number is obtained by adding the number of elements per point in the group to the negative element number. For example, element -1 is the last element, element -2 is the second to last, etc.
All functions reset to command level if an invalid group, point or element is given as an argument. Functions that don't need to return anything in particular return zero.
data_grp(grp, npts, wid)
-
Configures data group
grp
. The group will havenpts
points, each havingwid
elements. Ifnpts
andwid
match the previous values for the group, the data in the group is unchanged. Otherwise, the data values of the reconfigured group are set to zero. Ifwid
is zero, the group is eliminated. Ifnpts
is zero, as many points as possible are configured. Ifnpts
is negative, as many points as possible, but not more than-npts
are configured. Ifgrp
is -1, the current group configuration is displayed. data_info(grp, what)
-
Returns data group configuration information for group
grp
, according to the the stringwhat
. Values forwhat
are:"npts"
- the number of configured points.
"elem"
- the number of configured elements.
"last"
- the number of the last point added to the group.
"precision"
- the number of bytes per element, either 4 or 8.
If the group number is invalid, or if the stringwhat
is none of the above, returns -1. data_get(grp, npt, elem)
-
Returns the value of
element
elem
of pointnpt
in groupgrp
. data_put(grp, npt, elem, val)
-
Assigns the value
val
to elementelem
of pointnpt
in groupgrp
. data_nput(grp, npt, val0 [, val1 ... ])
-
Assigns values to point
npt
of groupgrp
. Element 0 is assignedval0
, element 1 is assignedval1
, etc. Not all elements need be given, although elements are assigned successively, starting at element 0. data_uop(g_src, e_src, g_dst, e_dst, uop [, val ])
-
Performs the unary operation specified by the string
uop
on elemente_src
for all points in groupg_src
. The results are put in elemente_dst
of the corresponding points in groupg_dst
. The source and destination groups and/or elements may be the same. If the number of points in the groups differ, the operation is carried out on up to the smallest number of points among the groups. Values foruop
are:"clr"
- clear to zero.
"fill"
- each element is set to point number, starting at 0.
"neg"
- Negative of source.
"abs"
- Absolute value of source.
"inv"
- Inverse of source.
"sin"
- Sine of source.
"cos"
- Cosine of source.
"tan"
- Tangent of source.
"asin"
- Arcsine of source.
"acos"
- Arccosine of source.
"atan"
- Arctangent of source.
"log"
- Natural logarithm of source.
"exp"
- Exponential of source.
"log10"
- Log base 10 of source.
"pow"
- The val power of source.
"copy"
- Value of source.
"rev"
- Reversed copy of source.
"sqrt"
- Square root of source.
"set"
- All elements set to the value of val.
"contract"
- Every val points are averaged to make a new point.
"add"
- Source plus val.
"sub"
- Source minus val.
"mul"
- Source times val.
"div"
- Source divided by val.
If any of the operations would result in an exception (divide by zero, log or square root of a negative number, etc), the operation is not performed and a count of the operations skipped is printed as an error message. data_bop(g0_src, e0_src, g1_src, e1_src, g_dst, e_dst, bop)
-
Performs the binary operation specified by the string
bop
on elementse0_src
ande1_src
for all points in the groupsg0_src
andg1_src
. The results are put in elemente_dst
for the corresponding points of groupg_dst
. The source and destination groups and/or elements may be the same. If the number of points in the groups differ, the operation is carried out on up to the smallest number of points among the groups. Values forbop
are:"add"
- The sum of the source elements.
"sub"
- Source 0 minus source 1.
"mul"
- The product of the source elements.
"div"
- Source 0 divided by source 1.
If the divide would result in an exception, the operation is not performed and a count of the operations skipped is printed as an error message. data_anal(grp, start, npts, el_0, el_1, op [, val ])
-
Performs the operations indicated by
op
onnpts
points in groupgrp
, starting at pointstart
. The operations use the values in elementel_0
(if applicable) andel_1
. Ifnpts
is zero, the operations are performed on points fromstart
to the last point added usingdata_nput()
ordata_put()
. The values forop
are:"min"
- Returns the minimum value of el_1.
(el_0 is unused.)
"max"
- Returns the maximum value of el_1.
(el_0 is unused.)
"i_at_min"
- Returns the point number of the data point with the
minimum value of el_1.
(el_0 is unused.)
"i_at_max"
- Returns the point number of the data point with the
maximum value of el_1.
(el_0 is unused.)
"i_<=_value"
- Returns the point number of the nearest data point in
el_1
at
or below val,
starting from the first point.
(el_0 is unused.)
"i_>=_value"
- Returns the point number of the nearest data point in
el_1
at
or above val,
starting at the last point.
(el_0 is unused.)
"uhmx"
- Returns the value in el_0 corresponding to
half the maximum value in
el_1
and
at a higher index.
"lhmx"
- Returns the value in
el_0
corresponding to
half the maximum value in
el_1
and
at a lower index.
"sum"
- Returns the sum of the values in
el_1.
(el_0
is unused.)
"fwhm"
- Returns the full-width in
el_0
at half the maximum value of
el_1.
"cfwhm"
- Returns the center of the full-width in
el_0
at half the maximum value of
el_1.
"com"
- Returns the center of mass in
el_0
with respect to
el_1.
The value is the sum of the products of each
el_0
and
el_1
divided by the number of points.
"x_at_min"
- Returns the value of
el_0
at the minimum in
el_1.
"x_at_max"
- Returns the value of
el_0
at the maximum in
el_1.
"sumsq"
- Returns the sum of the squares in el_1. (el_0 is unused.)
The following operations treat a data group as a two dimensional data array with rows indexed by the point number and the columns indexed by the element number. The operations work on the portion of the group determined by the starting rowstart
the number of rowsnpts
, the starting columnel_0
and the end rowel_1
. As usual, ifnpts
is zero, all points (rows) fromstart
to the last are considered. A negative element (column) number is added to the group width to obtain the element (column) to use."gmin"
- Returns the minimum value.
"gmax"
- Returns the maximum value.
"gsum"
- Returns the sum of all values.
"i_at_gmin"
- Returns the index number of the minimum value.
The index number is the row number times the group width plus the
element number.
"i_at_gmax"
- Returns the index number, as defined above, of the maximum value.
data_read(file_name, grp, start, npts)
-
Reads data from the ASCII file
file_name
, and stuffs the data into groupgrp
starting at pointstart
, reading up tonpts
points. Ifnpts
is zero, all the points in the file are read. The values on each line of the file are assigned into successive elements for each point in the group. If there are more elements on a line in the file than fit in the group, or if there are more points in the file than in the group, the extra values are ignored. Lines beginning with the#
character are ignored. Returns -1 if the file can't be opened, otherwise returns the number of points read. data_fit(pars, grp, start, npts, el_data, el_data [, ... ])
-
Performs a linear fit of the data in element
el_data
to the terms in the elements specified byel_pars
. The fitted parameters are returned in the arraypars
supplied by the user. The function returns the chi-squared value of the fit, if the fit was successful. A -1 is returned if there are insufficient arguments or the covariance matrix is singular. The fit algorithm is along the same lines as the lfit() routine in Numerical Recipes (W.H. Press, et al., Cambridge University Press, 1986, page 512). data_plot(grp, start, npts, el_0, el_1 [, el_2 ... ])
-
Plots the current data in group
grp
starting at pointstart
and plottingnpts
points. Elementel_0
is used for x. Elements given by the subsequent arguments (up to a maximum of 64) are plotted along the y axis. The element arguments can be combined in a single space- or comma-delimited string, which can make creation of macros to plot a variable numbers of curves in the same plot window easier.
Ifnpts
is zero, only the points fromstart
to the last point added usingdata_nput()
ordata_put()
are plotted.
If preceded by a call ofplot_cntl("addpoint")
and the ranges have not changed, only pointstart
is drawn. If preceded by a call of+
npts- 1
plot_cntl("addline")
the current plot will not be erased, and the plot ranges will not be changed.
The plotting area is not automatically erased by a call ofdata_plot()
-useplot_cntl("erase")
for that. The axis ranges are set using theplot_range()
function. Seeplot_cntl()
for other options that affect drawing the plot. data_dump(grp, start, npts, el_0, [, el_1 ... ] [, fmt1 ] [, fmt2 ])
-
Efficiently writes elements from group
grp
to turned on output devices. The starting point isstart
and the number of points isnpts
. The elements specified byel_0
,e1_1
, etc., are printed. Ifel_0
is the string"all"
, all the elements for each point are printed. Ifnpts
is zero, only the points fromstart
to the last point added usingdata_nput()
ordata_put()
are printed. The element arguments can be combined in a single space- or comma-delimited string.
The optional argumentfmt1
is a string, having the format"%#"
, that specifies how many data points (specified by the number#
) are to be printed on each line. If the number#
is followed by the letterC
, a backslash is added to each continued line, appropriate for saving MCA data in manageable length lines. New versions (since May 1, 1995) of the C-PLOT scans.4 user function interpret the continued lines correctly for MCA data. The optional argumentfmt2
is a string that specifies an alternate printf()-style format for the values. Onlye
,g
andf
formats are recognized. For example,"%15.8f"
uses fixed-point format with eight digits after the decimal point and a fifteen-character-wide field. The default output format is"%g"
. See printf() in a C manual for more information. Note that in the default installation, the internal data arrays use single-precision floating values, which contain only about 8 decimal digits of significance.
- 2.4.6.1. - Binary Input/Output
2.4.6.2. - The Data-Pipe Facility