next up previous
Next: Handling Errors in Conversion Commands
Up: ADDITIONAL FACILITIES
Previous: Efficiency Considerations

Example: Data Compression   

To illustrate the above, the following is a complete example of the C shell commands that might be used to allow access to compressed NDF data files (with file extension `.sdf.Z') on UNIX systems:

#  Define the COMPRESSED format to be recognised on input, with file
#  extension `.sdf.Z'.
      if ($?NDF_FORMATS_IN) then
         setenv NDF_FORMATS_IN $NDF_FORMATS_IN',COMPRESSED(.sdf.Z)'
      else
         setenv NDF_FORMATS_IN 'COMPRESSED(.sdf.Z)'
      endif

#  Similarly, recognise it on output.
      if ($?NDF_FORMATS_OUT) then
         setenv NDF_FORMATS_OUT $NDF_FORMATS_OUT',COMPRESSED(.sdf.Z)'
      else
         setenv NDF_FORMATS_OUT '.,COMPRESSED(.sdf.Z)'
      endif

#  Store the uncompressed data in the default directory.
      setenv NDF_KEEP_COMPRESSED ^name
      setenv NDF_TEMP_COMPRESSED tmp_^name

#  Use the "uncompress" and "compress" utilities to convert the data.
      setenv NDF_FROM_COMPRESSED 'uncompress -c -f ^dir^name^type >^ndf.sdf'
      setenv NDF_TO_COMPRESSED 'compress -c -f ^ndf.sdf >^dir^name^type;:'

#  Suppress processing of extension information for compressed data.
      setenv NDF_XTN_COMPRESSED ''

Note that the ``compress'' command has been followed by a null ``:'' command which does nothing. This is because an error status may be returned if the file being compressed does not get any smaller, so the ``:'' command ensures that the invoking NDF application always receives a success status. In a production system, more secure error handling than this would probably be required.

For an explanation of the final definition of the NDF_XTN_COMPRESSED environment variable, you should refer ahead to §[*].

(Warning: Users should be warned that it is unwise to archive compressed data unless thay are sure that the necessary decompression software will be available to them in future, possibly on different hardware and/or operating system platforms.)



next up previous
Next: Handling Errors in Conversion Commands
Up: ADDITIONAL FACILITIES
Previous: Efficiency Considerations


Starlink System Note 20
R.F.Warren-Smith & D.S.Berry
17th July 2000
E-mail:ussc@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils