binplot
Description
binplot is a utility designed to visualize binary data, specifically streams of 16-bit short integers, by plotting them onto a Metafile. It creates a 2D graph, where the x-axis typically represents the index (or time) and the y-axis represents the data value. The plot dimensions, ranges, and output file are configurable.
Usage
binplot [-infile <file>] [-outfile <metafile>]
Arguments
| Option | Description | Â |
|---|---|---|
-infile <file> | Specifies the input binary file containing 16-bit short integers. If not specified, data is read from standard input. | Â |
-outfile <metafile> | Specifies the output Metafile name. | plot.meta |
How It Works
- Input Reading:
- The tool reads 16-bit short integers from either the specified input file (
-infile) or standard input. - The entire input stream is loaded into a
short *tracearray in memory.
- The tool reads 16-bit short integers from either the specified input file (
- Plot Initialization:
- It determines the plot dimensions (
dx,dy) and the number of plots (noplots, hardcoded to 1 in the provided source). - A Metafile is opened (
plot_open) with the specified dimensions. - A basic bounding box is drawn on the plot area.
- It determines the plot dimensions (
- Axis Scaling:
- The x-axis range (
xmin,xmax) is set from 0 to the total number of points (nopoints). - The y-axis range (
ymin,ymax) is hardcoded to the full range of a 16-bit short integer (-32768 to 32767).
- The x-axis range (
- Data Plotting:
- The tool iterates through the
tracearray. - For each data point (
xval,yval):- It converts the
xvalandyvalto screen coordinates (xpos,ypos) based on the defined plot area and ranges. - It then draws a line segment from the previous point (
oldxpos,oldypos) to the current point (xpos,ypos).
- It converts the
- The tool iterates through the
- Output: The generated plot is saved as a Metafile.