DATRW++ library: seismic data I/O with multiple formats
formats.cc
Go to the documentation of this file.
1 /*! \file formats.cc
2  * \brief common description of formats (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 26/11/2010
8  *
9  * common description of formats (implementation)
10  *
11  * Copyright (c) 2010 by Thomas Forbriger (BFO Schiltach)
12  *
13  * ----
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27  * ----
28  *
29  * REVISIONS and CHANGES
30  * - 26/11/2010 V1.0 Thomas Forbriger
31  * - 02/09/2011 V1.1 support seife format
32  * - 08/09/2011 V1.2 strip modifiers from format srting in anyID
33  * - 03/11/2011 V1.3 added format IDs for ASCII, binary, and Thies DL1
34  * - 04/11/2011 V1.4 make Thies DL1 module visible
35  * - 05/11/2011 V1.5 make ASCII output module visible
36  * - 08/11/2011 V1.6 make ASCII input module visible
37  * - 19/11/2011 V1.7 make binary module visible
38  * - 05/12/2011 V1.8 provide format specfic online help
39  * - 23/07/2017 V1.9 report library version
40  * - 27/02/2019 V1.10 print list of formats in alphabetical order
41  *
42  * ============================================================================
43  */
44 #define DATRW_FORMATS_CC_VERSION \
45  "DATRW_FORMATS_CC V1.10"
46 
47 #include <datrwxx/aalibdatrwxx.h>
48 #include <datrwxx/formats.h>
49 #include <datrwxx/formatmodifier.h>
50 #include <datrwxx/sff.h>
51 #include <datrwxx/pdas.h>
52 #include <datrwxx/hpmo.h>
53 #include <datrwxx/mseed.h>
54 #include <datrwxx/bonjer.h>
55 #include <datrwxx/sac.h>
56 #include <datrwxx/gse.h>
57 #include <datrwxx/tsoft.h>
58 #include <datrwxx/tfascii.h>
59 #include <datrwxx/su.h>
60 #include <datrwxx/seife.h>
61 #include <datrwxx/util.h>
62 #include <datrwxx/ascii.h>
63 #include <datrwxx/binary.h>
64 #include <datrwxx/thiesdl1.h>
65 
66 namespace datrw {
67 
68  Eformat anyID(std::string formatstring)
69  {
70  std::string id=util::clipstring(formatstring);
71  Eformat retval;
72  if (id==pdas::streamID) { retval=Fpdas; }
73  else if (id==sff::streamID) { retval=Fsff; }
74  else if (id==hpmo::streamID) { retval=Fhpmo; }
75  else if (id==mseed::streamID) { retval=Fmseed; }
76  else if (id==bonjer::streamID) { retval=Fbonjer; }
77  else if (id==sac::streamID) { retval=Fsac; }
78  else if (id==gse::streamID) { retval=Fgse; }
79  else if (id==tsoft::streamID) { retval=Ftsoft; }
80  else if (id==tfascii::streamID) { retval=Ftfascii; }
81  else if (id==su::streamID) { retval=Fsu; }
82  else if (id==seife::streamID) { retval=Fseife; }
83  else if (id==ascii::streamID) { retval=Fascii; }
84  else if (id==binary::streamID) { retval=Fbinary; }
85  else if (id==thiesdl1::streamID) { retval=Fthiesdl1; }
86  else {
87  std::cerr << "selected data format ID: \"" << id << "\"" << std::endl;
88  DATRW_abort("unknown data type identifier!");
89  }
90  return(retval);
91  } // Eformat anyID(const std::string& identifier)
92 
93  /*----------------------------------------------------------------------*/
94 
95  std::string anyID(const Eformat& id)
96  {
97  std::string retval="NSP";
98  switch(id) {
99  case Fpdas: retval=pdas::streamID; break;
100  case Fsff: retval=sff::streamID; break;
101  case Fhpmo: retval=hpmo::streamID; break;
102  case Fmseed: retval=mseed::streamID; break;
103  case Fbonjer: retval=bonjer::streamID; break;
104  case Fsac: retval=sac::streamID; break;
105  case Fgse: retval=gse::streamID; break;
106  case Ftsoft: retval=tsoft::streamID; break;
107  case Ftfascii: retval=tfascii::streamID; break;
108  case Fsu: retval=su::streamID; break;
109  case Fseife: retval=seife::streamID; break;
110  case Fascii: retval=ascii::streamID; break;
111  case Fbinary: retval=binary::streamID; break;
112  case Fthiesdl1: retval=thiesdl1::streamID; break;
113  default: DATRW_abort("unknown data type ID#!");
114  }
115  return(retval);
116  } // std::string anyID(const Eformat& id)
117 
118  /*----------------------------------------------------------------------*/
119 
120  void online_help(const std::string& format,
121  std::ostream& os,
122  const bool& modifierhelp)
123  {
124  online_help(anyID(format), os, modifierhelp);
125  } // void online_help(const std::string& format, std::ostream& os)
126 
127  /*----------------------------------------------------------------------*/
128 
129  void online_help(const Eformat& format,
130  std::ostream& os,
131  const bool& modifierhelp)
132  {
133  switch(format) {
134  case Fsff:
135  os << "SFF data input: "; isffstream::help(os);
136  os << std::endl;
137  os << "SFF data output: "; osffstream::help(os);
138  os << std::endl;
139  break;
140  case Fhpmo:
141  os << "HPMO data input: "; ihpmostream::help(os);
142  os << std::endl;
143  break;
144  case Fmseed:
145  os << "MiniSEED data input: "; imseedstream::help(os);
146  os << std::endl;
147  break;
148  case Fpdas:
149  os << "PDAS data input: "; ipdasstream::help(os);
150  os << std::endl;
151  break;
152  case Fbonjer:
153  os << "Bonjer data input: "; ibonjerstream::help(os);
154  os << std::endl;
155  break;
156  case Fsac:
157  os << "SAC data input: "; isacstream::help(os);
158  os << std::endl;
159  break;
160  case Fgse:
161  os << "GSE data input: "; igsestream::help(os);
162  os << std::endl;
163  os << "GSE data output: "; ogsestream::help(os);
164  os << std::endl;
165  break;
166  case Ftsoft:
167  os << "TSOFT data input: "; itsoftstream::help(os);
168  os << std::endl;
169  break;
170  case Ftfascii:
171  os << "TFASCII data input: "; itfasciistream::help(os);
172  os << std::endl;
173  break;
174  case Fsu:
175  os << "SU data input: "; isustream::help(os);
176  os << std::endl;
177  os << "SU data output: "; osustream::help(os);
178  os << std::endl;
179  break;
180  case Fseife:
181  os << "seife data input: "; iseifestream::help(os);
182  os << std::endl;
183  os << "seife data output: "; oseifestream::help(os);
184  os << std::endl;
185  break;
186  case Fthiesdl1:
187  os << "Thies DL1 data input: "; ithiesdl1stream::help(os);
188  os << std::endl;
189  break;
190  case Fascii:
191  os << "ASCII data input: "; iasciistream::help(os);
192  os << std::endl;
193  os << "ASCII data output: "; oasciistream::help(os);
194  os << std::endl;
195  break;
196  case Fbinary:
197  os << "binary data input: "; ibinarystream::help(os);
198  os << std::endl;
199  os << "binary data output: "; obinarystream::help(os);
200  os << std::endl;
201  break;
202  default: DATRW_abort("unknown data type ID#!");
203  }
204  if (modifierhelp)
205  {
206  os << std::endl;
208  }
209  } // void online_help(const Eformat& format, std::ostream& os)
210 
211  /*----------------------------------------------------------------------*/
212 
213  void online_help(std::ostream& os)
214  {
215  os << std::endl
216  << datrw::libversion << std::endl
217  << "Online help obtained from I/O streams:"
218  << std::endl;
219  os << "--------------------------------------"
220  << std::endl << std::endl;
221  online_help(Fascii, os);
222  online_help(Fbinary, os);
223  online_help(Fbonjer, os);
224  online_help(Fgse, os);
225  online_help(Fhpmo, os);
226  online_help(Fmseed, os);
227  online_help(Fpdas, os);
228  online_help(Fsac, os);
229  online_help(Fseife, os);
230  online_help(Fsff, os);
231  online_help(Fsu, os);
232  online_help(Ftfascii, os);
233  online_help(Fthiesdl1, os);
234  online_help(Ftsoft, os);
236  } // void online_help(std::ostream& os)
237 
238  /*----------------------------------------------------------------------*/
239 
240  inline void print_format_desc(std::ostream& os,
241  const char* ID, const char* desc)
242  {
243  os.width(13); os << ID << ": " << desc << std::endl;
244  } // inline void print_format_desc(std::ostream& os,
245  // const char* ID, const char* desc)
246 
247  /*----------------------------------------------------------------------*/
248 
249  void supported_input_data_types(std::ostream& os)
250  {
251  os << datrw::libversion << std::endl;
252  os << "data formats supported by ianystream:" << std::endl;
254  "simple single column ASCII data");
255  print_format_desc(os, binary::streamID, "binary data");
257  "K2 ASCII data format (defined by K. Bonjer?)");
258  print_format_desc(os, gse::streamID, "raw GSE format");
260  "HP-MO data format defined by W. Grossmann (BFO)");
261  print_format_desc(os, mseed::streamID, "MiniSEED (SeisComP, EDL, etc.)");
262  print_format_desc(os, pdas::streamID, "PDAS100 (i.e. DaDisp)");
263  print_format_desc(os, sac::streamID, "SAC binary format");
264  print_format_desc(os, seife::streamID, "seife format (E. Wielandt)");
265  print_format_desc(os, sff::streamID, "Stuttgart File Format");
266  print_format_desc(os, su::streamID, "SeismicUn*x format");
268  "ASCII format of T. Forbrigers any2ascii");
270  "Thies DL1 pluviometer data at BFO");
271  print_format_desc(os, tsoft::streamID, "TSOFT format");
272  }
273 
274  /*----------------------------------------------------------------------*/
275 
276  void supported_output_data_types(std::ostream& os)
277  {
278  os << datrw::libversion << std::endl;
279  os << "data formats supported by oanystream:" << std::endl;
280  print_format_desc(os, ascii::streamID, "simple single column ASCII data");
281  print_format_desc(os, binary::streamID, "binary data");
282  print_format_desc(os, gse::streamID, "raw GSE format");
283  print_format_desc(os, seife::streamID, "seife format (E. Wielandt)");
284  print_format_desc(os, sff::streamID, "Stuttgart File Format");
285  print_format_desc(os, su::streamID, "SeismicUn*x format");
286  }
287 
288  /*----------------------------------------------------------------------*/
289 
290  void supported_data_types(std::ostream& os)
291  {
292  os << "data formats supported for reading:" << std::endl;
293  os << "-----------------------------------" << std::endl;
295  os << std::endl;
296  os << "data formats supported for writing:" << std::endl;
297  os << "-----------------------------------" << std::endl;
299  }
300 
301 } // namespace datrw
302 
303 /* ----- END OF formats.cc ----- */
static void help(std::ostream &os=std::cout)
const char *const streamID
Format properties.
Definition: ipdasstream.cc:56
static void help(std::ostream &os=std::cout)
const char *const streamID
Format properties.
Definition: binary.cc:48
read Thomas Forbrigers ASCII data (prototypes)
seife reading and writing module (prototypes)
provide format modifiers (prototypes)
void online_help(std::ostream &os)
Provide online help on modifiers.
const char *const streamID
Format properties.
Definition: igsestream.cc:55
Eformat anyID(std::string formatstring)
convert identifier from and to string representation
Definition: formats.cc:68
static void help(std::ostream &os=std::cout)
Definition: bonjer.h:72
static void help(std::ostream &os=std::cout)
Definition: ipdasstream.cc:144
const char *const streamID
Format properties.
Definition: itsoftstream.cc:57
write raw binary data (prototypes)
void supported_output_data_types(std::ostream &os)
Definition: formats.cc:276
read SAC files (prototypes)
void print_format_desc(std::ostream &os, const char *ID, const char *desc)
Definition: formats.cc:240
const char *const streamID
Format properties.
Definition: isffstream.cc:59
static void help(std::ostream &os=std::cout)
Definition: oasciistream.cc:73
read sff data (prototypes)
void online_help(const std::string &format, std::ostream &os, const bool &modifierhelp)
Definition: formats.cc:120
const char *const streamID
Format properties.
Definition: isacstream.cc:58
static void help(std::ostream &os=std::cout)
Definition: osffstream.cc:79
libdatrwxx version string (prototypes)
const char *const streamID
Format properties.
static void help(std::ostream &os=std::cout)
const char *const streamID
Format properties.
const char *const libversion
Version string.
Definition: aalibdatrwxx.cc:18
static void help(std::ostream &os=std::cout)
Definition: isustream.cc:154
static void help(std::ostream &os=std::cout)
Root namespace of library.
Definition: aalibdatrwxx.cc:16
static void help(std::ostream &os=std::cout)
read PDAS data (prototypes)
utilities used by more than one type of data reader (prototypes)
const char *const streamID
Format properties.
Definition: seifeformat.cc:53
void supported_data_types(std::ostream &os)
Definition: formats.cc:290
#define DATRW_abort(M)
Abort and give a message.
Definition: error.h:101
module to read ThiesDL1 data files (prototypes)
read raw GSE data (prototypes)
const char *const streamID
Format properties.
static void help(std::ostream &os=std::cout)
Definition: igsestream.cc:104
void supported_input_data_types(std::ostream &os)
Definition: formats.cc:249
read bonjers ASCII data (prototypes)
static void help(std::ostream &os=std::cout)
Definition: osustream.cc:72
static void help(std::ostream &os=std::cout)
std::string clipstring(std::string &s, const std::string &delim)
strip substringStrips off first substring up to given delimiter. The string is passed as a reference ...
Definition: util.cc:105
static void help(std::ostream &os=std::cout)
print some info about data conversion
const char *const streamID
Format properties.
Definition: suformat.cc:52
provide data from HP Mo (BFO data acquisition system) (prototypes)
const char *const streamID
Format properties.
Definition: asciiformat.cc:47
const char *const streamID
Format properties.
Definition: imseedstream.cc:68
provide mini-SEED data (prototypes)
static void help(std::ostream &os=std::cout)
Definition: osffstream.cc:199
static void help(std::ostream &os=std::cout)
Definition: sff.h:85
const char *const streamID
Format properties.
Definition: ihpmostream.cc:55
static void help(std::ostream &os=std::cout)
static void help(std::ostream &os=std::cout)
Definition: isacstream.cc:161
static void help(std::ostream &os=std::cout)
read Seismic Unix data (prototypes)
classes for TSOFT in SFF (prototypes)
common description of formats (prototypes)
Eformat
Definition: formats.h:54
static void help(std::ostream &os=std::cout)
Definition: hpmo.h:70
interface to write ASCII data (prototypes)