File Formats

Raw output files can be written out in one of three Grams/SPC formats: 16-bit fixed point, 32-bit fixed point, or 32-bit floating point. Edgar can read files stored in any of these formats, but some versions of Grams have trouble reading 16-bit files if the igram size is greater than 16384 points, so data collected at 1 cm-1 may not import correcty into Grams. Also, Acquire can only read in 32-bit floating point files.

Raw data files generated by Edgar are Grams/SPC multifiles with the new style header. The first 512 bytes of all files are the main header block. The next 32 bytes are the first subheader block.(1) After the subheader is the raw igram data, which varies in size based on the spectral resolution and sampling mode. After the raw igram data is another subheader block, then the next igram, etc. until the end of file.

There is an important difference to note regarding 16-bit fixed point vs. 32-bit floating point in regard to the way the Grams/SPC spec works. Since the instrument itself generates 16-bit data samples, igrams stored in the 16-bit fixed point format contain the actual data samples as derived by the ADC. Also in the case of 16-bit data, the subheader exponent field is directly related to the preamp gain setting. So it is trivial to recover the raw ADC values and preamp gain used for the data collection. But in the case of 32-bit floating point data, the subheader exponent field contains a "magic number" specified by the Grams/SPC spec to indicate 32-bit IEEE-standard single precision floating point. So with 32-bit floating point data the preamp gain is folded in prior to writing to disk. The raw 16-bit sample values are scaled by the appropriate constant (based on the preamp gain setting) to generate a 32-bit float. It is the scaled floats in this case that are actually written to disk. Since the XL annotation file generated by Edgar contains the preamp gain setting for each scan, it is possible to work backwards and arrive at the raw sample values if needed, but it is not a trivial operation as it is with the 16-bit fixed point data.

The default raw data output format is 16-bit fixed point. In this output mode, the subheader exponent field is set such that data for a preamp gain of 128 is stored with a multiplier of 1 (exponent field is 16), data colleted at a gain of 64 is stored with a multiplier of 2 (exponent is 17), etc. This makes it possible to determine the detector preamp gain setting directly from the subheader exponent field using the following table.

Subheader Exponent Preamp Gain
23 1
22 2
21 4
20 8
19 16
18 32
17 64
16 128

On the Acquisition tab of the Preferences editor is a setting(2) to turn on or off the application of gain scaling to raw 16-bit data files. If this option is checked, the subheader exponent field will be applied to the raw data before viewing. If this option is not checked, then raw 16-bit data values will be viewed. Note that the gain scaling option only applies to raw 16-bit data files. Any exponent scaling indicated for the other Grams/SPC file formats is always applied.

All files processed with Edgar are written out in 32-bit IEEE float (single precision) format, and so far no problems have been discovered with importing these files into any versions of Acquire or Grams.

(1) The last 4 bytes in the subfile header are marked "Reserved" in the official Grams/SPC specification, but these bytes are used by Edgar to store the actual 32-bit scan number (as generated by the Annotator). So, for data files collected with Edgar these 4 bytes will contain the hardware generated scan number, and for any other files these 4 bytes will be all zeros.

(2) This setting is called "Apply gain correction to raw data"