Gamma DISP: Reference Manual


swap_bytes

ANSI-C program: swap_bytes.c

NAME
swap_bytes - Byte order swapping between big_endian and little_endian  number formats on different computer platforms.  Computers based on the  SUN SPARC, HP PA-RISC, and IBM PowerPC  and use the big-endian byte order for internal data representation. Linux and Windows PCs (x86 and x86-64 architecture) use the little-endian byte order.  All Gamma data files follow the big-endian byte order. Note that  this is not the native byte order for the x86 processor.  Reading this data into other programs that are not in the Gamma software requires either that the byte-order is swapped using swap_bytes or that the the program has the capability to read big-endian format.  MATLAB and python have the capability to read either big or little endian data irrespective of the platform.

SYNOPSIS
swap_bytes <infile> <outfile> <type>

infile input data file
outfile output data file
type data type flag:
  2: (1,2) --> (2,1.) (short integer, scomplex)
  4: (1,2,3,4.) --> (4,3,2,1) (integer, float, fcomplex)
  8: (1,2,3,4,5,6,7,8) --> (8,7,6,5,4,3,2,1) (double)

EXAMPLE

swap_bytes 19990421.mli 19990421_le.mli 4

Swaps byte order for a 4-byte floating point file.

swap_bytes 19990421.slc 19990421_le.slc 2

Swaps the  byte order for scomplex  ( pairs of short integer) data.

DESCRIPTION
swap_bytes reads the input data file, swaps the byte order, and writes out the swapped byte order data to the output data file. swap_bytes supports swapping of different binary data types:

Data type swap_type
2-byte short integer 2
4-byte integer 4
4-float 4
8-byte double 8
scomplex (pairs of 2-byte short integer) 2
fcomplex (pairs of 4-byte float) 4

The data files produced by the Gamma software are homogeneous, so that conversion from one endian convention to the other is readily accomplished.

© Copyrights for Documentation, and Reference Manual by Gamma Remote Sensing, 2012.
UW, CW, last change 7-Jun-2012