Shell Utilities

The apps/awkies/ directory contains lightweight Bash/AWK scripts for quick manipulation of text-based data files. They operate on whitespace-delimited matrices and are useful for pre- and post-processing data outside of Python.

getrange.x

Compute per-dimension ranges of a sample matrix.

Given an \(N \times d\) data file, this script prints a \(d \times 2\) range table (min, max per column). An optional cushion fraction expands each range by a specified fraction of its width.

Usage:

getrange.x samples.dat              # exact ranges
getrange.x samples.dat 0.05         # 5 % cushion on each side

Arguments:

Argument

Description

<filename>

Whitespace-delimited data file (\(N \times d\)).

[cushion_fraction]

Optional fraction (default 0) to pad each range symmetrically.

scale.x

Scale matrix data between a given parameter domain and \([-1, 1]^d\).

Reads an \(N \times d\) data file and a \(d \times 2\) domain file (one min max row per dimension), then scales each column to or from the unit hypercube.

Usage:

scale.x input.dat to   domain.dat output.dat   # [-1,1] -> domain
scale.x input.dat from domain.dat output.dat   # domain -> [-1,1]

Arguments:

Argument

Description

<input>

Input data file.

<to|from>

Direction: to maps from \([-1,1]\) to the domain; from maps from the domain to \([-1,1]\).

<domain>

Domain file (\(d\) rows, 2 columns: min and max).

<output>

Output file for the scaled data.

transpose.x

Transpose a whitespace-delimited matrix file.

Reads an \(N \times d\) file and writes a \(d \times N\) file to standard output.

Usage:

transpose.x matrix.dat > matrix_T.dat