20 Process Compressed Files

Script doapp.csh allows you to apply an application to a series of compressed files. It is useful if disk space is scarce. The files are assumed to have been compressed with the Unix utility compress. Each file is, in turn, decompressed, processed and recompressed. In the script provided application histpeak in ESP is used to determine the median value of the image and this value is output to a text file. This effect is achieved by writing histpeak’s output to a temporary file and then using the Unix utilities grep and awk to extract the details required.

It is relatively straightforward to change doapp.csh to perform some other processing. For example, script dostats.csh is a modified version which uses KAPPA application stats to find the mean of each image. Using the Unix command diff on scripts doapp.csh and dostats.csh will show the lines that need to be changed to produce a modified script which performs some other processing.

The input for either script consists of the names of one or more files to be processed (wild-cards are permitted) and the name of the output text file.

Example

(1)
Before giving an example of using the script it is necessary to create some compressed files for it to work on. Type:
  % compress *.sdf

The compressed files retain their original name but have the additional file type ‘.Z’.

(2)
To examine a single file type:
  % doapp.csh ngc2336_r_2.sdf.Z result.txt

File ngc2336_r_2.sdf.Z will be decompressed, examined, and recompressed. The result will be written to file result.txt.

(3)
Alternatively, all the compressed files can be processed. Type:
  % doapp.csh ’*.Z’ results.txt

Here the results are written to file results.txt.

(4)
The use of dostats.csh is similar. Type:
  % dostats.csh ’*.Z’ stats.txt

and the results will be written to file stats.txt.

(5)
For the purpose of this example you will probably want to decompress the files once you have finished. Type:
  % uncompress *.Z

Obviously you would omit this stage if you were using the scripts ‘for real’ and disk space was scarce.