DATRW++ library: seismic data I/O with multiple formats

◆ evalline()

void datrw::thiesdl1::DataLine::evalline ( )
private

check consistency of data line and fill data value fields

Definition at line 89 of file thiesdl1line.cc.

References datrw::thiesdl1::helper::chalfminute(), datrw::thiesdl1::helper::coneday(), DL1_dlassert, gain, Mcounts, Mline, Mtime, and Mvalue.

Referenced by DataLine().

90  {
91  DL1_dlassert(Mline.length()==27, "unexpected length of data line", Mline);
92  // check for expected characters
93  const char cmismatch[]="character mismatch";
94  DL1_dlassert(Mline.substr(2,1)==".", cmismatch, Mline);
95  DL1_dlassert(Mline.substr(10,1)==".", cmismatch, Mline);
96  DL1_dlassert(Mline.substr(15,1)==".", cmismatch, Mline);
97  DL1_dlassert(Mline.substr(18,1)==".", cmismatch, Mline);
98  DL1_dlassert(Mline.substr(24,1)==":", cmismatch, Mline);
99  DL1_dlassert(Mline.substr(6,1)==" ", cmismatch, Mline);
100  DL1_dlassert(Mline.substr(12,1)==" ", cmismatch, Mline);
101  DL1_dlassert(Mline.substr(21,1)==" ", cmismatch, Mline);
102  // extract time and date
103  int year, month, day, hour, minute;
104  std::istringstream iss;
105  iss.clear();
106  iss.str(Mline.substr(13,2));
107  iss >> day;
108  iss.clear();
109  iss.str(Mline.substr(16,2));
110  iss >> month;
111  iss.clear();
112  iss.str(Mline.substr(19,2));
113  iss >> year;
114  iss.clear();
115  iss.str(Mline.substr(22,2));
116  iss >> hour;
117  iss.clear();
118  iss.str(Mline.substr(25,2));
119  iss >> minute;
120  if (year < 100) { year += 1900; }
121  if (year < 1970) { year += 100; }
122  libtime::TAbsoluteTime intime(year,month,day,hour,minute);
123  // check time and date
124  if (hour!=24)
125  {
126  DL1_dlassert(((intime.year()==year)
127  && (intime.month()==month)
128  && (intime.day()==day)
129  && (intime.hour()==hour)
130  && (intime.minute()==minute)),
131  "invalid date value", Mline);
132  }
133  else
134  {
135  DL1_dlassert((minute==0),
136  "invalid time value (expected: 24:00UT)", Mline);
137  libtime::TAbsoluteTime thedayonly(intime-helper::coneday);
138  DL1_dlassert(((thedayonly.year()==year)
139  && (thedayonly.month()==month)
140  && (thedayonly.day()==day)),
141  "invalid date value", Mline);
142  }
143  Mtime=intime-helper::chalfminute;
144  // check float value for time
145  double ftime=double(hour)+int(0.5+1000.*double(minute)/60.)/1000.;
146  double rftime;
147  iss.clear();
148  iss.str(Mline.substr(0,6));
149  iss >> rftime;
150  double diff=ftime-rftime;
151  if (diff<0) { diff=-diff; }
152  if (!(diff < 0.002))
153  {
154  /*
155  Logger(log_err) << "ftime: " << ftime
156  << " rftime: " << rftime
157  << " diff: " << diff;
158  */
159  }
160  DL1_dlassert(diff < 0.002,
161  "inconsistent floating point time values", Mline);
162  // read data value
163  iss.clear();
164  iss.str(Mline.substr(7,6));
165  iss >> this->Mvalue;
166  this->Mcounts=Tuint(nearbyint(Mvalue/DataLine::gain));
167  } // DataLine::evalline()
unsigned int Mcounts
value of sample in counts
Definition: thiesdl1line.h:98
std::string Mline
literal data line as received from DL1
Definition: thiesdl1line.h:92
unsigned int Tuint
Definition: thiesdl1line.cc:83
static const double gain
gain value in mm/count
Definition: thiesdl1line.h:84
#define DL1_dlassert(C, M, L)
Definition: thiesdl1line.cc:79
libtime::TAbsoluteTime Mtime
date and time of this sample
Definition: thiesdl1line.h:94
const libtime::TRelativeTime coneday(1)
double Mvalue
value of sample in mm precipitation
Definition: thiesdl1line.h:96
const libtime::TRelativeTime chalfminute(0, 0, 0, 30)
Here is the call graph for this function:
Here is the caller graph for this function: