Segment calculation / manipulation utility

Seg_calc is a utility program that evaluates data quality segment lists.

Running seg_calc

The seg_calc command has the following syntax:

      seg_calc [--help] [-c <command>] [-i <command-file>] [-v] \
               [-s:<list-name> <seg-file>] [-f <format>] [--debug n] \
	       <seg-file1> [... <seg-fileN>]

Where seg-file1 ... seg-fileN are files containing segment to be manipulated. Segments are manipulated and written under the control of a series of commands listed in the <command> or <command-file> arguments. The -c command string is a list of commands separated by semicolons. The file specified by the -i argument contains one or more commands, one command per line. If both arguments are entered, the commands specified by the '-c' argument are executed followed by those commands in the file specified by the '-i' argument. If '-s' was specified, the specified segment list is read from the file name in the following argument. The -v argument causes the command to be printed to stderr before it is executed, and result and timing information to be printed when it is completed.

Segment Manipulation Commands

The following segment manipulation commands are recognized by the program:

      define  [-name | -replace] <list-name> [-eval <expr>]

Create a segment list named <list-name> and optionally filled by evaluating <expr>. -replace must be specified if the segment list name already exists.

Echo a comment string.

      echo <string>

Execute a macro

      exec  [-cwd <pwd>] <macro>

The command stream reads from the file specified by <macro>. The default directory is changed to <pwd> before attempting to open the macro file if -cwd is specified.

Print a segment list index

      index [-name <seglist>]

Read segment from an flat text file

      read -file <file-name> [-name <seglist>] [-format <format-code>] \
	   [-prefix <prefix-string>]

The read command read one or more segments from an ascii text file. The file is specified by the mandatory <file-name> argument. If a segment list name is given, only the specified segment list will be read in. The read command attempts to discover the file format, but aformat string may be specified by one or more of the following characters a (action), d (duration), e (end time), i (identifier), n (name), s(start time) or v (version), separated by colons. The prefix_string is prepended on to all segment list names.

      write  [-name <segment-list>] [-file <file-name>] [-format <format-code>]

The specified segment name is written to an output file. The <file-name> argument specifies the output file. The format code is specified in the same format as the input format (see read command).


An expression is a combination of alphanumeric symbols (i.e. segment list names), operators, numeric values and function calls (function name followed by a parenthesized list of arguments).


Expressions may contain function calls with the syntax func(<expr>). The functions currently defined in seg_calc are:

Symbol Value
not(s) Return the list of all times not included in segment list s.
now() The current time
pad(s,tf,tb) Return a list of segments resulting from padding each segment in s by tf seconds in the front and tb seconds in the back. For example pad(seg(t1,t2),2,4) returns a list containing the segment [t1-2, t2+4).
seg(t1,t2) Specify a constant segment [t1, t2). The seg function returns a segments list with a single segment.
xor(s1,s2) Returns a list containing all sement that are in one of the argument lists but not the other (i.e. (s1 & not(s2)) | (s2 & not(s1)) ).


Notes and Warnings:

  1. This software carries no warrantees

J. Zweizig
1.1; last modified October 12, 2007

alphabetic index hierarchy of classes

Please send questions and comments to

generated by doc++