diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/annotated.html b/annotated.html new file mode 100644 index 0000000..9cca81a --- /dev/null +++ b/annotated.html @@ -0,0 +1,110 @@ + + +
+ + + + +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
CLeapSecond | Leap second list container |
CLIBMSEED_MEMORY | |
CLMIO | Type definition for data source I/O: file-system versus URL |
CMS3FileParam | State container for reading miniSEED records from files or URLs |
CMS3Record | MiniSEED record container |
CMS3RecordList | Record list, holds MS3RecordPtr entries that contribute to a given MS3TraceSeg |
CMS3RecordPtr | A miniSEED record pointer and metadata |
CMS3Selections | Data selection structure definition containers |
CMS3SelectTime | Data selection structure time window definition containers |
CMS3Tolerance | Callback functions that return time and sample rate tolerances |
CMS3TraceID | Container for a trace ID, linkable |
CMS3TraceList | Container for a collection of continuous trace segment, linkable |
CMS3TraceSeg | Container for a continuous trace segment, linkable |
CMSEHCalibration | Container for calibration parameters for use in extra headers |
CMSEHEventDetection | Container for event detection parameters for use in extra headers |
CMSEHRecenter | Container for recenter parameters for use in extra headers |
CMSEHTimingException | Container for timing exception parameters for use in extra headers |
CMSLogEntry | Log registry entry |
CMSLogParam | Logging parameters. Callers should not modify these values directly and generally should not need to access them. |
CMSLogRegistry | Log message registry |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
libmseed.h |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Flags indicating whether the header or payload needed byte swapping. +More...
++Macros | |
+#define | MSSWAP_HEADER 0x01 |
Header needed byte swapping. | |
+#define | MSSWAP_PAYLOAD 0x02 |
Data payload needed byte swapping. | |
Flags indicating whether the header or payload needed byte swapping.
+These are bit flags normally used to set/test the MS3Record.swapflag value.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Parsing, packing and trace construction control flags. +More...
++Macros | |
+#define | MSF_UNPACKDATA 0x0001 |
[Parsing] Unpack data samples | |
+#define | MSF_SKIPNOTDATA 0x0002 |
[Parsing] Skip input that cannot be identified as miniSEED | |
+#define | MSF_VALIDATECRC 0x0004 |
[Parsing] Validate CRC (if version 3) | |
+#define | MSF_PNAMERANGE 0x0008 |
[Parsing] Parse and utilize byte range from path name suffix | |
+#define | MSF_ATENDOFFILE 0x0010 |
[Parsing] Reading routine is at the end of the file | |
+#define | MSF_SEQUENCE 0x0020 |
[Packing] UNSUPPORTED: Maintain a record-level sequence number | |
+#define | MSF_FLUSHDATA 0x0040 |
[Packing] Pack all available data even if final record would not be filled | |
+#define | MSF_PACKVER2 0x0080 |
[Packing] Pack as miniSEED version 2 instead of 3 | |
+#define | MSF_RECORDLIST 0x0100 |
[TraceList] Build a MS3RecordList for each MS3TraceSeg | |
+#define | MSF_MAINTAINMSTL 0x0200 |
[TraceList] Do not modify a trace list when packing | |
Parsing, packing and trace construction control flags.
+These are bit flags that can be combined into a bitmask to control aspects of the library's parsing, packing and trace managment routines.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Data selections to be used as filters. +More...
++Data Structures | |
struct | MS3SelectTime |
Data selection structure time window definition containers. More... | |
struct | MS3Selections |
Data selection structure definition containers. More... | |
+Functions | |
const MS3Selections * | ms3_matchselect (const MS3Selections *selections, const char *sid, nstime_t starttime, nstime_t endtime, int pubversion, const MS3SelectTime **ppselecttime) |
Test the specified parameters for a matching selection entry. | |
const MS3Selections * | msr3_matchselect (const MS3Selections *selections, const MS3Record *msr, const MS3SelectTime **ppselecttime) |
Test the MS3Record for a matching selection entry. | |
int | ms3_addselect (MS3Selections **ppselections, const char *sidpattern, nstime_t starttime, nstime_t endtime, uint8_t pubversion) |
Add selection parameters to selection list. | |
int | ms3_addselect_comp (MS3Selections **ppselections, char *network, char *station, char *location, char *channel, nstime_t starttime, nstime_t endtime, uint8_t pubversion) |
Add selection parameters to a selection list based on separate source name codes. | |
int | ms3_readselectionsfile (MS3Selections **ppselections, const char *filename) |
Read data selections from a file. | |
void | ms3_freeselections (MS3Selections *selections) |
Free all memory associated with a MS3Selections. | |
void | ms3_printselections (const MS3Selections *selections) |
Print the selections list using the ms_log() facility. | |
Data selections to be used as filters.
+Selections are the identification of data, by source identifier and time ranges, that are desired. Capability is included to read selections from files and to match data against a selection list.
+For data to be selected it must only match one of the selection entries. In other words, multiple selection entries are treated with OR logic.
+The ms3_readmsr_selection() and ms3_readtracelist_selection() routines accept MS3Selections and allow selective (and efficient) reading of data from files.
+struct MS3SelectTime | +
Data selection structure time window definition containers.
+Data Fields | ||
---|---|---|
+nstime_t | ++starttime | ++Earliest data for matching channels, use NSTUNSET for open. |
+nstime_t | ++endtime | ++Latest data for matching channels, use NSTUNSET for open. |
+struct MS3SelectTime * | ++next | ++Pointer to next selection time, NULL if the last. |
struct MS3Selections | +
Data selection structure definition containers.
+Data Fields | ||
---|---|---|
+char | ++sidpattern[100] | ++Matching (globbing) pattern for source ID. |
+struct MS3SelectTime * | ++timewindows | ++Pointer to time window list for this source ID. |
+struct MS3Selections * | ++next | ++Pointer to next selection, NULL if the last. |
+uint8_t | ++pubversion | ++Selected publication version, use 0 for any. |
+
|
+ +extern | +
Test the specified parameters for a matching selection entry.
+Search the MS3Selections for an entry matching the provided parameters. The MS3Selections.sidpattern may contain globbing characters. The MS3Selections.timewindows many contain start and end times set to NSTUNSET to denote "open" times.
+Positive matching requires:
[in] | selections | MS3Selections to search |
[in] | sid | Source ID to match |
[in] | starttime | Start time to match |
[in] | endtime | End time to match |
[in] | pubversion | Publication version to match |
[out] | ppselecttime | Pointer-to-pointer to return the matching MS3SelectTime entry |
+
|
+ +extern | +
Test the MS3Record for a matching selection entry.
+Search the MS3Selections for an entry matching the provided parameters.
+Positive matching requires:
[in] | selections | MS3Selections to search |
[in] | msr | MS3Record to match against selections |
[out] | ppselecttime | Pointer-to-pointer to return the matching MS3SelectTime entry |
+
|
+ +extern | +
Add selection parameters to selection list.
+The sidpattern may contain globbing characters.
+The starttime and endtime may be set to NSTUNSET to denote "open" times.
+The pubversion may be set to 0 to match any publication version.
+[in] | ppselections | MS3Selections to add new selection to |
[in] | sidpattern | Source ID pattern, may contain globbing characters |
[in] | starttime | Start time for selection, NSTUNSET for open |
[in] | endtime | End time for selection, NSTUNSET for open |
[in] | pubversion | Publication version for selection, 0 for any |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Add selection parameters to a selection list based on separate source name codes.
+The network, station, location, and channel arguments may contain globbing parameters.
+The starttime and endtime may be set to NSTUNSET to denote "open" times.
+The pubversion may be set to 0 to match any publication version.
+If any of the naming parameters are not supplied (pointer is NULL) a wildcard for all matches is substituted.
+As a special case, if the location code (loc) is set to "--"
to match an empty location code it will be translated to an empty string to match libmseed's notation.
[in] | ppselections | MS3Selections to add new selection to |
[in] | network | Network code, may contain globbing characters |
[in] | station | Statoin code, may contain globbing characters |
[in] | location | Location code, may contain globbing characters |
[in] | channel | channel code, may contain globbing characters |
[in] | starttime | Start time for selection, NSTUNSET for open |
[in] | endtime | End time for selection, NSTUNSET for open |
[in] | pubversion | Publication version for selection, 0 for any |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Read data selections from a file.
+Selections from a file are added to the specified selections list. On errors this routine will leave allocated memory unreachable (leaked), it is expected that this is a program failing condition.
+As a special case if the filename is "-", selection lines will be read from stdin.
+Each line of the file contains a single selection and may be one of these two line formats:
or
The Starttime
and Endtime
values must be in a form recognized by ms_timestr2nstime() and include a full date (i.e. just a year is not allowed).
In the latter version, if the "Channel" field is a SEED 2.x channel (3-characters) it will automatically be converted into extended channel form (band_source_subsource).
+In the latter version, the "Pubversion" field, which was "Quality" in earlier versions of the library, is assumed to be a publication version if it is an integer, otherwise it is ignored.
+MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Free all memory associated with a MS3Selections.
+All memory from one or more MS3Selections (in a linked list) are freed.
+[in] | selections | Start of MS3Selections to free |
+
|
+ +extern | +
Print the selections list using the ms_log() facility.
+All selections are printed with simple formatting.
+[in] | selections | Start of MS3Selections to print |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Data encoding type defines. +More...
+Data encoding type defines.
+These are FDSN-defined miniSEED data encoding values. The value of MS3Record.encoding is set to one of these. These values may be used anywhere and encoding value is needed.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Structures and funtions to support extra headers. +More...
++Data Structures | |
struct | MSEHEventDetection |
Container for event detection parameters for use in extra headers. More... | |
struct | MSEHCalibration |
Container for calibration parameters for use in extra headers. More... | |
struct | MSEHTimingException |
Container for timing exception parameters for use in extra headers. More... | |
struct | MSEHRecenter |
Container for recenter parameters for use in extra headers. More... | |
+Macros | |
+#define | mseh_get(msr, ptr, valueptr, type, maxlength) mseh_get_ptr_r (msr, ptr, valueptr, type, maxlength, NULL) |
A simple wrapper to access any type of extra header. | |
+#define | mseh_get_number(msr, ptr, valueptr) mseh_get_ptr_r (msr, ptr, valueptr, 'n', 0, NULL) |
A simple wrapper to access a number type extra header. | |
+#define | mseh_get_int64(msr, ptr, valueptr) mseh_get_ptr_r (msr, ptr, valueptr, 'i', 0, NULL) |
A simple wrapper to access a number type extra header. | |
+#define | mseh_get_string(msr, ptr, buffer, maxlength) mseh_get_ptr_r (msr, ptr, buffer, 's', maxlength, NULL) |
A simple wrapper to access a string type extra header. | |
+#define | mseh_get_boolean(msr, ptr, valueptr) mseh_get_ptr_r (msr, ptr, valueptr, 'b', 0, NULL) |
A simple wrapper to access a boolean type extra header. | |
+#define | mseh_exists(msr, ptr) (!mseh_get_ptr_r (msr, ptr, NULL, 0, 0, NULL)) |
A simple wrapper to test existence of an extra header. | |
+#define | mseh_set(msr, ptr, valueptr, type) mseh_set_ptr_r (msr, ptr, valueptr, type, NULL) |
A simple wrapper to set any type of extra header. | |
+#define | mseh_set_number(msr, ptr, valueptr) mseh_set_ptr_r (msr, ptr, valueptr, 'n', NULL) |
A simple wrapper to set a number type extra header. | |
+#define | mseh_set_int64(msr, ptr, valueptr) mseh_set_ptr_r (msr, ptr, valueptr, 'i', NULL) |
A simple wrapper to set a number type extra header. | |
+#define | mseh_set_string(msr, ptr, valueptr) mseh_set_ptr_r (msr, ptr, valueptr, 's', NULL) |
A simple wrapper to set a string type extra header. | |
+#define | mseh_set_boolean(msr, ptr, valueptr) mseh_set_ptr_r (msr, ptr, valueptr, 'b', NULL) |
A simple wrapper to set a boolean type extra header. | |
+Typedefs | |
typedef struct LM_PARSED_JSON_s | LM_PARSED_JSON |
Internal structure for holding parsed JSON extra headers. | |
+Functions | |
int | mseh_get_ptr_r (const MS3Record *msr, const char *ptr, void *value, char type, uint32_t maxlength, LM_PARSED_JSON **parsestate) |
Search for and return an extra header value. | |
int | mseh_set_ptr_r (MS3Record *msr, const char *ptr, void *value, char type, LM_PARSED_JSON **parsestate) |
Set the value of extra header values. | |
int | mseh_add_event_detection_r (MS3Record *msr, const char *ptr, MSEHEventDetection *eventdetection, LM_PARSED_JSON **parsestate) |
Add event detection to the extra headers of the given record. | |
int | mseh_add_calibration_r (MS3Record *msr, const char *ptr, MSEHCalibration *calibration, LM_PARSED_JSON **parsestate) |
Add calibration to the extra headers of the given record. | |
int | mseh_add_timing_exception_r (MS3Record *msr, const char *ptr, MSEHTimingException *exception, LM_PARSED_JSON **parsestate) |
Add timing exception to the extra headers of the given record. | |
int | mseh_add_recenter_r (MS3Record *msr, const char *ptr, MSEHRecenter *recenter, LM_PARSED_JSON **parsestate) |
Add recenter event to the extra headers of the given record. | |
int | mseh_serialize (MS3Record *msr, LM_PARSED_JSON **parsestate) |
Generate extra headers string (serialize) from internal state. | |
void | mseh_free_parsestate (LM_PARSED_JSON **parsestate) |
Free internally parsed (deserialized) JSON data. | |
int | mseh_replace (MS3Record *msr, char *jsonstring) |
Replace extra headers with supplied JSON. | |
int | mseh_print (const MS3Record *msr, int indent) |
Print the extra header structure for the specified MS3Record. | |
Structures and funtions to support extra headers.
+Extra headers are stored as JSON within a data record header using an anonymous, root object as a container for all extra headers. For a full description consult the format specification.
+The library functions supporting extra headers allow specific header identification using JSON Pointer identification. In this notation each path element is an object until the final element which is a key to specified header value.
+For example, a path specified as:
would correspond to the single JSON value in:
struct MSEHEventDetection | +
Container for event detection parameters for use in extra headers.
+Actual values are optional, with special values indicating an unset state.
+Data Fields | ||
---|---|---|
+char | ++type[30] | +
+ Detector type (e.g. "MURDOCK"), zero length = not included + |
+char | ++detector[30] | +
+ Detector name, zero length = not included |
+double | ++signalamplitude | +
+ SignalAmplitude, 0.0 = not included + |
+double | ++signalperiod | +
+ Signal period, 0.0 = not included + |
+double | ++backgroundestimate | +
+ Background estimate, 0.0 = not included + |
+char | ++wave[30] | +
+ Detection wave (e.g. "DILATATION"), zero length = not included + |
+char | ++units[30] | +
+ Units of amplitude and background estimate (e.g. "COUNTS"), zero length = not included + |
+nstime_t | ++onsettime | +
+ Onset time, NSTUNSET = not included + |
+uint8_t | ++medsnr[6] | +
+ Signal to noise ratio for Murdock event detection, all zeros = not included + |
+int | ++medlookback | +
+ Murdock event detection lookback value, -1 = not included + |
+int | ++medpickalgorithm | +
+ Murdock event detection pick algoritm, -1 = not included + |
+struct MSEHEventDetection * | ++next | +
+ Pointer to next, NULL if none + |
struct MSEHCalibration | +
Container for calibration parameters for use in extra headers.
+Actual values are optional, with special values indicating an unset state.
+Data Fields | ||
---|---|---|
+char | ++type[30] | +
+ Calibration type (e.g. "STEP", "SINE", "PSEUDORANDOM"), zero length = not included + |
+nstime_t | ++begintime | +
+ Begin time, NSTUNSET = not included + |
+nstime_t | ++endtime | +
+ End time, NSTUNSET = not included + |
+int | ++steps | +
+ Number of step calibrations, -1 = not included + |
+int | ++firstpulsepositive | +
+ Boolean, step cal. first pulse, -1 = not included + |
+int | ++alternatesign | +
+ Boolean, step cal. alt. sign, -1 = not included + |
+char | ++trigger[30] | +
+ Trigger, e.g. AUTOMATIC or MANUAL, zero length = not included + |
+int | ++continued | +
+ Boolean, continued from prev. record, -1 = not included + |
+double | ++amplitude | +
+ Amp. of calibration signal, 0.0 = not included + |
+char | ++inputunits[30] | +
+ Units of input (e.g. volts, amps), zero length = not included + |
+char | ++amplituderange[30] | +
+ E.g PEAKTOPTEAK, ZEROTOPEAK, RMS, RANDOM, zero length = not included + |
+double | ++duration | +
+ Duration in seconds, 0.0 = not included + |
+double | ++sineperiod | +
+ Period of sine, 0.0 = not included + |
+double | ++stepbetween | +
+ Interval bewteen steps, 0.0 = not included + |
+char | ++inputchannel[30] | +
+ Channel of input, zero length = not included + |
+double | ++refamplitude | +
+ Reference amplitude, 0.0 = not included + |
+char | ++coupling[30] | +
+ Coupling, e.g. Resistive, Capacitive, zero length = not included + |
+char | ++rolloff[30] | +
+ Rolloff of filters, zero length = not included + |
+char | ++noise[30] | +
+ Noise for PR cals, e.g. White or Red, zero length = not included + |
+struct MSEHCalibration * | ++next | +
+ Pointer to next, NULL if none + |
struct MSEHTimingException | +
Container for timing exception parameters for use in extra headers.
+Actual values are optional, with special values indicating an unset state.
+Data Fields | ||
---|---|---|
+nstime_t | ++time | +
+ Time of exception, NSTUNSET = not included + |
+float | ++vcocorrection | +
+ VCO correction, from 0 to 100%, <0 = not included + |
+int | ++usec | +
+ [DEPRECATED] microsecond time offset, 0 = not included + |
+int | ++receptionquality | +
+ Reception quality, 0 to 100% clock accurracy, <0 = not included + |
+uint32_t | ++count | +
+ The count thereof, 0 = not included + |
+char | ++type[16] | +
+ E.g. "MISSING" or "UNEXPECTED", zero length = not included + |
+char | ++clockstatus[128] | +
+ Description of clock-specific parameters, zero length = not included + |
struct MSEHRecenter | +
Container for recenter parameters for use in extra headers.
+Actual values are optional, with special values indicating an unset state.
+Data Fields | ||
---|---|---|
+char | ++type[30] | +
+ Recenter type (e.g. "MASS", "GIMBAL"), zero length = not included + |
+nstime_t | ++begintime | +
+ Begin time, NSTUNSET = not included + |
+nstime_t | ++endtime | +
+ Estimated end time, NSTUNSET = not included + |
+char | ++trigger[30] | +
+ Trigger, e.g. AUTOMATIC or MANUAL, zero length = not included + |
typedef struct LM_PARSED_JSON_s LM_PARSED_JSON | +
Internal structure for holding parsed JSON extra headers.
+
+
|
+ +extern | +
Search for and return an extra header value.
+The extra header value is specified as a JSON Pointer (RFC 6901), e.g. '/objectA/objectB/header'
.
This routine can get used to test for the existence of a value without returning the value by setting value to NULL.
+If the target item is found (and value parameter is set) the value will be copied into the memory specified by value
. The type value specifies the data type expected.
If a parsestate pointer is supplied, the parsed (deserialized) JSON data are stored here. This value may be used in subsequent calls to avoid re-parsing the JSON. The data must be freed with mseh_free_parsestate() when done reading the JSON. If this value is NULL the parse state will be created and destroyed on each call.
+[in] | msr | Parsed miniSEED record to search |
[in] | ptr | Header value desired, as JSON Pointer |
[out] | value | Buffer for value, of type type |
[in] | type | Type of value expected, one of:
|
[in] | maxlength | Maximum length of string value |
[in] | parsestate | Parsed state for multiple operations, can be NULL |
0 | on success |
1 | when the value was not found |
2 | when the value is of a different type |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Set the value of extra header values.
+The extra header value is specified as a JSON Pointer (RFC 6901), e.g. '/objectA/objectB/header'
.
For most value types, if the ptr or final header values do not exist they will be created. If the header value exists it will be replaced. When the value type is 'M', for Merge Patch (RFC 7386), the location indicated by ptr must exist.
+The type value specifies the data type expected for value
.
If a parsestate pointer is supplied, the parsed (deserialized) JSON data are stored here. This value may be used in subsequent calls to avoid re-parsing the JSON. When done setting headers using this functionality the following must be done:
[in] | msr | Parsed miniSEED record to modify |
[in] | ptr | Header value to set as JSON Pointer, or JSON Merge Patch |
[in] | value | Buffer for value, of type type |
[in] | type | Type of value expected, one of:
|
[in] | parsestate | Parsed state for multiple operations, can be NULL |
0 | on success, otherwise a (negative) libmseed error code. |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Add event detection to the extra headers of the given record.
+If ptr is NULL, the default is '/FDSN/Event/Detection'
.
[in] | msr | Parsed miniSEED record to query |
[in] | ptr | Header value desired, specified in dot notation |
[in] | eventdetection | Structure with event detection values |
[in] | parsestate | Parsed state for multiple operations, can be NULL |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Add calibration to the extra headers of the given record.
+If ptr is NULL, the default is '/FDSN/Calibration/Sequence'
.
[in] | msr | Parsed miniSEED record to query |
[in] | ptr | Header value desired, specified in dot notation |
[in] | calibration | Structure with calibration values |
[in] | parsestate | Parsed state for multiple operations, can be NULL |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Add timing exception to the extra headers of the given record.
+If ptr is NULL, the default is '/FDSN/Time/Exception'
.
[in] | msr | Parsed miniSEED record to query |
[in] | ptr | Header value desired, specified in dot notation |
[in] | exception | Structure with timing exception values |
[in] | parsestate | Parsed state for multiple operations, can be NULL |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Add recenter event to the extra headers of the given record.
+If ptr is NULL, the default is '/FDSN/Recenter/Sequence'
.
[in] | msr | Parsed miniSEED record to query |
[in] | ptr | Header value desired, specified in dot notation |
[in] | recenter | Structure with recenter values |
[in] | parsestate | Parsed state for multiple operations, can be NULL |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Generate extra headers string (serialize) from internal state.
+Generate the extra headers JSON string from the internal parse state created by mseh_set_ptr_r().
+[in] | msr | MS3Record to generate extra headers for |
[in] | parsestate | Internal parsed state associated with msr |
+
|
+ +extern | +
Free internally parsed (deserialized) JSON data.
+Free the memory associated with JSON data parsed by mseh_get_ptr_r() or mseh_set_ptr_r(), specifically the data at the parsestate pointer.
+[in] | parsestate | Internal parsed state associated with msr |
+
|
+ +extern | +
Replace extra headers with supplied JSON.
+Parse the supplied JSON string, re-serialize into compact form, and replace the extra headers of msr with the result.
+To remove all of the extra headers, set jsonstring to NULL.
+This function cannot be used in combination with the routines that use a parsed state, i.e. mseh_get_ptr_r() and mseh_set_ptr_r().
+[in] | msr | MS3Record to generate extra headers for |
[in] | jsonstring | JSON replacment for extra headers of msr |
+
|
+ +extern | +
Print the extra header structure for the specified MS3Record.
+Output is printed in a pretty, formatted form for readability and the anonymous, root object container (the outer {}) is not printed.
+[in] | msr | MS3Record with extra headers to pring |
[in] | indent | Number of spaces to indent output |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Reading and writing interfaces for miniSEED to/from files or URLs. +More...
++Data Structures | |
struct | LMIO |
Type definition for data source I/O: file-system versus URL. More... | |
struct | MS3FileParam |
State container for reading miniSEED records from files or URLs. More... | |
+Macros | |
#define | LMIO_INITIALIZER |
Initialializer for the internal stream handle LMIO. | |
#define | MS3FileParam_INITIALIZER |
Initialializer for the internal file or URL I/O parameters MS3FileParam. | |
+Functions | |
int | ms3_readmsr (MS3Record **ppmsr, const char *mspath, uint32_t flags, int8_t verbose) |
Read miniSEED records from a file or URL. | |
int | ms3_readmsr_r (MS3FileParam **ppmsfp, MS3Record **ppmsr, const char *mspath, uint32_t flags, int8_t verbose) |
Read miniSEED records from a file or URL in a thread-safe way. | |
int | ms3_readmsr_selection (MS3FileParam **ppmsfp, MS3Record **ppmsr, const char *mspath, uint32_t flags, const MS3Selections *selections, int8_t verbose) |
Read miniSEED records from a file or URL with optional selection. | |
int | ms3_readtracelist (MS3TraceList **ppmstl, const char *mspath, const MS3Tolerance *tolerance, int8_t splitversion, uint32_t flags, int8_t verbose) |
Read miniSEED from a file into a trace list. | |
int | ms3_readtracelist_timewin (MS3TraceList **ppmstl, const char *mspath, const MS3Tolerance *tolerance, nstime_t starttime, nstime_t endtime, int8_t splitversion, uint32_t flags, int8_t verbose) |
Read miniSEED from a file into a trace list, with time range selection. | |
int | ms3_readtracelist_selection (MS3TraceList **ppmstl, const char *mspath, const MS3Tolerance *tolerance, const MS3Selections *selections, int8_t splitversion, uint32_t flags, int8_t verbose) |
Read miniSEED from a file into a trace list, with selection filtering. | |
int | ms3_url_useragent (const char *program, const char *version) |
Set User-Agent header for URL-based requests. | |
int | ms3_url_userpassword (const char *userpassword) |
Set authentication credentials for URL-based requests. | |
int | ms3_url_addheader (const char *header) |
Add header to any URL-based requests. | |
void | ms3_url_freeheaders (void) |
Free all set headers for URL-based requests. | |
int64_t | msr3_writemseed (MS3Record *msr, const char *mspath, int8_t overwrite, uint32_t flags, int8_t verbose) |
Write miniSEED from an MS3Record container to a file. | |
int64_t | mstl3_writemseed (MS3TraceList *mst, const char *mspath, int8_t overwrite, int maxreclen, int8_t encoding, uint32_t flags, int8_t verbose) |
Write miniSEED from an MS3TraceList container to a file. | |
int | libmseed_url_support (void) |
Run-time test for URL support in libmseed. | |
MS3FileParam * | ms3_mstl_init_fd (int fd) |
Initialize MS3FileParam parameters for a file descriptor. | |
Reading and writing interfaces for miniSEED to/from files or URLs.
+The miniSEED reading interfaces read from either regular files or URLs (if optional support is included). The miniSEED writing interfaces write to regular files.
+URL support for reading is included by building the library with the LIBMSEED_URL variable defined, see the INSTALL instructions for more information. Only URL path-specified resources can be read, e.g. HTTP GET requests. More advanced POST or form-based requests are not supported.
+The function libmseed_url_support() can be used as a run-time test to determine if URL support is included in the library.
+Some parameters can be set that affect the reading of data from URLs, including:
Diagnostics: Setting environment variable LIBMSEED_URL_DEBUG enables detailed verbosity of URL protocol exchanges.
+struct MS3FileParam | +
State container for reading miniSEED records from files or URLs.
+In general these values should not be directly set or accessed. It is possible to allocate a structure and set the path
, startoffset
, and endoffset
values for advanced usage. Note that file/URL start and end offsets can also be parsed from the path name as well.
Data Fields | ||
---|---|---|
+char | ++path[512] | ++INPUT: File name or URL. |
+int64_t | ++startoffset | ++INPUT: Start position in input stream. |
+int64_t | ++endoffset | ++INPUT: End position in input stream, 0 == unknown (e.g. pipe) |
+int64_t | ++streampos | ++OUTPUT: Read position of input stream. |
+int64_t | ++recordcount | ++OUTPUT: Count of records read from this stream/file so far. |
+char * | ++readbuffer | ++INTERNAL: Read buffer, allocated internally. |
+int | ++readlength | ++INTERNAL: Length of data in read buffer. |
+int | ++readoffset | ++INTERNAL: Read offset in read buffer. |
+uint32_t | ++flags | ++INTERNAL: Stream reading state flags. |
+LMIO | ++input | ++INTERNAL: IO handle, file or URL. |
#define LMIO_INITIALIZER | +
Initialializer for the internal stream handle LMIO.
+ +#define MS3FileParam_INITIALIZER | +
Initialializer for the internal file or URL I/O parameters MS3FileParam.
+ +
+
|
+ +extern | +
Read miniSEED records from a file or URL.
+This routine is a wrapper for ms3_readmsr_selection() that uses the global file reading parameters. This routine is not thread safe and cannot be used to read more than one stream at a time.
+See ms3_readmsr_selection() for a further description of arguments.
+MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Read miniSEED records from a file or URL in a thread-safe way.
+This routine is a wrapper for ms3_readmsr_selection() that uses the re-entrant capabilities. This routine is thread safe and can be used to read more than one stream at a time as long as separate MS3FileParam containers are used for each stream.
+A MS3FileParam container will be allocated if *ppmsfp
is NULL
.
See ms3_readmsr_selection() for a further description of arguments.
+MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Read miniSEED records from a file or URL with optional selection.
+This routine will open and read, with subsequent calls, all miniSEED records in specified stream (file or URL).
+All stream reading parameters are stored in a MS3FileParam container and returned (via a pointer to a pointer) for the calling routine to use in subsequent calls. A MS3FileParam container will be allocated if *ppmsfp
is NULL
. This routine is thread safe and can be used to read multiple streams in parallel as long as the stream reading parameters are managed appropriately.
The flags argument are bit flags used to control the reading process. The following flags are supported:
If MSF_PNAMERANGE is set in flags, the mspath will be searched for start and end byte offsets for the file or URL in the following format: 'PATH@
START-
whereEND'
,START
and END
are both optional and specified in bytes.
If selections is not NULL, the MS3Selections will be used to limit what is returned to the caller. Any data not matching the selections will be skipped.
+After reading all the records in a stream the calling program should call this routine a final time with mspath set to NULL. This will close the input stream and free allocated memory.
+[out] | ppmsfp | Pointer-to-pointer of an MS3FileParam, which contains the state of stream reading across iterative calls of this function. |
[out] | ppmsr | Pointer-to-pointer of an MS3Record, which will contain a parsed record on success. |
[in] | mspath | File or URL to read |
[in] | flags | Flags used to control parsing, see Control flags |
[in] | selections | Specify limits to which data should be returned, see Data Selections |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MS_ENDOFFILE | on reaching the end of a stream |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Read miniSEED from a file into a trace list.
+This is a simple wrapper for ms3_readtracelist_selection() that uses no selections.
+See ms3_readtracelist_selection() for a further description of arguments.
+MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Read miniSEED from a file into a trace list, with time range selection.
+This is a wrapper for ms3_readtraces_selection() that creates a simple selection for a specified time window.
+See ms3_readtracelist_selection() for a further description of arguments.
+MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Read miniSEED from a file into a trace list, with selection filtering.
+This routine will open and read all miniSEED records in specified file and populate a MS3TraceList, allocating this struture if needed. This routine is thread safe.
+If selections is not NULL, the MS3Selections will be used to limit which records are added to the trace list. Any data not matching the selections will be skipped.
+As this routine reads miniSEED records it attempts to construct continuous time series, merging segments when possible. See mstl3_addmsr() for details of tolerance.
+The splitversion flag controls whether data are grouped according to data publication version (or quality for miniSEED 2.x). See mstl3_addmsr() for full details.
+If the MSF_RECORDLIST flag is set in flags, a MS3RecordList will be built for each MS3TraceSeg. The MS3RecordPtr entries contain the location of the data record, bit flags, extra headers, etc.
+[out] | ppmstl | Pointer-to-pointer to a MS3TraceList to populate |
[in] | mspath | File to read |
[in] | tolerance | Tolerance function pointers as MS3Tolerance |
[in] | selections | Pointer to MS3Selections for limiting data |
[in] | splitversion | Flag to control splitting of version/quality |
[in] | flags | Flags to control reading, see ms3_readmsr_selection() |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Set User-Agent header for URL-based requests.
+Configure global User-Agent header for URL-based requests generated by the library. The program and version values will be combined into the form "program/version" along with declarations of the library and URL-supporting dependency versions.
+An error will be returned when the library was not compiled with URL support.
+[in] | program | Name of calling program |
[in] | version | Version of calling program |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Set authentication credentials for URL-based requests.
+Sets global user and password for authentication for URL-based requests generated by the library. The expected format of the credentials is: "[user name]:[password]" (without the square brackets).
+An error will be returned when the library was not compiled with URL support.
+[in] | userpassword | User and password as user:password |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Add header to any URL-based requests.
+Sets global header to be included in URL-based requests generated by the library.
+An error will be returned when the library was not compiled with URL support.
+[in] | header | Header in "key: value" format |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Free all set headers for URL-based requests.
+Free all global headers for URL-based requests as set by ms3_url_addheader().
+
+
|
+ +extern | +
Write miniSEED from an MS3Record container to a file.
+Pack MS3Record data into miniSEED record(s) by calling msr3_pack() and write to a specified file. The MS3Record container is used as a template for record(s) written to the file.
+The overwrite flag controls whether a existing file is overwritten or not. If true (non-zero) any existing file will be replaced. If false (zero) new records will be appended to an existing file. In either case, new files will be created if they do not yet exist.
+[in,out] | msr | MS3Record containing data to write |
[in] | mspath | File for output records |
[in] | overwrite | Flag to control overwriting versus appending |
[in] | flags | Flags controlling data packing, see msr3_pack() |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Write miniSEED from an MS3TraceList container to a file.
+Pack MS3TraceList data into miniSEED record(s) by calling mstl3_pack() and write to a specified file.
+The overwrite flag controls whether a existing file is overwritten or not. If true (non-zero) any existing file will be replaced. If false (zero) new records will be appended to an existing file. In either case, new files will be created if they do not yet exist.
+[in,out] | mstl | MS3TraceList containing data to write |
[in] | mspath | File for output records |
[in] | overwrite | Flag to control overwriting versus appending |
[in] | maxreclen | The maximum record length to create |
[in] | encoding | encoding Encoding for data samples, see msr3_pack() |
[in] | flags | Flags controlling data packing, see mstl3_pack() and msr3_pack() |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Run-time test for URL support in libmseed.
+
+
|
+ +extern | +
Initialize MS3FileParam parameters for a file descriptor.
+Initialize a MS3FileParam for reading from a specified fd (file descriptor).
+The MS3FileParam should be used with ms3_readmsr_r() or ms3_readmsr_selection(). Once all data has been read from the stream, it will be closed during the cleanup call of those routines.
+[in] | fd | File descriptor for input reading |
MessageOnError - this function logs a message on error
+ +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Utilities for handling leap seconds. +More...
++Data Structures | |
struct | LeapSecond |
Leap second list container. More... | |
+Functions | |
int | ms_readleapseconds (const char *envvarname) |
Read leap second file specified by an environment variable. | |
int | ms_readleapsecondfile (const char *filename) |
Read leap second from the specified file. | |
+Variables | |
LeapSecond * | leapsecondlist |
Utilities for handling leap seconds.
+The library contains functionality to load a list of leap seconds into a global list, which is then used to determine when leap seconds occurred, ignoring any flags in the data itself regarding leap seconds. This is useful as past leap seconds are well known and leap second indicators in data are, historically, more often wrong than otherwise.
+The library uses the leap second list (and any flags in the data, if no list is provided) to adjust the calculated time of the last sample in a record. This allows proper merging of continuous series generated through leap seconds.
+Normally, calling programs do not need to do any particular handling of leap seconds after loading the leap second list.
+struct LeapSecond | +
Leap second list container.
+Data Fields | ||
---|---|---|
+nstime_t | ++leapsecond | ++Time of leap second as epoch since 1 January 1900. |
+int32_t | ++TAIdelta | ++TAI-UTC difference in seconds. |
+struct LeapSecond * | ++next | ++Pointer to next entry, NULL if the last. |
+
|
+ +extern | +
Read leap second file specified by an environment variable.
+Leap seconds are loaded into the library's global leapsecond list.
+[in] | envvarname | Environment variable that identifies the leap second file |
-1 | on file read error |
-2 | when the environment variable is not set |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Read leap second from the specified file.
+Leap seconds are loaded into the library's global leapsecond list.
+The file is expected to be in NTP leap second list format. Some locations where this file can be obtained are indicated in RFC 8633 section 3.7: https://www.rfc-editor.org/rfc/rfc8633.html#section-3.7
+[in] | filename | File containing leap second list |
-1 | on error |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Global leap second list
+ +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Central logging functions for the library and calling programs. +More...
++Data Structures | |
struct | MSLogEntry |
Log registry entry. More... | |
struct | MSLogRegistry |
Log message registry. More... | |
struct | MSLogParam |
Logging parameters. Callers should not modify these values directly and generally should not need to access them. More... | |
+Macros | |
#define | MAX_LOG_MSG_LENGTH 200 |
#define | MSLogRegistry_INITIALIZER |
Initialializer for MSLogRegistry. | |
#define | MSLogParam_INITIALIZER |
Initialializer for MSLogParam. | |
+#define | ms_log(level, ...) ms_rlog(__func__, level, __VA_ARGS__) |
Wrapper for ms_rlog(), call as ms_log (level, format, ...) | |
+#define | ms_log_l(logp, level, ...) ms_rlog_l(logp, __func__, level, __VA_ARGS__) |
Wrapper for ms_rlog_l(), call as ms_log_l (logp, level, format, ...) | |
+#define | ms_loginit(log_print, logprefix, diag_print, errprefix) ms_rloginit(log_print, logprefix, diag_print, errprefix, 0) |
Convenience wrapper for ms_rloginit(), omitting max messages, disabling registry. | |
+#define | ms_loginit_l(logp, log_print, logprefix, diag_print, errprefix) ms_rloginit_l(logp, log_print, logprefix, diag_print, errprefix, 0) |
Convenience wrapper for ms_rloginit_l(), omitting max messages, disabling registry. | |
+Functions | |
int | ms_rlog (const char *function, int level, const char *format,...) |
Register log message using global logging parameters. | |
int | ms_rlog_l (MSLogParam *logp, const char *function, int level, const char *format,...) |
Register log message using specified logging parameters. | |
void | ms_rloginit (void(*log_print)(const char *), const char *logprefix, void(*diag_print)(const char *), const char *errprefix, int maxmessages) |
Initialize the global logging parameters. | |
MSLogParam * | ms_rloginit_l (MSLogParam *logp, void(*log_print)(const char *), const char *logprefix, void(*diag_print)(const char *), const char *errprefix, int maxmessages) |
Initialize specified MSLogParam logging parameters. | |
int | ms_rlog_emit (MSLogParam *logp, int count, int context) |
Emit, aka send to print functions, messages from log registry. | |
int | ms_rlog_free (MSLogParam *logp) |
Free, without emitting, all messages from log registry. | |
Central logging functions for the library and calling programs.
+This central logging facility is used for all logging performed by the library. Calling programs may also wish to log messages via the same facility for consistency.
+The logging can be configured to send messages to arbitrary functions, referred to as log_print()
and diag_print()
. This allows output to be re-directed to other logging systems if needed.
It is also possible to assign prefixes to log messages for identification, referred to as logprefix
and errprefix
.
Three message levels are recognized:
log_print()
with logprefix
diag_print()
with logprefix
diag_print()
with errprefix
It is the task of the ms_rlog() and ms_rlog_l() functions to format a message using printf conventions and pass the formatted string to the appropriate printing function. The convenience macros ms_log() and ms_log_l() can be used to automatically set the calling function name.
+The log registry facility allows a calling program to disable error (and warning) output from the library and either inspect it or emit (print) as desired.
+By default log messages are sent directly to the printing functions. Optionally, error and warning messages (levels 1 and 2) can be accumulated in a log-registry. Verbose output messages (level 0) are not accumulated in the registry. The registry is enabled by setting the maxmessages
argument of either ms_rloginit() or ms_rloginit_l(). Messages can be emitted, aka printed, using ms_rlog_emit() and cleared using ms_rlog_free(). Alternatively, the MSLogRegistry associated with a MSLogParam (or the global parameters at gMSLogParam
).
See Read miniSEED from files for a simple example of error and warning message registry usage.
+By default the library is compiled in a mode where each thread of a multi-threaded program will have it's own, default logging parameters. If you wish to change the default printing functions, message prefixes, or enable the log registry, this must be done per-thread.
+The library can be built with the LIBMSEED_NO_THREADING variable defined, resulting in a mode where there are global parameters for all threads. In general this should not be used unless the system does not support the necessary thread-local storage directives.
+Functions marked as MessageOnError log a message when returning an error status or logging a warning (log levels 1 and 2). This indication can be useful when error and warning messages are retained in log-registry.
+struct MSLogEntry | +
Log registry entry.
+Data Fields | ||
---|---|---|
+int | ++level | ++Message level. |
+char | ++function[30] | ++Function generating the message. |
+char | ++message[MAX_LOG_MSG_LENGTH] | ++Log, warning or error message. |
+struct MSLogEntry * | ++next | ++ |
struct MSLogRegistry | +
Log message registry.
+Data Fields | ||
---|---|---|
+int | ++maxmessages | ++ |
+int | ++messagecnt | ++ |
+MSLogEntry * | ++messages | ++ |
#define MAX_LOG_MSG_LENGTH 200 | +
Maximum length of log messages in bytes
+ +#define MSLogRegistry_INITIALIZER | +
Initialializer for MSLogRegistry.
+ +#define MSLogParam_INITIALIZER | +
Initialializer for MSLogParam.
+ +
+
|
+ +extern | +
Register log message using global logging parameters.
+It is convenient to call this function via the ms_log() macro, which sets the calling function automatically.
+Three message levels are recognized, see logging-levels for more information.
+This function builds the log/error message and passes to it to the appropriate print function. If custom printing functions have not been defined, messages will be printed with fprintf()
, log messages to stdout
and error messages to stderr
.
If the log/error prefixes have been set they will be pre-pended to the message. If no custom log prefix is set none will be included. If no custom error prefix is set "Error: "
will be included.
A trailing newline character is for error messages is removed if the message is added to the log registry.
+All messages will be truncated at the MAX_LOG_MSG_LENGTH, this includes any prefix.
+[in] | function | Name of function registering log message |
[in] | level | Message level |
[in] | format | Message format in printf() style |
[in] | ... | Message format variables |
+
|
+ +extern | +
Register log message using specified logging parameters.
+It is convenient to call this function via the ms_log_l() macro, which sets the calling function automatically.
+The function uses logging parameters specified in the supplied MSLogParam. This reentrant capability allows using different parameters in different parts of a program or different threads.
+Three message levels are recognized, see logging-levels for more information.
+This function builds the log/error message and passes to it to the appropriate print function. If custom printing functions have not been defined, messages will be printed with fprintf()
, log messages to stdout
and error messages to stderr
.
If the log/error prefixes have been set they will be pre-pended to the message. If no custom log prefix is set none will be included. If no custom error prefix is set "Error: "
will be included.
A trailing newline character is for error messages is removed if the message is added to the log registry.
+All messages will be truncated at the MAX_LOG_MSG_LENGTH, this includes any prefix.
+[in] | logp | Pointer to MSLogParam to use for this message |
[in] | function | Name of function registering log message |
[in] | level | Message level |
[in] | format | Message format in printf() style |
[in] | ... | Message format variables |
+
|
+ +extern | +
Initialize the global logging parameters.
+Any message printing functions indicated must except a single argument, namely a string (const char *) that will contain the log message. If the function pointers are NULL, defaults will be used.
If the log and error prefixes have been set they will be pre-pended to the message. If the prefixes are NULL, defaults will be used.
+If maxmessages is greater than zero, warning and error (level >= 1) messages will be accumulated in a message registry. Once the maximum number of messages have accumulated, the oldest messages are discarded. Messages in the registry can be printed using ms_rlog_emit() or cleared using ms_rlog_free().
+[in] | log_print | Function to print log messages |
[in] | logprefix | Prefix to add to log and diagnostic messages |
[in] | diag_print | Function to print diagnostic and error messages |
[in] | errprefix | Prefix to add to error messages |
[in] | maxmessages | Maximum number of error/warning messages to store in registry |
+
|
+ +extern | +
Initialize specified MSLogParam logging parameters.
+If the logging parameters have not been initialized (logp == NULL), new parameter space will be allocated.
+Any message printing functions indicated must except a single argument, namely a string (const char *) that will contain the log message. If the function pointers are NULL, defaults will be used.
If the log and error prefixes have been set they will be pre-pended to the message. If the prefixes are NULL, defaults will be used.
+If maxmessages is greater than zero, warning and error (level >= 1) messages will be accumulated in a message registry. Once the maximum number of messages have accumulated, the oldest messages are discarded. Messages in the registry can be printed using ms_rlog_emit() or cleared using ms_rlog_free().
+[in] | logp | MSLogParam logging parameters |
[in] | log_print | Function to print log messages |
[in] | logprefix | Prefix to add to log and diagnostic messages |
[in] | diag_print | Function to print diagnostic and error messages |
[in] | errprefix | Prefix to add to error messages |
[in] | maxmessages | Maximum number of error/warning messages to store in registry |
+
|
+ +extern | +
Emit, aka send to print functions, messages from log registry.
+Emit messages from the log registry, using the printing functions identified by the MSLogParam.
+Messages are printed in order from earliest to latest.
+The maximum number messages to emit, from most recent to earliest, can be limited using count. If the value is 0 all messages are emitted. If this limit is used and messages are left in the registry, it is highly recommended to either emit them soon or clear them with ms_rlog_free(). A common pattern would be to emit the last message (e.g. count of 1) and immediately free (discard) any remaining messages.
+[in] | logp | MSLogParam for this message or NULL for global parameters |
[in] | count | Number of messages to emit, 0 to emit all messages |
[in] | context | If non-zero include context by prefixing the function name (if available) |
+
|
+ +extern | +
Free, without emitting, all messages from log registry.
+[in] | logp | MSLogParam for this message or NULL for global parameters |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
The low-down, the nitty gritty, the basics. +More...
++Topics | |
Memory Allocators | |
User-definable memory allocators used by library. | |
Data Encodings | |
Data encoding type defines. | |
Byte swap flags | |
Flags indicating whether the header or payload needed byte swapping. | |
Return codes | |
Common error codes returned by library functions. Error values will always be negative. | |
Control flags | |
Parsing, packing and trace construction control flags. | |
The low-down, the nitty gritty, the basics.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
User-definable memory allocators used by library. +More...
++Data Structures | |
struct | LIBMSEED_MEMORY |
+Functions | |
void * | libmseed_memory_prealloc (void *ptr, size_t size, size_t *currentsize) |
+Variables | |
LIBMSEED_MEMORY | libmseed_memory |
size_t | libmseed_prealloc_block_size |
User-definable memory allocators used by library.
+The global structure libmseed_memory contains three function pointers that are used for all memory allocation and freeing done by the library.
+The following function pointers are available:
By default the system malloc(), realloc(), and free() are used. Equivalent to setting:
+
+
|
+ +extern | +
Internal realloc() wrapper that allocates in libmseed_prealloc_block_size blocks
+Preallocation is used by default on Windows and disabled otherwise.
+ +
+
|
+ +extern | +
Global memory management function list
+ +
+
|
+ +extern | +
Global pre-allocation block size.
+When non-zero, memory re-allocations will be increased in blocks of this size. This is useful on platforms where the system realloc() is slow such as Windows.
+Default on Windows is 1 MiB, otherwise disabled.
+Set to 0 to disable pre-allocation.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Definitions and functions related to individual miniSEED records. +More...
++Data Structures | |
struct | MS3Record |
miniSEED record container More... | |
+Functions | |
int | msr3_parse (const char *record, uint64_t recbuflen, MS3Record **ppmsr, uint32_t flags, int8_t verbose) |
Parse miniSEED from a buffer. | |
int | msr3_pack (const MS3Record *msr, void(*record_handler)(char *, int, void *), void *handlerdata, int64_t *packedsamples, uint32_t flags, int8_t verbose) |
Pack data into miniSEED records. | |
int | msr3_repack_mseed3 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_t verbose) |
Repack a parsed miniSEED record into a version 3 record. | |
int | msr3_pack_header3 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_t verbose) |
Pack a miniSEED version 3 header into the specified buffer. | |
int | msr3_pack_header2 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_t verbose) |
Pack a miniSEED version 2 header into the specified buffer. | |
int64_t | msr3_unpack_data (MS3Record *msr, int8_t verbose) |
Unpack data samples for a MS3Record. | |
int | msr3_data_bounds (const MS3Record *msr, uint32_t *dataoffset, uint32_t *datasize) |
Determine the data payload bounds for a MS3Record. | |
int64_t | ms_decode_data (const void *input, uint64_t inputsize, uint8_t encoding, uint64_t samplecount, void *output, uint64_t outputsize, char *sampletype, int8_t swapflag, const char *sid, int8_t verbose) |
Decode data samples to a supplied buffer. | |
MS3Record * | msr3_init (MS3Record *msr) |
Initialize and return an MS3Record. | |
void | msr3_free (MS3Record **ppmsr) |
Free all memory associated with a MS3Record. | |
MS3Record * | msr3_duplicate (const MS3Record *msr, int8_t datadup) |
Duplicate a MS3Record. | |
nstime_t | msr3_endtime (const MS3Record *msr) |
Calculate time of the last sample in a record. | |
void | msr3_print (const MS3Record *msr, int8_t details) |
Print header values of an MS3Record. | |
int | msr3_resize_buffer (MS3Record *msr) |
Resize data sample buffer of MS3Record to what is needed. | |
double | msr3_sampratehz (const MS3Record *msr) |
Calculate sample rate in samples/second (Hertz) for a given MS3Record. | |
double | msr3_host_latency (const MS3Record *msr) |
Calculate data latency based on the host time. | |
int64_t | ms3_detect (const char *record, uint64_t recbuflen, uint8_t *formatversion) |
Detect miniSEED record in buffer. | |
int | ms_parse_raw3 (const char *record, int maxreclen, int8_t details) |
Parse and verify a miniSEED 3.x record header. | |
int | ms_parse_raw2 (const char *record, int maxreclen, int8_t details, int8_t swapflag) |
Parse and verify a miniSEED 2.x record header. | |
Definitions and functions related to individual miniSEED records.
+struct MS3Record | +
miniSEED record container
+Data Fields | ||
---|---|---|
+const char * | ++record | ++Raw miniSEED record, if available. |
+int32_t | ++reclen | ++Length of miniSEED record in bytes. |
+uint8_t | ++swapflag | ++Byte swap indicator (bitmask), see Byte swap flags. |
+char | ++sid[LM_SIDLEN] | ++Source identifier as URN, max length LM_SIDLEN. |
+uint8_t | ++formatversion | ++Format major version. |
+uint8_t | ++flags | ++Record-level bit flags. |
+nstime_t | ++starttime | ++Record start time (first sample) |
+double | ++samprate | ++Nominal sample rate as samples/second (Hz) or period (s) |
+int16_t | ++encoding | ++Data encoding format, see Data Encodings. |
+uint8_t | ++pubversion | ++Publication version. |
+int64_t | ++samplecnt | ++Number of samples in record. |
+uint32_t | ++crc | ++CRC of entire record. |
+uint16_t | ++extralength | ++Length of extra headers in bytes. |
+uint32_t | ++datalength | ++Length of data payload in bytes. |
+char * | ++extra | ++Pointer to extra headers. |
+void * | ++datasamples | ++Data samples, numsamples of type sampletype. |
+uint64_t | ++datasize | ++Size of datasamples buffer in bytes. |
+int64_t | ++numsamples | ++Number of data samples in datasamples. |
+char | ++sampletype | ++Sample type code: t, i, f, d Sample Types. |
+
|
+ +extern | +
Parse miniSEED from a buffer.
+This routine will attempt to parse (detect and unpack) a miniSEED record from a specified memory buffer and populate a supplied MS3Record structure. Both miniSEED 2.x and 3.x records are supported.
+The record length is automatically detected. For miniSEED 2.x this means the record must contain a 1000 blockette.
+record | Buffer containing record to parse |
recbuflen | Buffer length in bytes |
ppmsr | Pointer-to-point to a MS3Record that will be populated |
flags | Flags controlling features:
|
verbose | control verbosity of diagnostic output |
0 | Success, populates the supplied MS3Record. |
>0 | Data record detected but not enough data is present, the return value is a hint of how many more bytes are needed. |
<0 | library error code is returned. |
MessageOnError - this function logs a message on error except MS_NOTSEED
+ +
+
|
+ +extern | +
Pack data into miniSEED records.
+Packing is performed according to the version at MS3Record::formatversion.
+The MS3Record::datasamples array and MS3Record::numsamples value will not be changed by this routine. It is the responsibility of the calling routine to adjust the data buffer if desired.
+As each record is filled and finished they are passed to record_handler() which should expect 1) a char*
to the record, 2) the length of the record and 3) a pointer supplied by the original caller containing optional private data (handlerdata). It is the responsibility of record_handler() to process the record, the memory will be re-used or freed when record_handler() returns.
The following data encodings and expected MS3Record::sampletype are supported:
't'
'i'
'i'
'f'
'd'
'i'
'i'
If flags has MSF_FLUSHDATA set, all of the data will be packed into data records even though the last one will probably be smaller than requested or, in the case of miniSEED 2, unfilled.
+Default values are: record length = 4096, encoding = 11 (Steim2). The defaults are triggered when msr.reclen and msr.encoding are set to -1.
+[in] | msr | MS3Record containing data to pack |
[in] | record_handler() | Callback function called for each record |
[in] | handlerdata | A pointer that will be provided to the record_handler() |
[out] | packedsamples | The number of samples packed, returned to caller |
[in] | flags | Bit flags used to control the packing process:
|
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Repack a parsed miniSEED record into a version 3 record.
+Pack the parsed header into a version 3 header and copy the raw encoded data from the original record. The original record must be available at the MS3Record.record pointer.
+This can be used to efficiently convert format versions or modify header values without unpacking the data samples.
+[in] | msr | MS3Record containing record to repack |
[out] | record | Destination buffer for repacked record |
[in] | recbuflen | Length of destination buffer |
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Pack a miniSEED version 3 header into the specified buffer.
+Default values are: record length = 4096, encoding = 11 (Steim2). The defaults are triggered when msr.reclen and msr.encoding are set to -1.
+[in] | msr | MS3Record to pack |
[out] | record | Destination for packed header |
[in] | recbuflen | Length of destination buffer |
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Pack a miniSEED version 2 header into the specified buffer.
+Default values are: record length = 4096, encoding = 11 (Steim2). The defaults are triggered when msr.reclen and msr.encoding are set to -1.
+[in] | msr | MS3Record to pack |
[out] | record | Destination for packed header |
[in] | recbuflen | Length of destination buffer |
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Unpack data samples for a MS3Record.
+This routine can be used to unpack the data samples for a MS3Record that was earlier parsed without the data samples being decoded.
+The packed/encoded data is accessed in the record indicated by MS3Record.record and the unpacked samples are placed in MS3Record.datasamples. The resulting data samples are either text characters, 32-bit integers, 32-bit floats or 64-bit floats in host byte order.
+An internal buffer is allocated if the encoded data is not aligned for the sample size, which is a decent indicator of the alignment needed for decoding efficiently.
+[in] | msr | Target MS3Record to unpack data samples |
[in] | verbose | Flag to control verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Determine the data payload bounds for a MS3Record.
+Bounds are the starting offset in record and size. For miniSEED 2.x the raw record is expected to be located at the MS3Record.record pointer.
+When the encoding is a fixed length per sample (text, integers, or floats), calculate the data size based on the sample count and use if less than size determined otherwise.
+When the encoding is Steim1 or Steim2, search for 64-byte padding frames (all zeros) at the end of the payload and remove from the reported size.
+[in] | msr | The MS3Record to determine payload bounds for |
[out] | dataoffset | Offset from start of record to start of payload |
[out] | datasize | Payload size in bytes |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Decode data samples to a supplied buffer.
+[in] | input | Encoded data |
[in] | inputsize | Size of input buffer in bytes |
[in] | encoding | Data encoding |
[in] | samplecount | Number of samples to decode |
[out] | output | Decoded data |
[in] | outputsize | Size of output buffer in bytes |
[out] | sampletype | Pointer to (single character) sample type of decoded data |
[in] | swapflag | Flag indicating if encoded data needs swapping |
[in] | sid | Source identifier to include in diagnostic/error messages |
[in] | verbose | Flag to control verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+ +Initialize and return an MS3Record.
+Memory is allocated if for a new MS3Record if msr is NULL.
+If memory for the datasamples
field has been allocated the pointer will be retained for reuse. If memory for extra headers has been allocated it will be released.
[in] | msr | A MS3Record to re-initialize |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
+
|
+ +extern | +
Duplicate a MS3Record.
+Extra headers are duplicated as well.
+If the datadup flag is true (non-zero) and the source MS3Record has associated data samples copy them as well.
+[in] | msr | MS3Record to duplicate |
[in] | datadup | Flag to control duplication of data samples |
MessageOnError - this function logs a message on error
+ +Calculate time of the last sample in a record.
+If leap seconds have been loaded into the internal library list: when a record completely contains a leap second, starts before and ends after, the calculated end time will be adjusted (reduced) by one second.
[in] | msr | MS3Record to calculate end time of |
+
|
+ +extern | +
+
|
+ +extern | +
Resize data sample buffer of MS3Record to what is needed.
+This routine should only be used if pre-allocation of memory, via libmseed_prealloc_block_size, was enabled to allocate the buffer.
+[in] | msr | MS3Record to resize buffer |
MessageOnError - this function logs a message on error
+ +
+
|
+ +externinline | +
+
|
+ +extern | +
Calculate data latency based on the host time.
+Calculation is based on the time of the last sample in the record; in other words, the difference between the host time and the time of the last sample in the record.
+Double precision is returned, but the true precision is dependent on the accuracy of the host system clock among other things.
+[in] | msr | MS3Record to calculate latency for |
+
|
+ +extern | +
Detect miniSEED record in buffer.
+Determine if the buffer contains a miniSEED data record by verifying known signatures (fields with known limited values).
+If miniSEED 2.x is detected, search the record up to recbuflen bytes for a 1000 blockette. If no blockette 1000 is found, search at 64-byte offsets for the fixed section of the next header, thereby implying the record length.
+[in] | record | Buffer to test for record |
[in] | recbuflen | Length of buffer |
[out] | formatversion | Major version of format detected, 0 if unknown |
-1 | Data record not detected or error |
0 | Data record detected but could not determine length |
>0 | Size of the record in bytes |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Parse and verify a miniSEED 3.x record header.
+Parsing is done at the lowest level, printing error messages for invalid header values and optionally print raw header values.
+The buffer at record is assumed to be a miniSEED record. Not every possible test is performed, common errors and those causing library parsing to fail should be detected.
+This routine is primarily intended to diagnose invalid miniSEED headers.
+[in] | record | Buffer to parse as miniSEED |
[in] | maxreclen | Maximum length to search in buffer |
[in] | details | Controls diagnostic output as follows:
|
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Parse and verify a miniSEED 2.x record header.
+Parsing is done at the lowest level, printing error messages for invalid header values and optionally print raw header values.
+The buffer record is assumed to be a miniSEED record. Not every possible test is performed, common errors and those causing libmseed parsing to fail should be detected.
+This routine is primarily intended to diagnose invalid miniSEED headers.
+[in] | record | Buffer to parse as miniSEED |
[in] | maxreclen | Maximum length to search in buffer |
[in] | details | Controls diagnostic output as follows:
|
[in] | swapflag | Flag controlling byte-swapping as follows:
|
MessageOnError - this function logs a message on error
+ +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Functionality to build a list of records that contribute to a MS3TraceSeg. +More...
++Data Structures | |
struct | MS3RecordPtr |
A miniSEED record pointer and metadata. More... | |
struct | MS3RecordList |
Record list, holds MS3RecordPtr entries that contribute to a given MS3TraceSeg. More... | |
Functionality to build a list of records that contribute to a MS3TraceSeg.
+As a Trace List is constructed from data records, a list of the records that contribute to each segment can be built by using the MSF_RECORDLIST flag to mstl3_readbuffer() and ms3_readtracelist(). Alternatively, a record list can be built by adding records to a Trace List using mstl3_addmsr_recordptr().
+The main purpose of this functionality is to support an efficient, 2-pass pattern of first reading a summary of data followed by unpacking the samples. The unpacking can be performed selectively on desired segments and optionally placed in a caller-supplied buffer.
+The mstl3_unpack_recordlist() function allows for the unpacking of data samples for a given MS3TraceSeg into a caller-specified buffer, or allocating the buffer if needed.
+struct MS3RecordPtr | +
A miniSEED record pointer and metadata.
+Used to construct a list of data records that contributed to a trace segment.
+The location of the record is identified at a memory address (bufferptr), the location in an open file (fileptr and fileoffset), or the location in a file (filename and fileoffset).
+A MS3Record is stored with and contains the bit flags, extra headers, etc. for the record.
+The dataoffset to the encoded data is stored to enable direct decoding of data samples without re-parsing the header, used by mstl3_unpack_recordlist().
+Note: the list is stored in the time order that the entries contributed to the segment.
+Data Fields | ||
---|---|---|
+const char * | ++bufferptr | ++Pointer in buffer to record, NULL if not used. |
+FILE * | ++fileptr | ++Pointer to open FILE containing record, NULL if not used. |
+const char * | ++filename | ++Pointer to file name containing record, NULL if not used. |
+int64_t | ++fileoffset | ++Offset into file to record for fileptr or filename. |
+MS3Record * | ++msr | ++Pointer to MS3Record for this record. |
+nstime_t | ++endtime | ++End time of record, time of last sample. |
+uint32_t | ++dataoffset | ++Offset from start of record to encoded data. |
+void * | ++prvtptr | ++Private pointer, will not be populated by library but will be free'd. |
+struct MS3RecordPtr * | ++next | ++Pointer to next entry, NULL if the last. |
struct MS3RecordList | +
Record list, holds MS3RecordPtr entries that contribute to a given MS3TraceSeg.
+Data Fields | ||
---|---|---|
+uint64_t | ++recordcnt | ++Count of records in the list (for convenience) |
+MS3RecordPtr * | ++first | ++Pointer to first entry, NULL if the none. |
+MS3RecordPtr * | ++last | ++Pointer to last entry, NULL if the none. |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Common error codes returned by library functions. Error values will always be negative. +More...
++Macros | |
+#define | MS_ENDOFFILE 1 |
End of file reached return value. | |
+#define | MS_NOERROR 0 |
No error. | |
+#define | MS_GENERROR -1 |
Generic unspecified error. | |
+#define | MS_NOTSEED -2 |
Data not SEED. | |
+#define | MS_WRONGLENGTH -3 |
Length of data read was not correct. | |
+#define | MS_OUTOFRANGE -4 |
SEED record length out of range. | |
+#define | MS_UNKNOWNFORMAT -5 |
Unknown data encoding format. | |
+#define | MS_STBADCOMPFLAG -6 |
Steim, invalid compression flag(s) | |
+#define | MS_INVALIDCRC -7 |
Invalid CRC. | |
Common error codes returned by library functions. Error values will always be negative.
+
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Source identifier (SID) and string manipulation functions. +More...
++Functions | |
int | ms_sid2nslc (const char *sid, char *net, char *sta, char *loc, char *chan) |
Parse network, station, location and channel from an FDSN Source ID. | |
int | ms_nslc2sid (char *sid, int sidlen, uint16_t flags, const char *net, const char *sta, const char *loc, const char *chan) |
Convert network, station, location and channel to an FDSN Source ID. | |
int | ms_seedchan2xchan (char *xchan, const char *seedchan) |
Convert SEED 2.x channel to extended channel. | |
int | ms_xchan2seedchan (char *seedchan, const char *xchan) |
Convert extended channel to SEED 2.x channel. | |
int | ms_strncpclean (char *dest, const char *source, int length) |
Copy string, removing spaces, always terminated. | |
int | ms_strncpcleantail (char *dest, const char *source, int length) |
Copy string, removing trailing spaces, always terminated. | |
int | ms_strncpopen (char *dest, const char *source, int length) |
Copy fixed number of characters into unterminated string. | |
Source identifier (SID) and string manipulation functions.
+A source identifier uniquely identifies the generator of data in a record. This is a small string, usually in the form of a URI. For data identified with FDSN codes, the SID is usally a simple combination of the codes.
+
+
|
+ +extern | +
Parse network, station, location and channel from an FDSN Source ID.
+FDSN Source Identifiers are defined at: https://docs.fdsn.org/projects/source-identifiers/
+Parse a source identifier into separate components, expecting: "FDSN:NET_STA_LOC_CHAN"
, where CHAN="BAND_SOURCE_POSITION"
The CHAN value will be converted to a SEED channel code if possible. Meaning, if the BAND, SOURCE, and POSITION are single characters, the underscore delimiters will not be included in the returned channel.
+Identifiers may contain additional namespace identifiers, e.g.: "FDSN:AGENCY:NET_STA_LOC_CHAN"
Such additional namespaces are not part of the Source ID standard as of this writing and support is included for specialized usage or future identifier changes.
+Memory for each component must already be allocated. If a specific component is not desired set the appropriate argument to NULL.
+[in] | sid | Source identifier |
[out] | net | Network code |
[out] | sta | Station code |
[out] | loc | Location code |
[out] | chan | Channel code |
0 | on success |
-1 | on error |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert network, station, location and channel to an FDSN Source ID.
+FDSN Source Identifiers are defined at: https://docs.fdsn.org/projects/source-identifiers/
+Create a source identifier from individual network, station, location and channel codes with the form: FDSN:NET_STA_LOC_CHAN
, where CHAN="BAND_SOURCE_POSITION"
Memory for the source identifier must already be allocated.
+If the loc value is NULL it will be empty in the resulting Source ID.
+The chan value will be converted to extended channel format if it appears to be in SEED channel form. Meaning, if the chan is 3 characters with no delimiters, it will be converted to "BAND_SOURCE_POSITION"
form by adding delimiters between the codes.
[out] | sid | Destination string for source identifier |
sidlen | Maximum length of sid | |
flags | Currently unused, set to 0 | |
[in] | net | Network code |
[in] | sta | Station code |
[in] | loc | Location code |
[in] | chan | Channel code |
-1 | on error |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert SEED 2.x channel to extended channel.
+The SEED 2.x channel at seedchan must be a 3-character string. The xchan buffer must be at least 6 bytes, for the extended channel (band,source,position) and the terminating NULL.
+This functionality simply maps patterns, it does not check the validity of any codes.
+[out] | xchan | Destination for extended channel string, must be at least 6 bytes |
[in] | seedchan | Source string, must be a 3-character string |
0 | on successful mapping of channel |
-1 | on error |
+
|
+ +extern | +
Convert extended channel to SEED 2.x channel.
+The extended channel at xchan must be a 5-character string.
+The seedchan buffer must be at least 4 bytes, for the SEED channel and the terminating NULL. Alternatively, seedchan may be set to NULL in which case this function becomes a test for whether the xchan could be mapped without actually doing the conversion. Finally, seedchan can be the same buffer as xchan for an in-place conversion.
+This routine simply maps patterns, it does not check the validity of any specific codes.
+[out] | seedchan | Destination for SEED channel string, must be at least 4 bytes |
[in] | xchan | Source string, must be a 5-character string |
0 | on successful mapping of channel |
-1 | on error |
+
|
+ +extern | +
Copy string, removing spaces, always terminated.
+Copy up to length bytes of UTF-8 characters from source to dest while removing all spaces. The result is left justified and always null terminated.
+The destination string must have enough room needed for the non-space characters within length and the null terminator, a maximum of length + 1.
+[out] | dest | Destination for terminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |
+
|
+ +extern | +
Copy string, removing trailing spaces, always terminated.
+Copy up to length bytes of UTF-8 characters from source to dest without any trailing spaces. The result is left justified and always null terminated.
+The destination string must have enough room needed for the characters within length and the null terminator, a maximum of length + 1.
+[out] | dest | Destination for terminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |
+
|
+ +extern | +
Copy fixed number of characters into unterminated string.
+Copy length bytes of UTF-8 characters from source to dest, padding the right side with spaces and leave open-ended, aka un-terminated. The result is left justified and never null terminated.
+The destination string must have enough room for length characters.
+[out] | dest | Destination for unterminated string |
[in] | source | Source string |
[in] | length | Length of characters for destination string in bytes |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
Definitions and functions for related to library time values. +More...
++Macros | |
+#define | NSTMODULUS 1000000000 |
Define the high precision time tick interval as 1/modulus seconds corresponding to nanoseconds. | |
+#define | NSTERROR -2145916800000000000LL |
Error code for routines that normally return a high precision time. The time value corresponds to '1902-01-01T00:00:00.000000000Z'. | |
+#define | NSTUNSET -2145916799999999999LL |
Special nstime_t value meaning "unset". The time value corresponds to '1902-01-01T00:00:00.000000001Z'. | |
+#define | MS_EPOCH2NSTIME(X) (X) * (nstime_t) NSTMODULUS |
macro to convert Unix/POSIX epoch time to high precision epoch time | |
+#define | MS_NSTIME2EPOCH(X) (X) / NSTMODULUS |
Macro to convert high precision epoch time to Unix/POSIX epoch time. | |
#define | MS_HPTIME2NSTIME(X) (X) * (nstime_t) 1000 |
Convert a hptime_t value (used by previous releases) to nstime_t. | |
#define | MS_NSTIME2HPTIME(X) (X) / 1000 |
Convert an nstime_t value to hptime_t (used by previous releases) | |
+Typedefs | |
typedef int64_t | nstime_t |
libmseed time type, integer nanoseconds since the Unix/POSIX epoch (00:00:00 Thursday, 1 January 1970) | |
+Enumerations | |
enum | ms_timeformat_t { + ISOMONTHDAY = 0 +, ISOMONTHDAY_Z = 1 +, ISOMONTHDAY_DOY = 2 +, ISOMONTHDAY_DOY_Z = 3 +, + ISOMONTHDAY_SPACE = 4 +, ISOMONTHDAY_SPACE_Z = 5 +, SEEDORDINAL = 6 +, UNIXEPOCH = 7 +, + NANOSECONDEPOCH = 8 + + } |
Time format identifiers. More... | |
enum | ms_subseconds_t { + NONE = 0 +, MICRO = 1 +, NANO = 2 +, MICRO_NONE = 3 +, + NANO_NONE = 4 +, NANO_MICRO = 5 +, NANO_MICRO_NONE = 6 + + } |
Subsecond format identifiers. More... | |
+Functions | |
int | ms_nstime2time (nstime_t nstime, uint16_t *year, uint16_t *yday, uint8_t *hour, uint8_t *min, uint8_t *sec, uint32_t *nsec) |
Convert an nstime_t to individual date-time components. | |
char * | ms_nstime2timestr (nstime_t nstime, char *timestr, ms_timeformat_t timeformat, ms_subseconds_t subsecond) |
Convert an nstime_t to a time string. | |
DEPRECATED char * | ms_nstime2timestrz (nstime_t nstime, char *timestr, ms_timeformat_t timeformat, ms_subseconds_t subsecond) |
Convert an nstime_t to a time string with 'Z' suffix. | |
nstime_t | ms_time2nstime (int year, int yday, int hour, int min, int sec, uint32_t nsec) |
Convert specified date-time values to a high precision epoch time. | |
nstime_t | ms_timestr2nstime (const char *timestr) |
Convert a time string to a high precision epoch time. | |
nstime_t | ms_mdtimestr2nstime (const char *timestr) |
Convert a time string (year-month-day) to a high precision epoch time. | |
nstime_t | ms_seedtimestr2nstime (const char *seedtimestr) |
Convert an SEED-style (ordinate date, i.e. day-of-year) time string to a high precision epoch time. | |
int | ms_doy2md (int year, int yday, int *month, int *mday) |
Compute the month and day-of-month from a year and day-of-year. | |
int | ms_md2doy (int year, int month, int mday, int *yday) |
Compute the day-of-year from a year, month and day-of-month. | |
Definitions and functions for related to library time values.
+Internally the library uses an integer value to represent time as the number of nanoseconds since the Unix/POSIX epoch (Jan 1 1970).
+#define MS_HPTIME2NSTIME | +( | +X | ) | +(X) * (nstime_t) 1000 | +
Convert a hptime_t value (used by previous releases) to nstime_t.
+An HTPTIME/hptime_t value, used by libmseed major version <= 2, defines microsecond ticks. An NSTIME/nstime_t value, used by this version of the library, defines nanosecond ticks.
+ +#define MS_NSTIME2HPTIME | +( | +X | ) | +(X) / 1000 | +
Convert an nstime_t value to hptime_t (used by previous releases)
+An HTPTIME/hptime_t value, used by libmseed major version <= 2, defines microsecond ticks. An NSTIME/nstime_t value, used by this version of the library, defines nanosecond ticks.
+ +typedef int64_t nstime_t | +
libmseed time type, integer nanoseconds since the Unix/POSIX epoch (00:00:00 Thursday, 1 January 1970)
+This time scale can represent a range from before year 0 through mid-year 2262.
+ +enum ms_timeformat_t | +
Time format identifiers.
+Formats values:
"YYYY-MM-DDThh:mm:ss.sssssssss"
, ISO 8601 in month-day format"YYYY-MM-DDThh:mm:ss.sssssssss"
, ISO 8601 in month-day format with trailing Z"YYYY-MM-DD hh:mm:ss.sssssssss (doy)"
, ISOMONTHDAY with day-of-year"YYYY-MM-DD hh:mm:ss.sssssssss (doy)"
, ISOMONTHDAY with day-of-year and trailing Z"YYYY-MM-DD hh:mm:ss.sssssssss"
, same as ISOMONTHDAY with space separator"YYYY-MM-DD hh:mm:ss.sssssssss"
, same as ISOMONTHDAY with space separator and trailing Z"YYYY,DDD,hh:mm:ss.sssssssss"
, SEED day-of-year format"ssssssssss.sssssssss"
, Unix epoch value"sssssssssssssssssss"
, Nanosecond epoch value enum ms_subseconds_t | +
Subsecond format identifiers.
+Formats values:
+
|
+ +extern | +
Convert an nstime_t to individual date-time components.
+Each of the destination date-time are optional, pass NULL if the value is not desired.
+[in] | nstime | Time value to convert |
[out] | year | Year with century, like 2018 |
[out] | yday | Day of year, 1 - 366 |
[out] | hour | Hour, 0 - 23 |
[out] | min | Minute, 0 - 59 |
[out] | sec | Second, 0 - 60, where 60 is a leap second |
[out] | nsec | Nanoseconds, 0 - 999999999 |
0 | on success |
-1 | on error |
+
|
+ +extern | +
Convert an nstime_t to a time string.
+Create a time string representation of a high precision epoch time in ISO 8601 and SEED formats.
+The provided timestr buffer must have enough room for the resulting time string, a maximum of 36 characters + terminating NULL.
+The subseconds flag controls whether the subsecond portion of the time is included or not. The value of subseconds is ignored when the format is NANOSECONDEPOCH
. When non-zero subseconds are "trimmed" using these flags there is no rounding, instead it is simple truncation.
[in] | nstime | Time value to convert |
[out] | timestr | Buffer for ISO time string |
timeformat | Time string format, one of ms_timeformat_t | |
subseconds | Inclusion of subseconds, one of ms_subseconds_t |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert an nstime_t to a time string with 'Z' suffix.
+This function is a thin wrapper of ms_nstime2timestr
+[in] | nstime | Time value to convert |
[out] | timestr | Buffer for ISO time string |
timeformat | Time string format, one of ms_timeformat_t | |
subseconds | Inclusion of subseconds, one of ms_subseconds_t |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert specified date-time values to a high precision epoch time.
+[in] | year | Year with century, like 2018 |
[in] | yday | Day of year, 1 - 366 |
[in] | hour | Hour, 0 - 23 |
[in] | min | Minute, 0 - 59 |
[in] | sec | Second, 0 - 60, where 60 is a leap second |
[in] | nsec | Nanoseconds, 0 - 999999999 |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert a time string to a high precision epoch time.
+Detected time formats:
"YYYY-MM-DD[THH:MM:SS.FFFFFFFFF]"
"YYYY-DDD[THH:MM:SS.FFFFFFFFF]"
"YYYY,DDD[,HH,MM,SS,FFFFFFFFF]"
"YYYY"
"[+-]#########.#########"
Following determination of the format, non-epoch value conversion is performed by the ms_mdtimestr2nstime() and ms_seedtimestr2nstime() routines.
+Four-digit values are treated as a year, unless a sign [+-] is specified and then they are treated as epoch values. For consistency, a caller is recommened to always include a sign with epoch values.
+Note that this routine does some sanity checking of the time string contents, but does not perform robust date-time validation.
+[in] | timestr | Time string to convert |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Convert a time string (year-month-day) to a high precision epoch time.
+The time format expected is "YYYY[-MM-DD HH:MM:SS.FFFFFFFFF]", the delimiter can be a dash [-], comma[,], slash [/], colon [:], or period [.]. Additionally a 'T' or space may be used between the date and time fields. The fractional seconds ("FFFFFFFFF") must begin with a period [.] if present.
+The time string can be "short" in which case the omitted values are assumed to be zero (with the exception of month and day which are assumed to be 1). For example, specifying "YYYY-MM-DD" assumes HH, MM, SS and FFFF are 0. The year is required, otherwise there wouldn't be much for a date.
+[in] | timestr | Time string in ISO-style, month-day format |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Convert an SEED-style (ordinate date, i.e. day-of-year) time string to a high precision epoch time.
+The time format expected is "YYYY[,DDD,HH,MM,SS.FFFFFFFFF]", the delimiter can be a dash [-], comma [,], colon [:] or period [.]. Additionally a [T] or space may be used to seprate the day and hour fields. The fractional seconds ("FFFFFFFFF") must begin with a period [.] if present.
+The time string can be "short" in which case the omitted values are assumed to be zero (with the exception of DDD which is assumed to be 1): "YYYY,DDD,HH" assumes MM, SS and FFFFFFFF are 0. The year is required, otherwise there wouldn't be much for a date.
+[in] | seedtimestr | Time string in SEED-style, ordinal date format |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Compute the month and day-of-month from a year and day-of-year.
+[in] | year | Year in range 1000-2262 |
[in] | yday | Day of year in range 1-365 or 366 for leap year |
[out] | month | Month in range 1-12 |
[out] | mday | Day of month in range 1-31 |
0 | on success |
-1 | on error |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Compute the day-of-year from a year, month and day-of-month.
+[in] | year | Year in range 1000-2262 |
[in] | month | Month in range 1-12 |
[in] | mday | Day of month in range 1-31 (or appropriate last day) |
[out] | yday | Day of year in range 1-366 or 366 for leap year |
0 | on success |
-1 | on error |
MessageOnError - this function logs a message on error
+ +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
A container for continuous data. +More...
++Data Structures | |
struct | MS3TraceSeg |
Container for a continuous trace segment, linkable. More... | |
struct | MS3TraceID |
Container for a trace ID, linkable. More... | |
struct | MS3TraceList |
Container for a collection of continuous trace segment, linkable. More... | |
struct | MS3Tolerance |
Callback functions that return time and sample rate tolerances. More... | |
+Macros | |
+#define | MSTRACEID_SKIPLIST_HEIGHT 8 |
Maximum skip list height for MSTraceIDs. | |
#define | MS3Tolerance_INITIALIZER |
Initialializer for the tolerances MS3Tolerance. | |
#define | mstl3_addmsr(mstl, msr, splitversion, autoheal, flags, tolerance) mstl3_addmsr_recordptr (mstl, msr, NULL, splitversion, autoheal, flags, tolerance) |
Add a MS3Record to a MS3TraceList. | |
+Functions | |
MS3TraceList * | mstl3_init (MS3TraceList *mstl) |
Initialize a MS3TraceList container. | |
void | mstl3_free (MS3TraceList **ppmstl, int8_t freeprvtptr) |
Free all memory associated with a MS3TraceList. | |
MS3TraceID * | mstl3_findID (MS3TraceList *mstl, const char *sid, uint8_t pubversion, MS3TraceID **prev) |
Find matching MS3TraceID in a MS3TraceList. | |
MS3TraceSeg * | mstl3_addmsr_recordptr (MS3TraceList *mstl, const MS3Record *msr, MS3RecordPtr **pprecptr, int8_t splitversion, int8_t autoheal, uint32_t flags, const MS3Tolerance *tolerance) |
Add data coverage from an MS3Record to a MS3TraceList. | |
int64_t | mstl3_readbuffer (MS3TraceList **ppmstl, const char *buffer, uint64_t bufferlength, int8_t splitversion, uint32_t flags, const MS3Tolerance *tolerance, int8_t verbose) |
Parse miniSEED from a buffer and populate a MS3TraceList. | |
int64_t | mstl3_readbuffer_selection (MS3TraceList **ppmstl, const char *buffer, uint64_t bufferlength, int8_t splitversion, uint32_t flags, const MS3Tolerance *tolerance, const MS3Selections *selections, int8_t verbose) |
Parse miniSEED from a buffer and populate a MS3TraceList. | |
int64_t | mstl3_unpack_recordlist (MS3TraceID *id, MS3TraceSeg *seg, void *output, uint64_t outputsize, int8_t verbose) |
Unpack data samples in a Record List associated with a MS3TraceList. | |
int | mstl3_convertsamples (MS3TraceSeg *seg, char type, int8_t truncate) |
Convert the data samples associated with an MS3TraceSeg to another data type. | |
int | mstl3_resize_buffers (MS3TraceList *mstl) |
Resize data sample buffers of MS3TraceList to what is needed. | |
int64_t | mstl3_pack (MS3TraceList *mstl, void(*record_handler)(char *, int, void *), void *handlerdata, int reclen, int8_t encoding, int64_t *packedsamples, uint32_t flags, int8_t verbose, char *extra) |
Pack MS3TraceList data into miniSEED records. | |
void | mstl3_printtracelist (const MS3TraceList *mstl, ms_timeformat_t timeformat, int8_t details, int8_t gaps, int8_t versions) |
Print trace list summary information for a MS3TraceList. | |
void | mstl3_printsynclist (const MS3TraceList *mstl, const char *dccid, ms_subseconds_t subseconds) |
Print SYNC trace list summary information for a MS3TraceList. | |
void | mstl3_printgaplist (const MS3TraceList *mstl, ms_timeformat_t timeformat, double *mingap, double *maxgap) |
Print gap/overlap list summary information for a MS3TraceList. | |
A container for continuous data.
+Trace lists are a container to organize continuous segments of data. By combining miniSEED data records into trace lists, the time series is reconstructed and ready for processing or summarization.
+A trace list container starts with an MS3TraceList, which contains one or more MS3TraceID entries, which each contain one or more MS3TraceSeg entries. The MS3TraceID and MS3TraceSeg entries are easily traversed as linked structures.
+The overall structure is illustrated as:
struct MS3TraceSeg | +
Container for a continuous trace segment, linkable.
+Data Fields | ||
---|---|---|
+nstime_t | ++starttime | ++Time of first sample. |
+nstime_t | ++endtime | ++Time of last sample. |
+double | ++samprate | ++Nominal sample rate (Hz) |
+int64_t | ++samplecnt | ++Number of samples in trace coverage. |
+void * | ++datasamples | ++Data samples, numsamples of type sampletype. |
+uint64_t | ++datasize | ++Size of datasamples buffer in bytes. |
+int64_t | ++numsamples | ++Number of data samples in datasamples. |
+char | ++sampletype | ++Sample type code, see Sample Types. |
+void * | ++prvtptr | ++Private pointer for general use, unused by library. |
+struct MS3RecordList * | ++recordlist | ++List of pointers to records that contributed. |
+struct MS3TraceSeg * | ++prev | ++Pointer to previous segment. |
+struct MS3TraceSeg * | ++next | ++Pointer to next segment, NULL if the last. |
struct MS3TraceID | +
Container for a trace ID, linkable.
+Data Fields | ||
---|---|---|
+char | ++sid[LM_SIDLEN] | ++Source identifier as URN, max length LM_SIDLEN. |
+uint8_t | ++pubversion | ++Largest contributing publication version. |
+nstime_t | ++earliest | ++Time of earliest sample. |
+nstime_t | ++latest | ++Time of latest sample. |
+void * | ++prvtptr | ++Private pointer for general use, unused by library. |
+uint32_t | ++numsegments | ++Number of segments for this ID. |
+struct MS3TraceSeg * | ++first | ++Pointer to first of list of segments. |
+struct MS3TraceSeg * | ++last | ++Pointer to last of list of segments. |
+struct MS3TraceID * | ++next[MSTRACEID_SKIPLIST_HEIGHT] | ++Next trace ID at first pointer, NULL if the last. |
+uint8_t | ++height | ++Height of skip list at next. |
struct MS3TraceList | +
Container for a collection of continuous trace segment, linkable.
+Data Fields | ||
---|---|---|
+uint32_t | ++numtraceids | ++Number of traces IDs in list. |
+struct MS3TraceID | ++traces | ++Head node of trace skip list, first entry at traces.next[0]. |
+uint64_t | ++prngstate | ++INTERNAL: State for Pseudo RNG. |
#define MS3Tolerance_INITIALIZER | +
Initialializer for the tolerances MS3Tolerance.
+ +#define mstl3_addmsr | +( | +mstl, | +|
+ | + | msr, | +|
+ | + | splitversion, | +|
+ | + | autoheal, | +|
+ | + | flags, | +|
+ | + | tolerance ) mstl3_addmsr_recordptr (mstl, msr, NULL, splitversion, autoheal, flags, tolerance) | +
Add a MS3Record to a MS3TraceList.
+
+
|
+ +extern | +
Initialize a MS3TraceList container.
+A new MS3TraceList is allocated if needed. If the supplied MS3TraceList is not NULL it will be re-initialized and any associated memory will be freed including data at prvtptr pointers.
+[in] | mstl | MS3TraceList to reinitialize or NULL |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Free all memory associated with a MS3TraceList.
+The pointer to the target MS3TraceList will be set to NULL.
+[in] | ppmstl | Pointer-to-pointer to the target MS3TraceList to free |
[in] | freeprvtptr | If true, also free any data at the prvtptr members of MS3TraceID.prvtptr, MS3TraceSeg.prvtptr, and MS3RecordPtr.prvtptr (in MS3TraceSeg.recordlist) |
+
|
+ +extern | +
Find matching MS3TraceID in a MS3TraceList.
+Return the MS3TraceID matching the sid in the specified MS3TraceList.
+If prev is not NULL, set pointers to previous entries for the expected location of the trace ID. Useful for adding a new ID with mstl3_addID(), and should be set to NULL otherwise.
+[in] | mstl | Pointer to the MS3TraceList to search |
[in] | sid | Source ID to search for in the list |
[in] | pubversion | If non-zero, find the entry with this version |
[out] | prev | Pointers to previous entries in expected location or NULL |
+
|
+ +extern | +
Add data coverage from an MS3Record to a MS3TraceList.
+Searching the list for the appropriate MS3TraceID and MS3TraceSeg and either add data to existing entries or create new ones as needed.
+As this routine adds data to a trace list it constructs continuous time series, merging segments when possible. The tolerance pointer to a MS3Tolerance identifies function pointers that are expected to return time tolerace, in seconds, and sample rate tolerance, in Hertz, for the given MS3Record. If tolerance is NULL, or the function pointers it identifies are NULL, default tolerances will be used as follows: - Default time tolerance is 1/2 the sampling period - Default sample rate (sr) tolerance is abs(1‐sr1/sr2) < 0.0001
+In recommended usage, the splitversion flag is 0 and different publication versions of otherwise matching data are merged. If more than one version contributes to a given source identifer's segments, its MS3TraceID.pubversion will be the set to the largest contributing version. If the splitversion flag is 1 the publication versions will be kept separate with each version isolated in separate MS3TraceID entries.
+If the autoheal flag is true, extra processing is invoked to conjoin trace segments that fit together after the MS3Record coverage is added. For segments that are removed, any memory at the MS3TraceSeg.prvtptr will be freed.
+If the pprecptr is not NULL a Record List will be maintained for each segment. If the value of *pprecptr
is NULL, a new MS3RecordPtr will be allocated, otherwise the supplied structure will be updated. The MS3RecordPtr will be added to the appropriate record list and the values of MS3RecordPtr.msr and MS3RecordPtr.endtime will be set, all other fields should be set by the caller.
The lists are always maintained in a sorted order. An MS3TraceList is maintained with the MS3TraceID entries in ascending alphanumeric order of SID. If repeated SIDs are present due to splitting on publication version, they are maintained in order of ascending version. A MS3TraceID is always maintained with MS3TraceSeg entries in data time time order.
+[in] | mstl | Destination MS3TraceList to add data to |
[in] | msr | MS3Record containing the data to add to list |
[in] | pprecptr | Pointer to pointer to a MS3RecordPtr for Record List |
[in] | splitversion | Flag to control splitting of version/quality |
[in] | autoheal | Flag to control automatic merging of segments |
[in] | flags | Flags to control optional functionality (unused) |
[in] | tolerance | Tolerance function pointers as MS3Tolerance |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Parse miniSEED from a buffer and populate a MS3TraceList.
+For a full description of tolerance see mstl3_addmsr().
+If the MSF_UNPACKDATA flag is set in flags, the data samples will be unpacked. In most cases the caller probably wants this flag set, without it the trace list will merely be a list of channels.
+If the MSF_RECORDLIST flag is set in flags, a MS3RecordList will be built for each MS3TraceSeg. The MS3RecordPtr entries contain the location of the data record, bit flags, extra headers, etc.
+[in] | ppmstl | Pointer-to-point to destination MS3TraceList |
[in] | buffer | Source buffer to read miniSEED records from |
[in] | bufferlength | Maximum length of buffer |
[in] | splitversion | Flag to control splitting of version/quality |
[in] | flags | Flags to control parsing and optional functionality:
|
[in] | tolerance | Tolerance function pointers as MS3Tolerance |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Parse miniSEED from a buffer and populate a MS3TraceList.
+For a full description of tolerance see mstl3_addmsr().
+If the MSF_UNPACKDATA flag is set in flags, the data samples will be unpacked. In most cases the caller probably wants this flag set, without it the trace list will merely be a list of channels.
+If the MSF_RECORDLIST flag is set in flags, a MS3RecordList will be built for each MS3TraceSeg. The MS3RecordPtr entries contain the location of the data record, bit flags, extra headers, etc.
+If selections is not NULL, the MS3Selections will be used to limit what is returned to the caller. Any data not matching the selections will be skipped.
+[in] | ppmstl | Pointer-to-point to destination MS3TraceList |
[in] | buffer | Source buffer to read miniSEED records from |
[in] | bufferlength | Maximum length of buffer |
[in] | splitversion | Flag to control splitting of version/quality |
[in] | flags | Flags to control parsing and optional functionality:
|
[in] | tolerance | Tolerance function pointers as MS3Tolerance |
[in] | selections | Specify limits to which data should be returned, see Data Selections |
[in] | verbose | Controls verbosity, 0 means no diagnostic output |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Unpack data samples in a Record List associated with a MS3TraceList.
+Normally a record list is created calling by ms3_readtracelist() or mstl3_readbuffer() with the MSF_RECORDLIST flag.
+Unpacked data samples are written to the provided output buffer (up to outputsize bytes). If output is NULL, a buffer will be allocated and associated with the MS3TraceSeg, just as if the data were unpacked while constructing the Trace List.
+The sample type of the decoded data is stored at MS3TraceSeg.sampletype (i.e. seg->sampletype
).
A record pointer entry has multiple ways to identify the location of a record: memory buffer, open file (FILE *) or file name. This routine uses the first populated record location in the following order:
It would be unusual to build a record list outside of the library, but should that ever occur note that the record list is assumed to be in correct time order and represent a contiguous time series.
+[in] | id | MS3TraceID for relevant MS3TraceSeg |
[in] | seg | MS3TraceSeg with associated Record List to unpack |
[out] | output | Output buffer for data samples, can be NULL |
[in] | outputsize | Size of output buffer |
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
MessageOnError - this function logs a message on error
+ + +
+
|
+ +extern | +
Convert the data samples associated with an MS3TraceSeg to another data type.
+Text data samples cannot be converted, if supplied or requested an error will be returned.
+When converting float & double sample types to integer type a simple rounding is applied by adding 0.5 to the sample value before converting (truncating) to integer. This compensates for common machine representations of floating point values, e.g. "40.0" represented by "39.99999999".
+If the truncate flag is true (non-zero) data samples will be truncated to integers even if loss of sample precision is detected. If the truncate flag is false (zero) and loss of precision is detected an error is returned. Loss of precision is determined by testing that the difference between the floating point value and the (truncated) integer value is greater than 0.000001.
+[in] | seg | The target MS3TraceSeg to convert |
[in] | type | The desired data sample type:
|
[in] | truncate | Control truncation of floating point values to integers |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Resize data sample buffers of MS3TraceList to what is needed.
+This routine should only be used if pre-allocation of memory, via libmseed_prealloc_block_size, was enabled to allocate the buffers.
+[in] | mstl | MS3TraceList to resize buffers |
MessageOnError - this function logs a message on error
+ +
+
|
+ +extern | +
Pack MS3TraceList data into miniSEED records.
+The datasamples array, numsamples and starttime fields of each trace segment will be adjusted as data are packed unless the MSF_MAINTAINMSTL flag is specified in flags. If MSF_MAINTAINMSTL is specified a caller would also normally set the MSF_FLUSHDATA flag to pack all data in the trace list.
+Use as a rolling buffer to generate data records: The behavior of adjusting the trace list as data are packed is intended to allow using a MS3TraceList as an intermediate collection of data buffers to generate data records from an arbitrarily large data source, e.g. continuous data. In this pattern, data are added to a MS3TraceList and mstl3_pack() is called repeatedly. Data records are only produced if a complete record can be generated, which often leaves small amounts of data in each segment buffer. On completion or shutdown the caller usually makes a final call to mst3_pack() with the MSF_FLUSHDATA flag set to flush all data from the buffers.
+As each record is filled and finished they are passed to record_handler() which should expect 1) a char*
to the record, 2) the length of the record and 3) a pointer supplied by the original caller containing optional private data (handlerdata). It is the responsibility of record_handler() to process the record, the memory will be re-used or freed when record_handler() returns.
The requested encoding value is currently only used for integer data samples. The encoding is set automatially for text and floating point data samples as there is only a single encoding for them. A value of -1
can be used to request the default.
If extra is not NULL it is expected to contain extraheaders, a string containing (compact) JSON, that will be added to each output record.
+[in] | mstl | MS3TraceList containing data to pack |
[in] | record_handler() | Callback function called for each record |
[in] | handlerdata | A pointer that will be provided to the record_handler() |
[in] | reclen | Maximum record length to create |
[in] | encoding | Encoding for data samples, see msr3_pack() |
[out] | packedsamples | The number of samples packed, returned to caller |
[in] | flags | Bit flags to control packing:
|
[in] | verbose | Controls logging verbosity, 0 is no diagnostic output |
[in] | extra | If not NULL, add this buffer of extra headers to all records |
MessageOnError - this function logs a message on error
+
+
|
+ +extern | +
Print trace list summary information for a MS3TraceList.
+By default only print the source ID, starttime and endtime for each trace. If details is greater than 0 include the sample rate, number of samples and a total trace count. If gaps is greater than 0 and the previous trace matches (SID & samprate) include the gap between the endtime of the last trace and the starttime of the current trace.
+[in] | mstl | MS3TraceList to print |
[in] | timeformat | Time string format, one of ms_timeformat_t |
[in] | details | Flag to control inclusion of more details |
[in] | gaps | Flag to control inclusion of gap/overlap between segments |
[in] | versions | Flag to control inclusion of publication version on SourceIDs |
+
|
+ +extern | +
Print SYNC trace list summary information for a MS3TraceList.
+The SYNC header line will be created using the supplied dccid, if the pointer is NULL the string "DCC" will be used instead.
+If the subsecond flag is true the segment start and end times will include subsecond precision, otherwise they will be truncated to integer seconds.
+[in] | mstl | MS3TraceList to print |
[in] | dccid | The DCC identifier to include in the output |
[in] | subseconds | Inclusion of subseconds, one of ms_subseconds_t |
+
|
+ +extern | +
Print gap/overlap list summary information for a MS3TraceList.
+Overlaps are printed as negative gaps.
+If mingap and maxgap are not NULL their values will be enforced and only gaps/overlaps matching their implied criteria will be printed.
+[in] | mstl | MS3TraceList to print |
[in] | timeformat | Time string format, one of ms_timeformat_t |
[in] | mingap | Minimum gap to print in seconds (pointer to value) |
[in] | maxgap | Maximum gap to print in seconds (pointer to value) |
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
General utilities. +More...
++Functions | |
uint8_t | ms_samplesize (char sampletype) |
Determine data sample size for each type. | |
int | ms_encoding_sizetype (uint8_t encoding, uint8_t *samplesize, char *sampletype) |
Return sample size and/or type for given encoding value. | |
const char * | ms_encodingstr (uint8_t encoding) |
Descriptive string for data encodings. | |
const char * | ms_errorstr (int errorcode) |
Descriptive string for library Return codes. | |
nstime_t | ms_sampletime (nstime_t time, int64_t offset, double samprate) |
Calculate the time of a sample in an array. | |
double | ms_dabs (double val) |
Determine the absolute value of an input double. | |
int | ms_bigendianhost (void) |
Runtime test for host endianess. | |
int64_t | lmp_ftell64 (FILE *stream) |
int | lmp_fseek64 (FILE *stream, int64_t offset, int whence) |
uint64_t | lmp_nanosleep (uint64_t nanoseconds) |
uint32_t | ms_crc32c (const uint8_t *input, int length, uint32_t previousCRC32C) |
General utilities.
+
+
|
+ +extern | +
Determine data sample size for each type.
+[in] | sampletype | Library sample type code:
|
+
|
+ +extern | +
Return sample size and/or type for given encoding value.
+Determine the decoded sample size and/or type based on data encoding. The samplesize and sampletype values will only be set if not NULL, allowing lookup of either value or both.
+[in] | encoding | Data sample encoding code |
[out] | samplesize | Size of sample, pointer that will be set |
[out] | sampletype | Sample type, pointer to char that will be set |
+
|
+ +extern | +
Descriptive string for data encodings.
+[in] | encoding | Data sample encoding code |
+
|
+ +extern | +
Descriptive string for library Return codes.
+[in] | errorcode | Library error code |
+
|
+ +extern | +
Calculate the time of a sample in an array.
+Given a time, sample offset and sample rate/period calculate the time of the sample at the offset.
+If samprate is negative the negated value is interpreted as a sample period in seconds, otherwise the value is assumed to be a sample rate in Hertz.
+If leap seconds have been loaded into the internal library list: when a time span, from start to offset, completely contains a leap second, starts before and ends after, the calculated sample time will be adjusted (reduced) by one second.
[in] | time | Time value for first sample in array |
[in] | offset | Offset of sample to calculate time of |
[in] | samprate | Sample rate (when positive) or period (when negative) |
+
|
+ +extern | +
Determine the absolute value of an input double.
+Actually just test if the input double is positive multiplying by -1.0 if not and return it.
+[in] | val | Value for which to determine absolute value |
+
|
+ +externinline | +
Runtime test for host endianess.
+
+
|
+ +extern | +
Portable version of POSIX ftello() to get file position in large files
+ +
+
|
+ +extern | +
Portable version of POSIX fseeko() to set position in large files
+ +
+
|
+ +extern | +
Portable version of POSIX nanosleep() to sleep for nanoseconds
+ +
+
|
+ +extern | +
Return CRC32C value of supplied buffer, with optional starting CRC32C value
+ +
+ libmseed 3.1.1
+
+ The miniSEED data format library
+ |
+
The miniSEED library provides a framework for manipulation of miniSEED records, a format commonly used for seismological time series and related data. The library includes the functionality to read and write data records, in addition to reconstructing time series from multiple records.
+The library should work in Unix-like, Windows and potentially other environments.
+The Tutorial contains an overview of basic usage and examples to get you going.
+The Capabilities page provides an overview the data format fundamentals and capabilities of the library.
+The releases area contains release versions.
+For installation instructions see the INSTALL file.
+Please report issues to the project.
+If you would like to contribute to the project please file Pull Requests and/or create issues for discussion at the libmseed project.
+A Guide for porting from earlier libmseed versions is available for developer porting software that previously used version 2 of the library.
+Releases are versioned using Semantic Versioning.
+Numerous improvements have been incorporated based on feedback and patches submitted by others. Individual acknowlegements are included in the ChangeLog and/or commit messages. Contributions are welcome and greatly appreciated.
+This library also uses code bits published in the public domain and acknowledgement is included in the code whenever possible.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+Copyright (C) 2024 Chad Trabant, EarthScope Data Services
+Documentation last generated 2024-02-12
+