Commit 7d3f1ed7 authored by thomas.forbriger's avatar thomas.forbriger

libdatrwxx [MERGE][FIX]: fix usec header field issue in MiniSEED

Merge branch '25-libdatrwxx-miniseed-consistency-checks'

- when reading the [1001] Data Extension Blockette the usec field may carry a
  sign (see SEED V2.4 Manual, August 2012, page 124)
- introduce a consistency check for usec being in the specified range
parents 268e41b6 0d001823
......@@ -33,6 +33,7 @@
* - 08/05/2014 V1.3 Add field for timing tolerance value
* - 22/07/2014 V1.4 thof: support new format modifier: estimateNframes
* - 05/07/2016 V1.5 thof: provide consistency check control flags
* - 12/07/2016 V1.6 thof: provide usec consistency check
*
* ============================================================================
*/
......@@ -41,7 +42,7 @@
#ifndef DATRW_MSEED_H_VERSION
#define DATRW_MSEED_H_VERSION \
"DATRW_MSEED_H V1.5"
"DATRW_MSEED_H V1.6"
#include<datrwxx/datread.h>
......@@ -84,7 +85,8 @@ namespace datrw {
ConsistencyChecks(const bool& fatal, const bool& check):
nframes(fatal, check),
nsamples(fatal, check),
data(fatal, check) { }
data(fatal, check),
usec(fatal, check) { }
/*! \brief Check for consistent number of frames.
*
* Number of frames to be expected is provided in the header in
......@@ -116,6 +118,19 @@ namespace datrw {
* first data frame of the record.
*/
ConsistencyCheckControl data;
/*! \brief Check for usec field being in specified range.
*
* On page 124 of "SEED Reference Manual, Standard for the Exchange of
* Earthquake Data, SEED Format Version 2.4, August, 2012" with
* respect to [1001] Data Extension Blockette (8 bytes):
*
* > field 4: BYTE: µsec has the data start time down to the
* > microsecond. The SEED format handles down to 100µsecs. This
* > field is an offset from that value. The recommended value is
* > from -50 to +49µsecs. At the users option, this value may be
* > from 0 to +99µsecs.
*/
ConsistencyCheckControl usec;
}; // struct ConsistencyChecks
/*----------------------------------------------------------------------*/
......
......@@ -37,11 +37,12 @@
* - 22/07/2014 V1.6 thof: support new format modifier: estimateNframes
* - 05/07/2016 V1.7 thof: evaluate format modifiers to adjust
* consistency checks
* - 12/07/2016 V1.8 thof: provide usec consistency check
*
* ============================================================================
*/
#define DATRW_IMSEEDSTREAM_CC_VERSION \
"DATRW_IMSEEDSTREAM_CC V1.7"
"DATRW_IMSEEDSTREAM_CC V1.8"
#include <datrwxx/util.h>
#include <datrwxx/mseed.h>
......@@ -107,6 +108,8 @@ namespace datrw {
=!(all||(checks.find(mseed::key::nsamples)!=std::string::npos));
Mchecks.data.fatal
=!(all||(checks.find(mseed::key::data)!=std::string::npos));
Mchecks.usec.fatal
=!(all||(checks.find(mseed::key::usec)!=std::string::npos));
}
// note: flags have opposite meaning compared to subformat flags
......@@ -120,6 +123,8 @@ namespace datrw {
=!(all||(checks.find(mseed::key::nsamples)!=std::string::npos));
Mchecks.data.docheck
=!(all||(checks.find(mseed::key::data)!=std::string::npos));
Mchecks.usec.docheck
=!(all||(checks.find(mseed::key::usec)!=std::string::npos));
}
DATRW_assert_modifiers_are_recognized(subformat,
......
......@@ -27,11 +27,12 @@
*
* REVISIONS and CHANGES
* - 05/07/2016 V1.0 Thomas Forbriger
* - 12/07/2016 V1.1 add usec consistency check
*
* ============================================================================
*/
#define DATRW_MSEED_KEYWORDS_CC_VERSION \
"DATRW_MSEED_KEYWORDS_CC V1.0"
"DATRW_MSEED_KEYWORDS_CC V1.1"
#include <datrwxx/mseed_keywords.h>
......@@ -48,6 +49,7 @@ namespace datrw {
const char* const key::nframes="nframes";
const char* const key::nsamples="nsamples";
const char* const key::data="data";
const char* const key::usec="usec";
const char* const key::all="all";
} // namespace mseed
......
......@@ -27,6 +27,7 @@
*
* REVISIONS and CHANGES
* - 05/07/2016 V1.0 Thomas Forbriger
* - 12/07/2016 V1.1 add usec consistency check
*
* ============================================================================
*/
......@@ -35,7 +36,7 @@
#ifndef DATRW_MSEED_KEYWORDS_H_VERSION
#define DATRW_MSEED_KEYWORDS_H_VERSION \
"DATRW_MSEED_KEYWORDS_H V1.0"
"DATRW_MSEED_KEYWORDS_H V1.1"
namespace datrw {
......@@ -64,6 +65,7 @@ namespace datrw {
extern const char* const nframes;
extern const char* const nsamples;
extern const char* const data;
extern const char* const usec;
extern const char* const all;
/**@}*/
......
......@@ -41,11 +41,13 @@
* - make correct use of new DATRW_nonfatal_assert
* - 11/07/2016 V1.4 thof:
* - improve error messages in consistency checks
* - 12/07/2016 V1.5 thof:
* - add consistency check for usec value
*
* ============================================================================
*/
#define DATRW_MSEEDREAD_MSEEDRECORD_READ_CC_VERSION \
"DATRW_MSEEDREAD_MSEEDRECORD_READ_CC V1.4"
"DATRW_MSEEDREAD_MSEEDRECORD_READ_CC V1.5"
#include <string>
#include <cstring>
......@@ -243,6 +245,36 @@ namespace datrw {
+ std::string(key::skipcheck) + "\"\n"
"if you like to ignore this inconsistency");
/* Check for usec field being in specified range
* ---------------------------------------------
*
* On page 124 of "SEED Reference Manual, Standard for the Exchange of
* Earthquake Data, SEED Format Version 2.4, August, 2012" with
* respect to [1001] Data Extension Blockette (8 bytes):
*
* > field 4: BYTE: µsec has the data start time down to the
* > microsecond. The SEED format handles down to 100µsecs. This
* > field is an offset from that value. The recommended value is
* > from -50 to +49µsecs. At the users option, this value may be
* > from 0 to +99µsecs.
*/
if (Mhasblockette1001 && Mchecks.usec.docheck)
{
DATRW_nonfatal_assert(Mdebug.inconsistencies_are_not_fatal
|| (!Mchecks.usec.fatal),
(Mblockette1001.iusec()>=-50)
&& (Mblockette1001.iusec()<=99),
"usec-value in MiniSEED record is out of specified range\n"
"consistency check \"" << key::nsamples << "\" complains:\n"
"usec-value in [1001] Data Extension Blockette: "
<< DATRW_value(Mblockette1001.iusec()) << "\n"
"specified range SEED Reference Manual, "
"Version 2.4, August, 2012 (page 124):\n"
"The recommended value is from -50 to +49 usecs.\n"
"At the users option, this value may be from 0 to +99 usecs.\n"
<< CHintToFormatModifiers);
}
/* Check for consistent number of samples.
* ---------------------------------------
*
......
......@@ -32,6 +32,11 @@
* implementation dependent size
* - 09/05/2006 V1.2 introduced Steim 2 code
* SteimFrame now does all that Steim1Reader did
* - 12/07/2016 V1.3 thof:
* - fix [1001] Data Extension Blockette
* field 4 (usec) explicitely is signed an can be
* negative (see SEED V2.4 Manual, August 2012, page
* 124)
*
* ============================================================================
*/
......@@ -40,7 +45,7 @@
#ifndef DATRW_SEEDSTRUCTS_H_VERSION
#define DATRW_SEEDSTRUCTS_H_VERSION \
"DATRW_SEEDSTRUCTS_H V1.2"
"DATRW_SEEDSTRUCTS_H V1.3"
namespace datrw {
......@@ -373,10 +378,10 @@ namespace datrw {
void swap();
DataRecordBlocketteHeader blocketteheader;
unsigned char tquality; //!< Timing quality
unsigned char usec; //!< microseconds
char usec; //!< microseconds
unsigned char reserved; //!< reserved
unsigned char fcount; //!< frame count
unsigned int iusec() const { return(this->usec); }
int iusec() const { return(this->usec); }
unsigned int itquality() const { return(this->tquality); }
unsigned int ifcount() const { return(this->fcount); }
}; // DataExtensionBlockette
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment