Big effort of decoding a MiniSEED record.
Read all blocks belonging to one record in sequence. Extract all frames in all blocks in sequence (within the outer loop of reading blocks). Reading stops, if all blocks of the record are read or all frames (as indicated in the header of the record) are extracted are all expected samples are extracted. Extraction of samples stops when all samples (as indicated by the record header) are extracted.
It may appear in normal operation that the capacity of a data record is not completely used to store samples.
107 int nblocks=reclen/block.bytesize();
111 bool filetellsnframes=
false;
114 filetellsnframes=
true;
119 "unreasonable number of frames (" 121 ") given in blockette1001\n" 122 <<
" consider to use format modifier \"estimateNframes\"");
128 "ERROR (reading MiniSEED record): " 129 "Can only decode Steim (1) or Steim (2) compression");
137 bool waitingforxn=
true;
142 while ((iblock <= nblocks) &&
144 ((iframe <
nframes) || (!filetellsnframes)))
148 while (pdata <
int(block.bytesize()) &&
150 ((iframe <
nframes) || (!filetellsnframes)))
152 SEED::SteimFrame* pframe;
156 pframe=
new SEED::Steim1Frame(block.block(pdata), doswap);
159 pframe=
new SEED::Steim2Frame(block.block(pdata), doswap);
163 "compression format not supported");
166 SEED::SteimFrame& rframe(*pframe);
170 "ERROR (reading MiniSEED record): " 175 "ERROR (reading MiniSEED record): " 191 while (rframe.valid() && (isample <
nsamples))
195 sum += rframe.diff();
206 if (iblock < nblocks)
212 "input stream is bad!");
221 while (iblock < nblocks)
228 "input stream is bad!");
242 const std::string CHintToFormatModifiers(
243 "consider to use format modifiers \"" 246 "if you like to ignore this inconsistency");
267 "usec-value in MiniSEED record is out of specified range\n" 269 "usec-value in [1001] Data Extension Blockette: " 271 "specified range SEED Reference Manual, " 272 "Version 2.4, August, 2012 (page 124):\n" 273 "The recommended value is from -50 to +49 usecs.\n" 274 "At the users option, this value may be from 0 to +99 usecs.\n" 275 << CHintToFormatModifiers);
290 "number of samples in MiniSEED record is inconsistent\n" 292 "number of samples announced in header: " 294 "number of samples actually used: " 296 << CHintToFormatModifiers);
318 (
Mdata(isample-1)==xn),
319 "data in MiniSEED record are inconsistent\n" 320 "consistency check \"" <<
key::data <<
"\" complains:\n" 321 "expected value of last sample " 322 "(i.e. reverse integration constant): " 324 "value of last sample (" 327 << CHintToFormatModifiers);
346 "number of frames in MiniSEED record is inconsistent\n" 347 "consistency check \"" <<
key::nframes <<
"\" complains:\n" 348 "number of frames announced in header: " 350 "number of frames actually used: " 352 << CHintToFormatModifiers);
356 if (is.good()) {
Mvalid=
true; }
ConsistencyChecks Mchecks
flags controlling consistency checks
bool fatal
Consequences of check.
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
ConsistencyCheckControl nsamples
Check for consistent number of samples.
MiniSEEDblock readheader(std::istream &is)
read header and return block
static const int blocksize
size of frame in bytes
ConsistencyCheckControl data
Check for consistent data values.
SEED::DataExtensionBlockette Mblockette1001
Data Extension Blockette.
const char *const nframes
keywords for consistency checks
bool Mhasblockette1001
Data Extension Blockette is present.
int Mxm1
Expected value of last sample in previous block.
bool MestimateNframes
estimate number of frames
ConsistencyCheckControl usec
Check for usec field being in specified range.
const char *const data
keywords for consistency checks
bool needswap(const unsigned char &bytesex)
check bytesex
unsigned int ifcount() const
aff::Series< Tvalue > Tseries
type of container for sample data
#define DATRW_warning(N, M)
Report a warning.
bool docheck
Activation of check.
const char *const skipcheck
keywords for format modifiers
#define DATRW_abort(M)
Abort and give a message.
contains non-data information, like headers
bool inconsistencies_are_not_fatal
make inconsistencies non fatal
SEED::FixedDataRecordHeader Mrecordheader
Fixed Data Record Header.
#define DATRW_nonfatal_assert(F, C, M)
Macro to distinguish between fatal and non fatal assertions.
Tseries Mdata
Container for sample data.
unsigned int iformat() const
unsigned int nsamples() const
number of samples
const char *const nsamples
number of samples per minute block and channel
SEED::DataOnlySEEDBlockette Mblockette1000
Data Only SEED Blockette.
#define DATRW_value(V)
report value
Debug Mdebug
debug options
bool Mvalid
contains valid data
ConsistencyCheckControl nframes
Check for consistent number of frames.
unsigned char bytesex
Word order.
unsigned int reclenbytes() const
const char *const nonfatal
keywords for format modifiers