Format for 2d Spectra

The two dimensional data is a matrix of dimension NX x NY which has been compressed to save disk space. The copmression method leaves out the zeros of the matrix and retains only the non-zero data.

Each data row is encoded as

NZ1, ND1, [ND1 data-words]; NZ2, ND2, [ND2 data-words]; ...
This sequence is repeated for each of the NY rows
Here NZ and ND values are written as 16-bit values while the data-words are written as either 16-bit or 32-bit values depending upon the option Single Word or Double Word selected in Setup.

To make things clear, here is how a (hypothetical) 8x8 matix would be encoded.
Punctuation marks (comma, semi-colon and brackets) are shown for readabilty - they are not in the data stream.
NZ values are shown in red, ND values in blue and data-words in green:

Raw Matrix
320001100
01217100110
1300007018
00000000
430000013
000013000
22000000
5211451125


Compressed Rows
Row 1 0,2 (3,2) 3,1 (11) 2,0
Row 2 1,3 (12,17,1) 2,1 (11) 1,0
Row 3 0,1 (13) 4,1 (7) 1,1 (18)
Row 4 8,0
Row 5 0,2 (4,3) 5,1 (13)
Row 6 4,1 (13) 3,0
Row 7 0,2 (2,2) 6,0
Row 8 0,8 (5,2,1,14,5,11,2,5)
Storage Space
Single Word:    128 bytes
Double Word:   256 bytes


Storage Space
Singe Word:     82 bytes
Double Word:  130 bytes
This is only a toy example (the minimum matrix size in LAMPS is 16 x 16), nevertheless we see a compression factor of 1.56 (Single Word case) or 1.96 (Double Word case).

Example programs (in FORTRAN and C) showing how to read and write 2d files are included in DemoProgs.tgz which can be downloaded from the LAMPS website.