63 #define DATRW_THIESDL1FILE_CC_VERSION \ 64 "DATRW_THIESDL1FILE_CC V1.4" 66 #include <datrwxx/thiesdl1file.h> 67 #include <datrwxx/thiesdl1line.h> 69 #include <aff/seriesoperators.h> 87 std::cerr <<
" earliest in expected window: " <<
89 std::cerr <<
" latest in expected window: " <<
91 std::cerr <<
" DL1 data line: " << this->
Mdataline;
96 #define DL1_rcassert( C, M, E, L, N ) \ 97 if (!(C)) { throw( thiesdl1::ExceptionRecordWindow( M , __FILE__, \ 105 this->
lines.lines.clear();
135 while (line.substr(0,2) ==
"# ")
137 retval.
lines.append(line.substr(2));
138 if (line.substr(2,15) ==
"earliest date: ")
141 libtime::TAbsoluteTime(line.substr(27,4)+
":"+
142 line.substr(24,2)+
":"+
143 line.substr(21,2)+
":"+
148 else if (line.substr(2,15) ==
"latest date: ")
151 libtime::TAbsoluteTime(line.substr(27,4)+
":"+
152 line.substr(24,2)+
":"+
153 line.substr(21,2)+
":"+
158 else if (line.substr(2,15) ==
"creation date: ")
161 libtime::TAbsoluteTime(line.substr(27,4)+
":"+
162 line.substr(24,2)+
":"+
163 line.substr(21,2)+
":"+
168 else if (line.substr(2,15) ==
"initial line: ")
174 else if (line.substr(2,15) ==
"final line: ")
188 "ERROR: could not extract full header data");
190 "initial data line is not matsching" 196 "ERROR: missing expected initial data line");
198 "ERROR: inconsistent date values in data header");
200 "ERROR: inconsistent date values in data header");
211 "FileHeader::nsamples: Data is not set ready");
220 "FileHeader::wid2line: Data is not set ready");
245 "ERROR: File container is not empty");
251 fileduration<libtime::TRelativeTime(5),
252 "Duration of file is larger than 5 days!\n" 267 while (hot && is.good())
281 DATRW_assert(!hot,
"missed expected last line of data file");
306 "No data was read into File structure");
308 "Header data not read successfully");
310 "Data not read successfully");
320 std::ostringstream oss;
326 "sample does not fit in expected window",
335 std::cerr <<
"sample does not fit in expected window";
336 std::cerr <<
" earliest in expected window: " <<
338 std::cerr <<
" latest in expected window: " <<
340 std::cerr <<
" DL1 data line: " << line.
line();
343 oss <<
"ERROR: data line with weird time: " << line.
line();
350 unsigned int i=(line.
time()-
355 "sample index out of range",
357 this->Mheader.latestdate,
366 oss <<
"NOTICE: duplicate sample time (index " 367 << i <<
"): " << line.
line();
370 std::cerr << oss.str() << std::endl;
381 oss <<
"ERROR: sample index " << i <<
" out of range: " << line.
line();
382 std::cerr << oss.str() << std::endl;
399 "Data is not set ready");
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
FileHeader readheader(std::istream &is)
Read and parse a file header.
unsigned int counts() const
return count value
aff::Series< float > Tfseries
Tdseries dseries() const
return data block of values
bool Mbetolerantagainstwrongtime
mode: do not abort upon wrong sample time
#define DL1_rcassert(C, M, E, L, N)
Store one line of data as read from DL1.
libtime::TAbsoluteTime time() const
return date and time
aff::Series< double > Tdseries
const libtime::TRelativeTime dl1samplinginterval
expected sampling interval of DL1
unsigned int Mnsamples
number of samples
static const double gain
gain value in mm/count
bool Mbetolerantagainstredundant
mode: do not abort upon redundant samples
FileHeader header() const
return file header
aff::Series< bool > Mfilled
an array to keep track of samples
std::string line() const
return data line
exception class declaration for libdatrwxx (prototypes)
Tiseries Miseries
prepare are series of counts
void readwithheader(std::istream &is)
actually read file
bool isproperlyfilled(const bool &throwerrors=false) const
bool Mreadyforreading
is this container empty and ready for reading?
bool Mfoundunexpecteddatatime
found unexpected data time
Tiseries iseries() const
return data block of counts
Root namespace of library.
::sff::WID2 wid2line() const
return WID2 header
libtime::TAbsoluteTime Mearliest
FileHeader Mheader
file header
void read(std::istream &is, const FileHeader &header)
actually read file
::sff::FREE Mtracefree
comment header lines
void clear()
clear container
aff::Series< int > Tiseries
libtime::TAbsoluteTime Mlatest
#define DATRW_nonfatal_assert(F, C, M)
Macro to distinguish between fatal and non fatal assertions.
Tfseries fseries() const
return data block of values
virtual void report() const
Screen report.
const char *const precipitationID
SEED channel identifier for precipitation.
virtual void report() const
Screen report.
int nsamples() const
number of samples expected in this data set
bool Mreadsuccessfully
true if data was read successfully
void put(const DataLine &line)
drop a data line
#define DATRW_report_assert(C, M)
Check an assertion and report only.