mst_convertsamples man page

mst_convertsamples — Convert data samples between numeric types


#include <libmseed.h>

int  mst_convertsamples ( MSTrace *mst, char type, flag truncate);

int  mstl_convertsamples ( MSTraceSeg *seg, char type, flag truncate);


mst_convertsamples and mst_convertsamples convert any data samples associated with an MSTrace or MSTraceSeg to a specified type.

The routines can convert between 32-bit integers (type i), 32-bit floats (type f) and 64-bit doubles (type d).

When converting float and 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 data samples will be truncated to integers even if loss of sample precision is detected.  If the truncate flag is false (0) 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.

ASCII data samples (type a) cannot be converted, if supplied or requested an error will be returned.

Return Values

mst_convertsamples and mstl_convertsamples return 0 on success and -1 on error.

See Also



Chad Trabant
IRIS Data Management Center


2013/10/01 Libmseed API