Skip to content

Commit f2cc114

Browse files
Update libmseed to v3.1.2
1 parent 75f2c10 commit f2cc114

20 files changed

+145
-125
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2024.148: 4.2.1
2+
- Update libmseed to v3.1.2.
3+
14
2024.024: 4.2
25
- Update libmseed to v3.1.1.
36

libmseed/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2024.148: 3.1.2
2+
- Update yyjson to v0.9.0.
3+
- Simplify mstl3_addmsr_recordptr() a bit.
4+
5+
2024.146:
6+
- Replace ms_dabs() with macro to use system fabs(), document as deprecated.
7+
- Add CRC values to diagnostic message when header values does not match calculated.
8+
9+
2024.137:
10+
- Add msr3_nsperiod() to calculate the sample period in nanoseconds.
11+
- Add tests for msr3 utility functions.
12+
13+
2024.106:
14+
- When writing v2 derive the quality code from the publication version when the
15+
extra-header "/FDSN/DataQuality" is not present. Use quality indicator 'D' when
16+
the publication version cannot be mapped, e.g. > 4.
17+
118
2024.024: 3.1.1
219
- Change library compatibility version in Makefile to MAJOR.1.0, as this is now
320
incompatible with the x.0.0 releases.

libmseed/doc/DoxygenLayout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<tab type="namespacelist" visible="yes" title="" intro=""/>
1010
<tab type="namespacemembers" visible="yes" title="" intro=""/>
1111
</tab>
12-
<tab type="classes" visible="no" title="">
12+
<tab type="classes" visible="yes" title="">
1313
<tab type="classlist" visible="yes" title="" intro=""/>
1414
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
1515
<tab type="hierarchy" visible="yes" title="" intro=""/>

libmseed/genutils.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,25 +1671,6 @@ ms_sampletime (nstime_t time, int64_t offset, double samprate)
16711671
} /* End of ms_sampletime() */
16721672

16731673

1674-
/**********************************************************************/ /**
1675-
* @brief Determine the absolute value of an input double
1676-
*
1677-
* Actually just test if the input double is positive multiplying by
1678-
* -1.0 if not and return it.
1679-
*
1680-
* @param[in] val Value for which to determine absolute value
1681-
*
1682-
* @returns the positive value of input double.
1683-
***************************************************************************/
1684-
double
1685-
ms_dabs (double val)
1686-
{
1687-
if (val < 0.0)
1688-
val *= -1.0;
1689-
return val;
1690-
} /* End of ms_dabs() */
1691-
1692-
16931674
/**********************************************************************/ /**
16941675
* @brief Runtime test for host endianess
16951676
* @returns 0 if the host is little endian, otherwise 1.

libmseed/libmseed.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ EXPORTS
9292
ms_encodingstr
9393
ms_errorstr
9494
ms_sampletime
95-
ms_dabs
9695
ms_bigendianhost
9796
ms_crc32c
9897
leapsecondlist

libmseed/libmseed.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
extern "C" {
2929
#endif
3030

31-
#define LIBMSEED_VERSION "3.1.1" //!< Library version
32-
#define LIBMSEED_RELEASE "2024.024" //!< Library release date
31+
#define LIBMSEED_VERSION "3.1.2" //!< Library version
32+
#define LIBMSEED_RELEASE "2024.148" //!< Library release date
3333

3434
/** @defgroup io-functions File and URL I/O */
3535
/** @defgroup miniseed-record Record Handling */
@@ -63,6 +63,7 @@ extern "C" {
6363
#include <time.h>
6464
#include <string.h>
6565
#include <ctype.h>
66+
#include <math.h>
6667

6768
/** @def PRIsize_t
6869
@brief A printf() macro for portably printing size_t values */
@@ -140,7 +141,7 @@ extern "C" {
140141

141142
/** @def MS_ISRATETOLERABLE
142143
@brief Macro to test default sample rate tolerance: abs(1-sr1/sr2) < 0.0001 */
143-
#define MS_ISRATETOLERABLE(A,B) (ms_dabs (1.0 - ((A) / (B))) < 0.0001)
144+
#define MS_ISRATETOLERABLE(A,B) (fabs (1.0 - ((A) / (B))) < 0.0001)
144145

145146
/** @def MS2_ISDATAINDICATOR
146147
@brief Macro to test a character for miniSEED 2.x data record/quality indicators */
@@ -409,6 +410,7 @@ extern nstime_t msr3_endtime (const MS3Record *msr);
409410
extern void msr3_print (const MS3Record *msr, int8_t details);
410411
extern int msr3_resize_buffer (MS3Record *msr);
411412
extern double msr3_sampratehz (const MS3Record *msr);
413+
extern nstime_t msr3_nsperiod (const MS3Record *msr);
412414
extern double msr3_host_latency (const MS3Record *msr);
413415

414416
extern int64_t ms3_detect (const char *record, uint64_t recbuflen, uint8_t *formatversion);
@@ -1252,9 +1254,11 @@ extern const char *ms_encodingstr (uint8_t encoding);
12521254
extern const char *ms_errorstr (int errorcode);
12531255

12541256
extern nstime_t ms_sampletime (nstime_t time, int64_t offset, double samprate);
1255-
extern double ms_dabs (double val);
12561257
extern int ms_bigendianhost (void);
12571258

1259+
/** DEPRECATED legacy implementation of fabs(), now a macro */
1260+
#define ms_dabs(val) fabs(val)
1261+
12581262
/** Portable version of POSIX ftello() to get file position in large files */
12591263
extern int64_t lmp_ftell64 (FILE *stream);
12601264
/** Portable version of POSIX fseeko() to set position in large files */

libmseed/msrutils.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,29 @@ msr3_sampratehz (const MS3Record *msr)
355355
return msr->samprate;
356356
} /* End of msr3_sampratehz() */
357357

358+
/**********************************************************************/ /**
359+
* @brief Calculate sample period in nanoseconds/sample for a given ::MS3Record
360+
*
361+
* @param[in] msr ::MS3Record to calculate sample period for
362+
*
363+
* @returns Return sample period in nanoseconds (nanoseconds per sample)
364+
***************************************************************************/
365+
inline nstime_t
366+
msr3_nsperiod (const MS3Record *msr)
367+
{
368+
if (!msr)
369+
return 0;
370+
371+
/* Calculate sample period from sample rate or period.
372+
* The value is rounded by adding 0.5 before truncation to an integer. */
373+
if (msr->samprate > 0.0)
374+
return (nstime_t)(NSTMODULUS / msr->samprate + 0.5); /* samples/second */
375+
else if (msr->samprate < 0.0)
376+
return (nstime_t)(NSTMODULUS * -msr->samprate + 0.5); /* period or seconds/sample */
377+
378+
return 0;
379+
} /* End of msr3_nsperiod() */
380+
358381
/**********************************************************************/ /**
359382
* @brief Calculate data latency based on the host time
360383
*

libmseed/pack.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,31 @@ msr3_pack_header2 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_
988988
/* Build fixed header */
989989
memcpy (pMS2FSDH_SEQNUM (record), "000000", 6);
990990

991+
/* Use DataQuality indicator in extra headers if present */
991992
if (yyjson_ptr_get_str (ehroot, "/FDSN/DataQuality", &header_string) &&
992993
MS2_ISDATAINDICATOR (header_string[0]))
994+
{
993995
*pMS2FSDH_DATAQUALITY (record) = header_string[0];
996+
}
997+
/* Otherwise map publication version, defaulting to 'D' */
994998
else
995-
*pMS2FSDH_DATAQUALITY (record) = 'D';
999+
{
1000+
switch (msr->pubversion)
1001+
{
1002+
case 1:
1003+
*pMS2FSDH_DATAQUALITY (record) = 'R';
1004+
break;
1005+
case 3:
1006+
*pMS2FSDH_DATAQUALITY (record) = 'Q';
1007+
break;
1008+
case 4:
1009+
*pMS2FSDH_DATAQUALITY (record) = 'M';
1010+
break;
1011+
default:
1012+
*pMS2FSDH_DATAQUALITY (record) = 'D';
1013+
break;
1014+
}
1015+
}
9961016

9971017
*pMS2FSDH_RESERVED (record) = ' ';
9981018
ms_strncpopen (pMS2FSDH_STATION (record), station, 5);
@@ -1122,7 +1142,7 @@ msr3_pack_header2 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_
11221142
}
11231143

11241144
/* Add Blockette 100 if sample rate is not well represented by factor/multiplier */
1125-
if (ms_dabs(msr3_sampratehz(msr) - ms_nomsamprate(factor, multiplier)) > 0.0001)
1145+
if (fabs(msr3_sampratehz(msr) - ms_nomsamprate(factor, multiplier)) > 0.0001)
11261146
{
11271147
*next_blockette = HO2u ((uint16_t)written, swapflag);
11281148
next_blockette = pMS2B100_NEXT (record + written);
@@ -1825,7 +1845,7 @@ ms_ratapprox (double real, int *num, int *den, int maxval, double precision)
18251845
if (!pos)
18261846
*num = -*num;
18271847

1828-
while (ms_dabs (preal - (double)Aj / (double)Bj) > precision &&
1848+
while (fabs (preal - (double)Aj / (double)Bj) > precision &&
18291849
Aj < maxval && Bj < maxval)
18301850
{
18311851
Aj2 = Aj1;
@@ -1926,7 +1946,7 @@ ms_reduce_rate (double samprate, int16_t *factor1, int16_t *factor2)
19261946
int32_t diff;
19271947

19281948
/* Handle case of integer sample values. */
1929-
if (ms_dabs (samprate - intsamprate) < 0.0000001)
1949+
if (fabs (samprate - intsamprate) < 0.0000001)
19301950
{
19311951
/* If integer sample rate is less than range of 16-bit int set it directly */
19321952
if (intsamprate <= 32767)
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)