DATRW++ library: seismic data I/O with multiple formats
iseifestream.cc
Go to the documentation of this file.
1 /*! \file iseifestream.cc
2  * \brief reading seife data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 30/11/2010
8  *
9  * reading seife data (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  * - 30/11/2010 V1.0 Thomas Forbriger
31  * - 18/11/2016 V1.1 use debug flag in base class
32  *
33  * ============================================================================
34  */
35 #define DATRW_ISEIFESTREAM_CC_VERSION \
36  "DATRW_ISEIFESTREAM_CC V1.1"
37 
38 #include <datrwxx/seife.h>
39 #include <datrwxx/seifeio.h>
40 #include <datrwxx/util.h>
41 #include <datrwxx/formatmodifier.h>
42 
43 namespace datrw {
44 
45  const std::ios_base::openmode
46  iseifestream::openmode=std::ios_base::in;
47 
48  /*----------------------------------------------------------------------*/
49 
50  iseifestream::iseifestream(std::istream& is,
51  const std::string& modifier,
52  const bool& debug):
53  Tbase(is, true, true, false, debug), Mmodifier(modifier)
54  {
55  } // iseifestream::iseifestream
56 
57  /*----------------------------------------------------------------------*/
58 
60  {
61  this->newtrace();
62  datrw::Subformat subformat(Mmodifier);
63  datrw::seife::Header header(Mis);
64  ::sff::FREE free=header.comments();
66  free.append("input format: "+pl.format());
67  ::sff::WID2 wid2;
68  wid2.dt=pl.dt();
69  libtime::TAbsoluteTime date(subformat.value("date","2000/1/1"));
70  wid2.date=libtime::TAbsoluteTime(date.year(), date.month(), date.day());
71  wid2.date+=pl.time();
72  wid2.nsamples=pl.nsamples();
73  wid2.station=subformat.value("station","NSP");
74  wid2.channel=subformat.value("channel","NSP");
75  wid2.auxid=subformat.value("auxid","NSP");
76  wid2.instype=subformat.value("instype","NSP");
77  this->settracefree(free);
78  this->setwid2(wid2);
79  // check for unrecognized modifiers since this is the only place where
80  // modifiers are evaluated in this stream
82  "iseifestream::settraceheader()");
83  } // void iseifestream::settraceheader()
84 
85  /*----------------------------------------------------------------------*/
86 
88  {
89  this->settraceheader();
90  this->setlast();
91  return(datrw::util::readasciidouble<datrw::Tdseries>(Mis,
92  this->wid2().nsamples,
93  "iseifestream"));
94  } // Tdseries iseifestream::dseries()
95 
96  /*----------------------------------------------------------------------*/
97 
99  {
100  this->settraceheader();
101  this->setlast();
102  return(datrw::util::readasciidouble<datrw::Tfseries>(Mis,
103  this->wid2().nsamples,
104  "iseifestream"));
105  } // Tfseries iseifestream::fseries()
106 
107  /*----------------------------------------------------------------------*/
108 
110  {
111  this->settraceheader();
112  this->setlast();
113  } // void iseifestream::skipseries()
114 
115  /*----------------------------------------------------------------------*/
116 
117  void iseifestream::help(std::ostream& os)
118  {
119  os <<
120  std::endl <<
121  "seife reading functions" << std::endl <<
122  "-----------------------" << std::endl <<
123  DATRW_ISEIFESTREAM_CC_VERSION << std::endl <<
124  std::endl;
125  os <<
126  "This module reads seismic time series data in the format\n"
127  "used by programs provided by Erhard Wielandt. See his web site\n"
128  "http://www.software-for-seismometry.de for details.\n"
129  "In its current version, the input stream does not evaluate the\n"
130  "Fortran format specification in the file header. It simply expects\n"
131  "a sequence of the announced number of floating point values\n"
132  "separated by whitespace."
133  << std::endl;
134  os <<
135  "The seife input stream can be controlled by format modifiers:\n"
136  "date=2012/7/2 sets the recording date to 2.7.2012\n"
137  "station=BFO sets the recording station to BFO\n"
138  "channel=LXX sets the recording channel to LXX\n"
139  "auxid=LOC0 sets the recording auxid to LOC0\n"
140  "instype=STS2 sets the recording instrument type to STS2\n"
141  "Choose appropriate parameter values for your case."
142  << std::endl;
143  } // void iseifestream::help(std::ostream& os)
144 
145 } // namespace datrw
146 
147 /* ----- END OF iseifestream.cc ----- */
seife format header parameter line
Definition: seifeio.h:69
libtime::TRelativeTime time() const
return time of first sample as offset from midnight
Definition: seifeio.h:98
unsigned int nsamples() const
return number of samples
Definition: seifeio.h:92
seife reading and writing module (prototypes)
provide format modifiers (prototypes)
aff::Series< float > Tfseries
Definition: types.h:46
sff::WID2 wid2() const
Definition: datread.h:111
virtual void skipseries()
std::string Mmodifier
format modifier
Definition: seife.h:79
aff::Series< double > Tdseries
Definition: types.h:45
::sff::FREE comments() const
return comments
Definition: seifeio.h:153
const int nsamples
number of samples per minute block and channel
Definition: hpmodata.h:51
std::istream & Mis
Definition: datread.h:126
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
#define DATRW_assert_modifiers_are_recognized(S, F)
abort if user passed unused modifiers
static const std::ios_base::openmode openmode
Definition: seife.h:76
Root namespace of library.
Definition: aalibdatrwxx.cc:16
utilities used by more than one type of data reader (prototypes)
std::string format() const
return Fortran data format
Definition: seifeio.h:94
sff::FREE free() const
Definition: datread.cc:79
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
double dt() const
return sumpling interval
Definition: seifeio.h:96
class to hold complete seife header
Definition: seifeio.h:132
Class to handle format modifiersThis class is used to parse a format modifier string. Detailed instructions will be given upon request. For some hints have a look at tests/libdatrwxxtests.c.
#define DATRW_ISEIFESTREAM_CC_VERSION
Definition: iseifestream.cc:35
virtual Tdseries dseries()
Definition: iseifestream.cc:87
ParameterLine parameters() const
return parameters
Definition: seifeio.h:155
static void help(std::ostream &os=std::cout)
iseifestream(std::istream &is, const std::string &modifier="", const bool &debug=false)
Definition: iseifestream.cc:50
std::string value(const std::string &k, const std::string &dev="false") const
function operator returns string
virtual Tfseries fseries()
Definition: iseifestream.cc:98