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

◆ readheader()

header datrw::bonjer::readheader ( std::istream &  is,
const bool &  verbose 
)

function to read the file header

Definition at line 76 of file readbonjer.cc.

References datrw::bonjer::header::component, datrw::bonjer::header::date, datrw::bonjer::header::filename, datrw::bonjer::header::nsamples, datrw::bonjer::header::rate, datrw::bonjer::header::sensitivity, datrw::bonjer::header::station, and datrw::bonjer::header::units.

Referenced by datrw::ibonjerstream::readheader().

77  {
78  std::string line;
79  bool hot=true;
80  header retval;
81  int mandatory=0;
82  while (hot && is.good()) {
83  getline(is, line);
84  if (line.substr(0,7)==std::string("K2 Stn:"))
85  {
86  retval.station=line.substr(8);
87  mandatory++;
88  } else
89  if (line.substr(0,17)==std::string("Event Start Time:"))
90  {
91  std::istringstream iss(line.substr(18).c_str());
92  char c;
93  int day, month, year, hour, minute;
94  double seconds;
95  iss >> month >> c >> day >> c >> year;
96  iss >> c >> hour >> c;
97  iss >> hour >> c >> minute >> c >> seconds;
98  retval.date=libtime::TAbsoluteTime(year,month,day,hour,minute);
99  retval.date+=libtime::double2time(seconds);
100  mandatory++;
101  } else
102  if (line.substr(0,19)==std::string("Samples per second:"))
103  {
104  retval.rate=std::atof(line.substr(20).c_str());
105  mandatory++;
106  } else
107  if (line.substr(0,17)==std::string("Number of points:"))
108  {
109  retval.nsamples=std::atoi(line.substr(18).c_str());
110  mandatory++;
111  } else
112  if (line.substr(0,9)==std::string("Filename:"))
113  {
114  retval.filename=line.substr(10);
115  mandatory++;
116  } else
117  if (line.substr(0,10)==std::string("Component:"))
118  {
119  retval.component=line.substr(11);
120  mandatory++;
121  } else
122  if (line.substr(0,12)==std::string("Sensitivity:"))
123  {
124  retval.sensitivity=line.substr(13);
125  mandatory++;
126  } else
127  if (line.substr(0,6)==std::string("Units:"))
128  {
129  retval.units=line.substr(7);
130  mandatory++;
131  }
132  if (mandatory > 7) { hot=false; }
133  }
134  if (mandatory<8) throw;
135  getline(is,line);
136  if (verbose)
137  {
138  std::cout << "File: " << retval.filename << std::endl;
139  std::cout << "Station: " << retval.station << std::endl;
140  std::cout << "Component: " << retval.component << std::endl;
141  std::cout << "First: " << retval.date.timestring() << std::endl;
142  std::cout << "Rate: " << retval.rate << std::endl;
143  std::cout << "Samples: " << retval.nsamples << std::endl;
144  std::cout << "Sensitivity: " << retval.sensitivity << std::endl;
145  std::cout << "Units: " << retval.units << std::endl;
146  }
147  return(retval);
148  } // function readheader
Here is the caller graph for this function: