⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libmseed-usersguide

📁 C编写的格式转换程序
💻
📖 第 1 页 / 共 2 页
字号:
Explanation of fields:dataquality:  A SEED data quality indicator, either 'D', 'R', 'Q' or 'M'.   This value  will be (binary) 0 when the quality is unknown or mixed.network:station:location:channel:  MSTrace identifiers as NULL terminated strings.type:  A single character trace type indicator.  This field is not used by  libmseed but could be used for application specific trace  identification.starttime:  MSTrace start time, the time of the first sample, as a high precision  epoch time (see ms_time(3)).  This time can be converted using the  various ms_hptime2<X> functions.endtime:  MSTrace end time, the time of the last sample, as a high precision  epoch time (see 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.samplecnt:  The sample count, i.e. number of data samples in the trace.datasamples:  A pointer to the data samples.  If no data samples are included 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.prvtptr:  A private pointer for general use.  This pointer is not used by  libmseed and can safely be used by the calling program.ststate:  Pointer to a StreamState struct used internally to track stream  oriented state variables.  Memory for this only allocated when needed.next:  A pointer to the next MSTrace structure.  The value will be 0 for the  last link in a chain of MSTrace structures. -- Log Messages --All of the log and diagnostic messages emitted by the library functionsuse the same interface.  The output from this interface can be controlled.This is useful when the library will be embedded in a larger system witha custom logging facility.  See the man page for more details.  ms_log() : the central logging facility.  Behavior is controlled by the        settings specified with ms_loginit().  ms_loginit() : set the functions and prefixes used for log,        diagnostic and error messages.The default destination for log messages is standard output (stdout),while all diagnostic (including error) messages go to standard error(stderr).  Most of the internal messages emmited by the library areconsidered diagnostic and will, by default, go to standard error.The default prefix for log and diagnostic messages is nothing. Thedefault prefix for diagnostic error messages is "error: ".There are reentrant versions of these functions that operate directlyon a logging parameter MSLogParam struct.  These are intended for usein threaded programs or where a complex logging scheme is desired.See the man pages for more details. -- Waveform Data --Waveform data samples are managed by libmseed in a couple of differentformats depending on how they are unpacked or will be packed.  Anarray of samples is completely represented by an array of samplevalues, the number of samples and a sample type.  The number ofsamples is always the actual number of sample values, not the numberof bytes needed for storing the values.  Samples can be either ASCII,32-bit integer, 32-bit floats or 64-bit double precision floats.Sample types are identified by a type character:'a' - ASCII (8 bits)'i' - integer (32 bits)'f' - float (32 bits)'d' - double (64 bits)The size of each sample type in bytes is returned by theget_samplesize(3) lookup routine. -- Common Usage --Example programs using libmseed are provided in the 'examples'directory of the source code distribution.One of the most common tasks is to read a file of Mini-SEED recordsand either perform some action based on the header values or applysome process to the data samples.  This task is greatly simplified byusing the library functions ms_readmsr(3) and ms_readtraces(3).  Thems_readmsr(3) routine will open a specified file and return MSRecordstructures for each Mini-SEED record it reads from the file.  Thems_readtraces(3) routine will do the same except add all the data readto a MSTraceGroup, this is ideal for quickly reading data forprocessing.  Both of these routines are able to automatically detectrecord length.Skeleton code for reading a file with ms_readmsr(3):main() {  MSRecord *msr = NULL;  int retcode;  while ( (retcode = msr_readmsr (&msr, filename, 0, NULL, NULL, 1, 0, verbose)) == MS_NOERROR )    {       /* Do something with the record here, e.g. print */       msr_print (msr, verbose);    }  if ( retcode != MS_ENDOFFILE )    ms_log (2, "Cannot read %s: %s\n", filename, ms_errorstr(retcode));  /* Cleanup memory and close file */  ms_readmsr (&msr, NULL, 0, NULL, NULL, 0, 0);}For reading two files with ms_readtraces(3):main() {  MSTraceGroup *mstg = NULL;  int retcode;  retcode = ms_readtraces (&mstg, filename, 0, -1.0, -1.0, 0, 1, 0, verbose);  if ( retcode != MS_ENDOFFILE )    ms_log (2, "Cannot read %s: %s\n", filename, ms_errorstr(retcode));  retcode = ms_readtraces (&mstg, filename2, 0, -1.0, -1.0, 0, 1, 0, verbose);  if ( retcode != MS_ENDOFFILE )    ms_log (2, "Cannot read %s: %s\n", filename2, ms_errorstr(retcode));  if ( ! mstg )    {      fprintf (stderr, "Error reading file\\n");      return -1;    }  /* Do something with the traces here, e.g. print */  mst_printtracelist (mstg, 0, verbose, 0);  mst_freegroup (&mstg);}Another common task is to create (pack) Mini-SEED records. The librarysupports packing of Mini-SEED either from MSRecord structures, MSTracestructures or MSTraceGroup collections using, respectively, msr_pack(3),mst_pack(3) or mst_packgroup(3).  In each case the appropriate datastructure and parameters are provided to the routine along with afunction pointer to a routine that will be called each time a recordis complete and should be disposed of.When packing Mini-SEED records the concept of a record header templateis used, the template is always in the form of a MSRecord structure.This allows the calling program to dictate the contents, with a fewexceptions, of the header in the final data records.Skeleton code for creating (packing) Mini-SEED records withmst_pack(3):static void record_handler (char *record, int reclen, void *srcname) {  if ( fwrite(record, reclen, 1, outfile) != 1 )    {      ms_log (2, "Error writing %s to output file\n", (char *)srcname);    }}main() {  int psamples;  int precords;  MSTrace *mst;  char srcname[50];  mst = mst_init (NULL);  /* Populate MSTrace values */  strcpy (mst->network, "XX");  strcpy (mst->station, "TEST");  strcpy (mst->channel, "BHE");  mst->starttime = ms_seedtimestr2hptime ("2004,350,00:00:00.000000");  mst->samprate = 40.0;  /* The datasamples pointer and numsamples counter will be adjusted by     the packing routine, the datasamples array must be dynamic memory     allocated by the malloc() family of routines. */  mst->datasamples = dataptr; /* pointer to 32-bit integer data samples */    mst->numsamples = 1234;  mst->sampletype = 'i';      /* declare type to be 32-bit integers */  mst_srcname (mst, srcname, 0);  /* Pack 4096 byte, big-endian records, using Steim-2 compression */  precords = mst_pack (mst, &record_handler, srcname, 4096, DE_STEIM2,                                     1, &psamples, 1, verbose, NULL);  ms_log (0, "Packed %d samples into %d records\n", psamples, precords);  mst_free (&mst);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -