DATRW++ library: seismic data I/O with multiple formats
ipdasstream.cc
Go to the documentation of this file.
1 /*! \file ipdasstream.cc
2  * \brief read PDAS data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 30/03/2004
8  *
9  * read PDAS data (implementation)
10  *
11  * ----
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25  * ----
26  *
27  * Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
28  *
29  * REVISIONS and CHANGES
30  * - 30/03/2004 V1.0 Thomas Forbriger
31  * - 17/09/2004 V1.1 slightly simplified
32  * - 20/10/2004 V1.2 support scaling for floating point output types
33  * - 23/11/2010 V1.3 introduced static member data
34  *
35  * ============================================================================
36  */
37 #define DATRW_PDAS_CC_VERSION \
38  "DATRW_PDAS_CC V1.3"
39 
40 #include <algorithm>
41 #include <iterator>
42 #include <datrwxx/pdas.h>
43 #include <datrwxx/pdasread.h>
44 #include <aff/seriesoperators.h>
45 
46 namespace datrw {
47 
48  const std::ios_base::openmode
49  ipdasstream::openmode=std::ios_base::in|std::ios_base::binary;
50 
51  //@{
52  /*! \brief Format properties
53  * \ingroup group_pdas
54  */
55  const bool pdas::isbinary=true;
56  const char* const pdas::streamID="pdas";
57  //@}
58 
59  /*----------------------------------------------------------------------*/
60 
61  ipdasstream::ipdasstream(std::istream& is)
62  : Tbase(is, true, true, true)
63  { }
64 
65  /*----------------------------------------------------------------------*/
66 
68  {
69  readheader();
72  sff::WID2 wid2(this->wid2());
73  wid2.nsamples=data.size();
74  this->setwid2(wid2);
75  return(datrw::pdas::convertandscale<Tdseries>(data, Mtype));
76  }
77 
78  /*----------------------------------------------------------------------*/
79 
81  {
82  readheader();
85  sff::WID2 wid2(this->wid2());
86  wid2.nsamples=data.size();
87  this->setwid2(wid2);
88  return(datrw::pdas::convertandscale<Tfseries>(data, Mtype));
89  }
90 
91  /*----------------------------------------------------------------------*/
92 
94  {
95  readheader();
98  sff::WID2 wid2(this->wid2());
99  wid2.nsamples=data.size();
100  this->setwid2(wid2);
101  return(datrw::pdas::convert<Tiseries>(data));
102  }
103 
104  /*----------------------------------------------------------------------*/
105 
107  {
108  readheader();
109  sff::WID2 wid2(this->wid2());
110  wid2.nsamples=datrw::pdas::countdata(Mis, Mtype);
111  this->setwid2(wid2);
112  }
113 
114  /*----------------------------------------------------------------------*/
115 
117  {
118  this->newtrace();
119  sff::WID2 wid2;
120  sff::FREE tracefree;
122  std::copy(hd.lines.begin(), hd.lines.end(),
123  std::back_inserter(tracefree.lines));
124  wid2.station=hd.dataset.substr(2,3);
125  wid2.channel=hd.dataset.substr(0,2);
126  wid2.auxid=hd.signal;
127  int ipday=hd.date.find('-');
128  int ipyear=hd.date.find('-',1+ipday);
129  std::string datestring=hd.date.substr(1+ipyear)
130  + '/' + hd.date.substr(0,ipday)
131  + '/' + hd.date.substr(1+ipday,ipyear-ipday-1);
132  int ipspace=hd.time.find(' ');
133  datestring += '_' + hd.time.substr(0,ipspace);
134  wid2.date=libtime::TAbsoluteTime(datestring.c_str());
135  wid2.dt=std::atof(hd.interval.c_str());
136  Mtype=hd.type;
137  this->settracefree(tracefree);
138  this->setwid2(wid2);
139  this->setlast();
140  }
141 
142  /*----------------------------------------------------------------------*/
143 
144  void ipdasstream::help(std::ostream& os)
145  { datrw::pdas::help(os); }
146 
147 } // namespace datrw
148 
149 /* ----- END OF ipdasstream.cc ----- */
const char *const streamID
Format properties.
Definition: ipdasstream.cc:56
static const std::ios_base::openmode openmode
Definition: pdas.h:73
aff::Series< float > Tfseries
Definition: types.h:46
std::string interval
Definition: pdasread.h:69
sff::WID2 wid2() const
Definition: datread.h:111
static void help(std::ostream &os=std::cout)
Definition: ipdasstream.cc:144
aff::Series< double > Tdseries
Definition: types.h:45
std::istream & Mis
Definition: datread.h:126
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
const char *const data
keywords for consistency checks
std::string signal
Definition: pdasread.h:69
pdas::Etype Mtype
Definition: pdas.h:79
std::string time
Definition: pdasread.h:69
Root namespace of library.
Definition: aalibdatrwxx.cc:16
virtual Tfseries fseries()
Definition: ipdasstream.cc:80
std::vector< std::string > lines
Definition: pdasread.h:72
void readdata(std::istream &is, Tdata &data, const Etype &type)
Definition: pdasread.cc:150
read PDAS data (prototypes)
std::string dataset
Definition: pdasread.h:69
ipdasstream(std::istream &is)
Definition: ipdasstream.cc:61
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
aff::Series< int > Tiseries
Definition: types.h:47
struct to hold complete header
Definition: pdasread.h:68
void help(std::ostream &os)
function to print online help
Definition: pdasread.cc:262
virtual void skipseries()
Definition: ipdasstream.cc:106
Header readheader(std::istream &is, const bool &verbose)
function to read the file header
Definition: pdasread.cc:82
virtual Tdseries dseries()
Definition: ipdasstream.cc:67
virtual Tiseries iseries()
Definition: ipdasstream.cc:93
std::string date
Definition: pdasread.h:69
const bool isbinary
Format properties.
Definition: ipdasstream.cc:55
int countdata(std::istream &is, const Etype &type)
function to skip the file data but count the samples
Definition: pdasread.cc:166
std::vector< Tvalue > Tdata
Definition: pdasread.h:76