Guralp Compressed Format (GCF)
All data blocks used by the GSL digital devices are in GCF format. This is a format for the efficient transmission of digitally sampled data streams where multiple sources may share a common transmission medium.
Each GCF block consists of two parts: a header and a body. For data blocks, this body contains first differences of the sample values, and for status blocks, the body contains text status information.
The header is 16 bytes long, split into four 4 byte fields which are:
reserved - Reserved for future use. On some systems, refers to a decimation lookup table to identify the decimation filters that have been used to derive the data at a given sample rate.
Sample Rate - Sample rate of data in the block. This should be constant for a stream. A status block is defined as having a sample rate zero.
Compression Code - The bottom 3 bits Identify the compression format for the block. The top 5 bits are reserved. Three values are defined
1:data is stored as 32 bit differences* (one sample per record)
2:data is stored as 16 bit differences (two samples per record)
4:data is stored as 8 bit differences (four samples per record)
Number of Records - Number of four byte ‘fields’ of data following*. This value can be used in association with the compression code to determine the number of sample in the block. Combine this with the sample rate and the duration of the block can be determined. i.e.
Number of samples = Compression Code x Number of Records
Block Duration = Number of Samples / Sample Rate
The block duration is ALWAYS an integral number of seconds, and ALWAYS starts on a whole second boundary. For status blocks, the number of characters is Number of Records x 4.
The rest of the block contains the data fields.
* Note: Serial data transmission may reduce 32 bit differences to 3-bytes (24 bit). All data on disk, file or network will be full 32 bit differences. 24 bit values have a 16 million range (±8 million). The difference values must be able to indicate ±16 million, which is 25 bits. Since the compression may discard the 25th bit, the sign of a 24 bit difference must be determined during decompression. A simple method is to check whether the addition of the 24 bit difference would place the sample value outside the range of a 24 bit number. If this occurs, then the sign of the difference should be inverted.
Decoding Base 36 numbers, Decoding Dates and Times, Block Transfer Protocol