Skip to content

Commit

Permalink
Update libmseed to v3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
chad-earthscope committed May 27, 2024
1 parent 75f2c10 commit f2cc114
Show file tree
Hide file tree
Showing 20 changed files with 145 additions and 125 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024.148: 4.2.1
- Update libmseed to v3.1.2.

2024.024: 4.2
- Update libmseed to v3.1.1.

Expand Down
17 changes: 17 additions & 0 deletions libmseed/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2024.148: 3.1.2
- Update yyjson to v0.9.0.
- Simplify mstl3_addmsr_recordptr() a bit.

2024.146:
- Replace ms_dabs() with macro to use system fabs(), document as deprecated.
- Add CRC values to diagnostic message when header values does not match calculated.

2024.137:
- Add msr3_nsperiod() to calculate the sample period in nanoseconds.
- Add tests for msr3 utility functions.

2024.106:
- When writing v2 derive the quality code from the publication version when the
extra-header "/FDSN/DataQuality" is not present. Use quality indicator 'D' when
the publication version cannot be mapped, e.g. > 4.

2024.024: 3.1.1
- Change library compatibility version in Makefile to MAJOR.1.0, as this is now
incompatible with the x.0.0 releases.
Expand Down
2 changes: 1 addition & 1 deletion libmseed/doc/DoxygenLayout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<tab type="namespacelist" visible="yes" title="" intro=""/>
<tab type="namespacemembers" visible="yes" title="" intro=""/>
</tab>
<tab type="classes" visible="no" title="">
<tab type="classes" visible="yes" title="">
<tab type="classlist" visible="yes" title="" intro=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title="" intro=""/>
Expand Down
19 changes: 0 additions & 19 deletions libmseed/genutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,25 +1671,6 @@ ms_sampletime (nstime_t time, int64_t offset, double samprate)
} /* End of ms_sampletime() */


/**********************************************************************/ /**
* @brief 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.
*
* @param[in] val Value for which to determine absolute value
*
* @returns the positive value of input double.
***************************************************************************/
double
ms_dabs (double val)
{
if (val < 0.0)
val *= -1.0;
return val;
} /* End of ms_dabs() */


/**********************************************************************/ /**
* @brief Runtime test for host endianess
* @returns 0 if the host is little endian, otherwise 1.
Expand Down
1 change: 0 additions & 1 deletion libmseed/libmseed.def
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ EXPORTS
ms_encodingstr
ms_errorstr
ms_sampletime
ms_dabs
ms_bigendianhost
ms_crc32c
leapsecondlist
Expand Down
12 changes: 8 additions & 4 deletions libmseed/libmseed.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
extern "C" {
#endif

#define LIBMSEED_VERSION "3.1.1" //!< Library version
#define LIBMSEED_RELEASE "2024.024" //!< Library release date
#define LIBMSEED_VERSION "3.1.2" //!< Library version
#define LIBMSEED_RELEASE "2024.148" //!< Library release date

/** @defgroup io-functions File and URL I/O */
/** @defgroup miniseed-record Record Handling */
Expand Down Expand Up @@ -63,6 +63,7 @@ extern "C" {
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

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

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

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

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

extern nstime_t ms_sampletime (nstime_t time, int64_t offset, double samprate);
extern double ms_dabs (double val);
extern int ms_bigendianhost (void);

/** DEPRECATED legacy implementation of fabs(), now a macro */
#define ms_dabs(val) fabs(val)

/** Portable version of POSIX ftello() to get file position in large files */
extern int64_t lmp_ftell64 (FILE *stream);
/** Portable version of POSIX fseeko() to set position in large files */
Expand Down
23 changes: 23 additions & 0 deletions libmseed/msrutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,29 @@ msr3_sampratehz (const MS3Record *msr)
return msr->samprate;
} /* End of msr3_sampratehz() */

/**********************************************************************/ /**
* @brief Calculate sample period in nanoseconds/sample for a given ::MS3Record
*
* @param[in] msr ::MS3Record to calculate sample period for
*
* @returns Return sample period in nanoseconds (nanoseconds per sample)
***************************************************************************/
inline nstime_t
msr3_nsperiod (const MS3Record *msr)
{
if (!msr)
return 0;

/* Calculate sample period from sample rate or period.
* The value is rounded by adding 0.5 before truncation to an integer. */
if (msr->samprate > 0.0)
return (nstime_t)(NSTMODULUS / msr->samprate + 0.5); /* samples/second */
else if (msr->samprate < 0.0)
return (nstime_t)(NSTMODULUS * -msr->samprate + 0.5); /* period or seconds/sample */

return 0;
} /* End of msr3_nsperiod() */

/**********************************************************************/ /**
* @brief Calculate data latency based on the host time
*
Expand Down
28 changes: 24 additions & 4 deletions libmseed/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,31 @@ msr3_pack_header2 (const MS3Record *msr, char *record, uint32_t recbuflen, int8_
/* Build fixed header */
memcpy (pMS2FSDH_SEQNUM (record), "000000", 6);

/* Use DataQuality indicator in extra headers if present */
if (yyjson_ptr_get_str (ehroot, "/FDSN/DataQuality", &header_string) &&
MS2_ISDATAINDICATOR (header_string[0]))
{
*pMS2FSDH_DATAQUALITY (record) = header_string[0];
}
/* Otherwise map publication version, defaulting to 'D' */
else
*pMS2FSDH_DATAQUALITY (record) = 'D';
{
switch (msr->pubversion)
{
case 1:
*pMS2FSDH_DATAQUALITY (record) = 'R';
break;
case 3:
*pMS2FSDH_DATAQUALITY (record) = 'Q';
break;
case 4:
*pMS2FSDH_DATAQUALITY (record) = 'M';
break;
default:
*pMS2FSDH_DATAQUALITY (record) = 'D';
break;
}
}

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

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

while (ms_dabs (preal - (double)Aj / (double)Bj) > precision &&
while (fabs (preal - (double)Aj / (double)Bj) > precision &&
Aj < maxval && Bj < maxval)
{
Aj2 = Aj1;
Expand Down Expand Up @@ -1926,7 +1946,7 @@ ms_reduce_rate (double samprate, int16_t *factor1, int16_t *factor2)
int32_t diff;

/* Handle case of integer sample values. */
if (ms_dabs (samprate - intsamprate) < 0.0000001)
if (fabs (samprate - intsamprate) < 0.0000001)
{
/* If integer sample rate is less than range of 16-bit int set it directly */
if (intsamprate <= 32767)
Expand Down
Binary file modified libmseed/test/data/reference-testdata-float32.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-float64.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-int16.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-int32.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-steim1.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-steim2.mseed2
Binary file not shown.
Binary file modified libmseed/test/data/reference-testdata-text.mseed2
Binary file not shown.
Loading

0 comments on commit f2cc114

Please sign in to comment.