📄 libmseed-usersguide
字号:
An introduction to libmseed -- Introduction --The Mini-SEED library provides a framework for manipulation of SEEDdata records including the unpacking and packing of data records.Functionality is also included for managing waveform data ascontinuous traces. All structures of SEED 2.4 data records aresupported with the following exceptions: Blockette 2000 opaque datawhich has an unknown data structure by definition and Blockette 405which depends on full SEED (SEED including full ASCII headers) for afull data description.The primary purpose of the library is to hide the details of Mini-SEEDin order to allow rapid development of Mini-SEED reading/writingsoftware. The framework allows everything from manipulation ofMini-SEED on a record-by-record basis to reading of Mini-SEED intocontinuous trace segments to packing of large continuous traces usinga record template.Certain common tasks have, through library design, been streamlined,for example: reading Mini-SEED records from a file, adding data fromunpacked records to a group of traces or packing a group of continuoustraces into Mini-SEED records.The following data encoding formats are supported for both unpackingand packing: ASCII, INT16, INT32, FLOAT32, FLOAT64, STEIM1 and STEIM2.The INT and FLOAT encodings each have two versions for quantities witha different number of bits of representation. The STEIM decompressionproduces 32-bit integers; likewise the compression routines require32-bit integers as input. The following data encoding formats aresupported for unpacking only: GEOSCOPE (24-bit, 16/3 and 16/4 gainranged), SRO and DWWSSN. -- Data Records --A Mini-SEED record is represented in the library using the datastructure given below. This structure is used for both unpacking andpacking of Mini-SEED records. When unpacking with msr_unpack(3) thisstructure is populated. When packing with msr_pack(3) this structureis used as a template for the resulting data records and as a sourceof samples to be packed.Blockettes following the fixed section of the header are contained inthe blockette chain of BlktLink structures. Shortcut pointers tocommonly used blockettes are maintained for types 100, 1000 and 1001.Many common header fields which are not easily accessible/usable inthe raw header are available directly from the structure. When thisstructure is used as a packing template, these common header fieldsare packed into the appropriate place in the fixed section orblockette. As examples, the ASCII stream identifiers (network,station, location and channel) are available as NULL terminatedstrings, the start time is available as a high precision epoch time(see ms_time(3)) and the sample rate is available as a doubleprecision floating point value.The MSRecord data structure:typedef struct MSRecord_s { char *record; /* Mini-SEED record */ int32_t reclen; /* Length of Mini-SEED record in bytes */ /* Pointers to SEED data record structures */ struct fsdh_s *fsdh; /* Fixed Section of Data Header */ struct BlktLink *blkts; /* Root of blockette chain */ struct blkt_100_s *Blkt100; /* Blockette 100, if present */ struct blkt_1000_s *Blkt1000; /* Blockette 1000, if present */ struct blkt_1001_s *Blkt1001; /* Blockette 1001, if present */ /* Common header fields in accessible form */ int32_t sequence_number; /* SEED record sequence number */ char dataquality; /* Data quality indicator */ char network[11]; /* Network designation, NULL terminated */ char station[11]; /* Station designation, NULL terminated */ char location[11]; /* Location designation, NULL terminated */ char channel[11]; /* Channel designation, NULL terminated */ hptime_t starttime; /* Record start time, corrected (first sample) */ double samprate; /* Nominal sample rate (Hz) */ int32_t samplecnt; /* Number of samples in record */ int8_t encoding; /* Data encoding format */ int8_t byteorder; /* Byte order of record */ /* Data sample fields */ void *datasamples; /* Data samples, 'numsamples' of type 'sampletype'*/ int32_t numsamples; /* Number of data samples in datasamples */ char sampletype; /* Sample type code: a, i, f, d */ /* Stream oriented state information */ StreamState *ststate; /* Stream processing state information */}MSRecord;Explanation of fields:record: Pointer to the Mini-SEED record which was unpacked into the MSRecord.reclen: When unpacking this is the record length in bytes of the record pointed to by the 'record' pointer. When packing this is the length of records to pack.fsdh: A pointer to the Fixed Section of the Data Header, all appropriate multi-byte quantities are in host byte order.blkts: The root of the blockette chain. The chain is constructed from linked BlktLink structures. All appropriate multi-byte quantities in the blockettes are in host byte order. The msr_addblockette(3) routine can be used to add blockettes to this chain. The BlktLink structure and SEED blockette structures are defined in libmseed.h.Blkt100:Blkt1000:Blkt1001: Shortcut pointers to common blockettes in the blockette chain. If a given blockette does not exist in the blockette chain the shortcut pointer will be 0. If more than one of these blockette types exist in the chain this pointer will point to the last one.sequence_number: SEED record sequence number, should be between 0 and 999999.dataquality: Data record indicator, should be 'D', 'R', 'Q' or 'M'.network:station:location:channel: SEED stream identifiers as NULL terminated strings.starttime: Record start time, the time of the first sample, as a high precision epoch time (seed ms_time(3)). This time can be converted using the various ms_hptime2<X> functions.samprate: The sample rate in samples per second in double precision. During unpacking this value will be set to the sample rate given in the 100 blockette if it is present, otherwise the sample rate derived from the factor and multiplier in the fixed section of the header. In a packing template this value will be used to derive a factor and multiplier for the fixed section of the header and will be written into 100 blockettes if any are in the blockette chain.samplecnt: The sample count, i.e. number of data samples in the record.encoding: The SEED data sample encoding format. During packing this dictates what format will be used to pack the data samples. Supported packing formats are 0 (DE_ASCII), 1 (DE_INT16), 3 (DE_INT32), 4 (DE_FLOAT32), 5 (DE_FLOAT64), 10 (DE_STEIM1) and 11 (DE_STEIM2).byteorder: Byte order of multi-byte quantities in the record. A value of 0 indicates little endian and a value of 1 indicates big endian. During packing this dictates the byte order of the final records.datasamples: A pointer to the unpacked data samples. If no data samples were unpacked this will be 0. The 'numsamples' field indicates how many samples are in this array and the 'sampletype' field indicates what type of samples they are.numsamples: The number of samples pointed to by the 'datasamples' pointer.sampletype: The type of samples pointed to by the 'datasamples' pointer. Supported types are 'a' (ASCII), 'i' (integer), 'f' (float) and 'd' (double). The size of each sample type in bytes is returned by the get_samplesize(3) lookup routine.ststate: Pointer to a StreamState struct used internally to track stream oriented state variables. Memory for this only allocated when needed. -- Traces --In order to manage continuous trace segments the library defines aMSTrace data structure and a MSTraceGroup data structure in whichMSTrace structures can be grouped. While a MSTrace structure isnormally used to hold trace information and associated data samples itcan also be used without data samples as a means to keep trace of datacoverage without actual samples.Numerous routines are provided for basic management of MSTracestructures, including the creation of new MSTrace structures, addingdata from Mini-SEED data structures to MSTrace structures, printingtrace information, etc.The MSTraceGroup data structure acts as a very simple place to begin achain of MSTrace structures and keep track of the number of traces.The MSTrace and MSTraceGroup data structures:typedef struct MSTrace_s { char network[11]; /* Network designation, NULL terminated */ char station[11]; /* Station designation, NULL terminated */ char location[11]; /* Location designation, NULL terminated */ char channel[11]; /* Channel designation, NULL terminated */ char dataquality; /* Data quality indicator */ char type; /* MSTrace type code */ hptime_t starttime; /* Time of first sample */ hptime_t endtime; /* Time of last sample */ double samprate; /* Nominal sample rate (Hz) */ int32_t samplecnt; /* Number of samples in trace coverage */ void *datasamples; /* Data samples, 'numsamples' of type 'sampletype'*/ int32_t numsamples; /* Number of data samples in datasamples */ char sampletype; /* Sample type code: a, i, f, d */ void *prvtptr; /* Private pointer for general use */ StreamState *ststate; /* Stream processing state information */ struct MSTrace_s *next; /* Pointer to next trace */}MSTrace;typedef struct MSTraceGroup_s { int32_t numtraces; /* Number of MSTraces in the trace chain */ struct MSTrace_s *traces; /* Root of the trace chain */}MSTraceGroup;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -