1MS_WRITEMSEED(3) Library Functions Manual MS_WRITEMSEED(3)
2
3
4
6 ms_writemseed - Write Mini-SEED records to files.
7
8
10 #include <libmseed.h>
11
12 int msr_writemseed ( MSRecord *msr, char *msfile, flag overwrite,
13 int reclen, flag encoding, flag byteorder,
14 flag verbose );
15
16 int mst_writemseed ( MSTrace *mst, char *msfile, flag overwrite,
17 int reclen, flag encoding, flag byteorder,
18 flag verbose );
19
20 int mst_writemseedgroup ( MSTraceGroup *msr, char *msfile,
21 flag overwrite, int reclen, flag encoding,
22 flag byteorder, flag verbose );
23
24
26 These routines will packed the data contained in the MSRecord, MSTrace
27 or MSTraceGroup into Mini-SEED records and write them to the specified
28 file. The overwrite flag controls whether the output file is overwrit‐
29 ten or appended to.
30
31 Mini-SEED records are created using the specified record length
32 (reclen), Mini-SEED encoding and byteorder. Default values will be
33 used for any of the key characteristics of record length, encoding for‐
34 mat and byte order that are specified as -1. The default values are:
35 reclen = 4096 bytes, encoding = 11 (Steim2) and byteorder = 1 (MSBF or
36 big-endian).
37
38 reclen should be set to the desired data record length in bytes which
39 must be expressible as 2 raised to the power of X where X is between
40 (and including) 8 to 20.
41
42 encoding should be set to one of the following supported Mini-SEED data
43 encoding formats: DE_ASCII (0), DE_INT16 (1), DE_INT32 (3), DE_FLOAT32
44 (4), DE_FLOAT64 (5), DE_STEIM1 (10) and DE_STEIM2 (11). The encoding
45 aliases are defined in libmseed.h. MSTrace.sampletype should indicated
46 the sample type as either 'a' (ASCII), 'i' (32-bit integers), 'f'
47 (32-bit floats) or 'd' (64-bit doubles).
48
49 The encoding format must be appropriate for the sample type of the
50 MSTrace samples. For example, Steim compression and integer encoding
51 formats require integer samples and float encoding formats require the
52 appropriate size floats as input. As a counter example, float samples
53 cannot be packed using Steim compression or integer encoding formats.
54
55 byteorder must be either 0 (LSBF or little-endian) or 1 (MBF or big-
56 endian).
57
58 The verbose flag controls verbosity, a value of zero will result in no
59 diagnostic output.
60
61
63 All of these routines return the number of records written on success
64 and -1 on error.
65
66
68 Skeleton code for writing Mini-SEED records with msr_writemseed(3):
69
70 main() {
71 MSRecord *msr;
72 int precords;
73
74 msr = msr_init (NULL);
75
76 /* Populate MSRecord values */
77 strcpy (msr->network, "XX");
78 strcpy (msr->station, "TEST");
79 strcpy (msr->channel, "BHE");
80 msr->starttime = ms_seedtimestr2hptime ("2004,350,00:00:00.00");
81 msr->samprate = 40.0;
82 msr->datasamples = dataptr; /* pointer to 32-bit integer data samples */
83 msr->numsamples = 1234;
84 msr->sampletype = 'i'; /* declare type to be 32-bit integers */
85
86 /* Write record(s) with 4096-byte length, Steim-2 compression, big-endian */
87 precords = msr_writemseed (msr, "output.mseed", 1, 4096, DE_STEIM2, 1, 0);
88
89 ms_log (0, "Wrote %d records0, precords);
90
91 msr_free (&msr);
92 }
93
94
96 ms_intro(3), msr_pack(3) and mst_pack(3).
97
98
100 Chad Trabant
101 IRIS Data Management Center
102
103
104
105Libmseed API 2011/01/06 MS_WRITEMSEED(3)