readtsdata.h 11.3 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
/*! \file readtsdata.h
2
 * \brief read waveform data through the interface provided by libdatrwxx 
thomas.forbriger's avatar
GPL    
thomas.forbriger committed
3
 * (prototypes)
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
 * 
 * ----------------------------------------------------------------------------
 * 
thomas.forbriger's avatar
thomas.forbriger committed
7
 * $Id$
thomas.forbriger's avatar
thomas.forbriger committed
8
9
10
 * \author Thomas Forbriger
 * \date 31/01/2007
 * 
11
 * read waveform data through the interface provided by libdatrwxx 
thomas.forbriger's avatar
GPL    
thomas.forbriger committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 * (prototypes)
 *
 * ----
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
thomas.forbriger's avatar
thomas.forbriger committed
29
30
31
32
33
 * 
 * Copyright (c) 2007 by Thomas Forbriger (BFO Schiltach) 
 * 
 * REVISIONS and CHANGES 
 *  - 31/01/2007   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
34
35
 *  - 31/10/2007   V1.1   added single precision versions
 *                        PGPLOT requires single precision data
thomas.forbriger's avatar
thomas.forbriger committed
36
37
38
39
40
41
42
43
 * 
 * ============================================================================
 */

// include guard
#ifndef TF_READTSDATA_H_VERSION

#define TF_READTSDATA_H_VERSION \
thomas.forbriger's avatar
thomas.forbriger committed
44
  "TF_READTSDATA_H   V1.1"
thomas.forbriger's avatar
thomas.forbriger committed
45
#define TF_READTSDATA_H_CVSID \
thomas.forbriger's avatar
thomas.forbriger committed
46
  "$Id$"
thomas.forbriger's avatar
thomas.forbriger committed
47
48
49
50

#include<tfxx/rangelist.h>
#include<tfxx/xcmdline.h>
#include<tfxx/rangestring.h>
51
#include<datrwxx/readany.h>
thomas.forbriger's avatar
thomas.forbriger committed
52
53
54
#include<tsxx/sffheaders.h>
#include<iostream>
#include<fstream>
thomas.forbriger's avatar
thomas.forbriger committed
55

thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*! \defgroup group_readtsdata Reading of time series data.
 * \brief Read a complete set of time series including the selection of
 *   traces.
 *
 * The module is presented in namespace tfxx::tsio.
 *
 */

/*! \brief Interface provided through readtsdata.h
 *
 * \defgroup readtsdata_h Interface provided through readtsdata.h
 * 
 * \ingroup group_readtsdata
 */
namespace tfxx {

/*! \namespace tfxx::tsio
 * \brief Namespace containing all components of module readtsdata.
 * \ingroup group_readtsdata, readtsdata_h
 */
  namespace tsio {

thomas.forbriger's avatar
thomas.forbriger committed
78
79
80
81
82
83
84
85
86
87
88
89
    /*! \brief type of trace selection list.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * This is the rangelist class that holds a selection of traces in
     * numerical form. It can be generated generated from an approriate string
     * on the command line through:
     * \code
     * Ttracelist selection=
     *   tfxx::string::rangelist<Ttracelist::Tvalue>(filename.value(tracekey));
     * \endcode
     */
thomas.forbriger's avatar
thomas.forbriger committed
90
91
    typedef tfxx::RangeList<int> Ttracelist;

thomas.forbriger's avatar
thomas.forbriger committed
92
93
94
95
96
97
98
    /*! \brief type of trace selection key.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * This typedef is given here to make the argument definitions more
     * verbose.
     */
thomas.forbriger's avatar
thomas.forbriger committed
99
    typedef const char* Ttracelistkey;
thomas.forbriger's avatar
thomas.forbriger committed
100

thomas.forbriger's avatar
thomas.forbriger committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

    /*! \brief structure to contain file data together with command line
     * arguments (single precision).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * A struct to hold a complete data file including
     * -# command line arguments associated with the file
     * -# the file header
     * -# headers and samples from all selected traces
     *
     * This specific struct will hold samples in form of doubles.
     */
    struct SFile {
      //! provides reading into doubles
      typedef float Tvalue;
      //! container to be used
      typedef aff::Series<Tvalue> Tseries;
      //! file container
      typedef ts::sff::File<Tseries> Tfile;
      //! command line arguments
      tfxx::cmdline::Filename arguments;
      //! container to hold data headers and samples
      ts::sff::File<Tseries> data;
    }; // struct SFile

thomas.forbriger's avatar
thomas.forbriger committed
127
128
129
130
131
132
133
134
135
136
137
138
    /*! \brief structure to contain file data together with command line
     * arguments.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * A struct to hold a complete data file including
     * -# command line arguments associated with the file
     * -# the file header
     * -# headers and samples from all selected traces
     *
     * This specific struct will hold samples in form of doubles.
     */
thomas.forbriger's avatar
thomas.forbriger committed
139
    struct DFile {
thomas.forbriger's avatar
thomas.forbriger committed
140
      //! provides reading into doubles
thomas.forbriger's avatar
thomas.forbriger committed
141
      typedef double Tvalue;
thomas.forbriger's avatar
thomas.forbriger committed
142
      //! container to be used
thomas.forbriger's avatar
thomas.forbriger committed
143
      typedef aff::Series<Tvalue> Tseries;
thomas.forbriger's avatar
thomas.forbriger committed
144
      //! file container
thomas.forbriger's avatar
thomas.forbriger committed
145
      typedef ts::sff::File<Tseries> Tfile;
thomas.forbriger's avatar
thomas.forbriger committed
146
      //! command line arguments
thomas.forbriger's avatar
thomas.forbriger committed
147
      tfxx::cmdline::Filename arguments;
thomas.forbriger's avatar
thomas.forbriger committed
148
      //! container to hold data headers and samples
thomas.forbriger's avatar
thomas.forbriger committed
149
      ts::sff::File<Tseries> data;
thomas.forbriger's avatar
thomas.forbriger committed
150
    }; // struct DFile
thomas.forbriger's avatar
thomas.forbriger committed
151

thomas.forbriger's avatar
thomas.forbriger committed
152
153
154
155
156
157
158
    /*! \brief complete list of files.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * A list of DFile structs, to store all data files provided on the
     * command line at once.
     */
thomas.forbriger's avatar
thomas.forbriger committed
159
    typedef std::list<DFile> TDFileList;
thomas.forbriger's avatar
thomas.forbriger committed
160
161
162
163
164
165
166
167
168

    /*! \brief complete list of files (single precision version).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * A list of DFile structs, to store all data files provided on the
     * command line at once.
     */
    typedef std::list<SFile> TSFileList;
thomas.forbriger's avatar
thomas.forbriger committed
169
    
thomas.forbriger's avatar
thomas.forbriger committed
170
171
172
173
174
175
176
177
178
179
180
181
182
183
    /*! \brief read complete SFF file.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file with headers and samples at once.
     *
     * \return structure that contains file data together with command line
     *    arguments
     * \param filename input file name of file to be read
     * \param verbose select verbosity
     * \param format data format to be read
     */
    DFile readDSFF(const std::string& filename,
                   const bool& verbose=false,
184
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
185

thomas.forbriger's avatar
thomas.forbriger committed
186
187
188
189
190
191
192
193
194
195
196
197
198
199
    /*! \brief read complete SFF file with trace selection.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file with all headers and samples but only for the
     * selected traces.
     *
     * \return structure that contains file data together with command line
     *    arguments (here: only file name)
     * \param filename input file name of file to be read
     * \param selection numerical list of selected traces
     * \param verbose select verbosity
     * \param format data format to be read
     */
thomas.forbriger's avatar
thomas.forbriger committed
200
    DFile readDSFF(const std::string& filename,
thomas.forbriger's avatar
thomas.forbriger committed
201
                   const Ttracelist& selection,
thomas.forbriger's avatar
thomas.forbriger committed
202
                   const bool& verbose=false,
203
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
204

thomas.forbriger's avatar
thomas.forbriger committed
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
    /*! \brief read complete SFF file with trace selection.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file, but take selection from the structure of
     * command line arguments.
     *
     * \return structure that contains file data together with command line
     *    arguments (here: only file name)
     * \param filename input file name together with command line options and
     *    arguments
     * \param verbose select verbosity
     * \param tracekey key string for command line option that defines trace
     *   selection
     * \param format data format to be read
     */
thomas.forbriger's avatar
thomas.forbriger committed
221
222
    DFile readDSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose=false,
thomas.forbriger's avatar
thomas.forbriger committed
223
                   Ttracelistkey tracekey="t",
224
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
225

thomas.forbriger's avatar
thomas.forbriger committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    /*! \brief read complete list of SFF files with trace selection.
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete set of files like defined in the structure of command
     * line arguments.
     *
     * \return structure that contains file data together with command line
     *    arguments
     * \param flist list of file names together with
     *   command line options and arguments
     * \param verbose select verbosity
     * \param tracekey key string for command line option that defines trace
     *   selection
     * \param format data format to be read
     */
thomas.forbriger's avatar
thomas.forbriger committed
242
243
    TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose=false,
thomas.forbriger's avatar
thomas.forbriger committed
244
                        Ttracelistkey tracekey="t",
245
                        const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
    
    /*! \brief read complete SFF file (single precision version).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file with headers and samples at once.
     *
     * \return structure that contains file data together with command line
     *    arguments
     * \param filename input file name of file to be read
     * \param verbose select verbosity
     * \param format data format to be read
     */
    SFile readSSFF(const std::string& filename,
                   const bool& verbose=false,
261
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

    /*! \brief read complete SFF file with trace selection (single precision
     * version).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file with all headers and samples but only for the
     * selected traces.
     *
     * \return structure that contains file data together with command line
     *    arguments (here: only file name)
     * \param filename input file name of file to be read
     * \param selection numerical list of selected traces
     * \param verbose select verbosity
     * \param format data format to be read
     */
    SFile readSSFF(const std::string& filename,
                   const Ttracelist& selection,
                   const bool& verbose=false,
281
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302

    /*! \brief read complete SFF file with trace selection (single precision
     * version).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete data file, but take selection from the structure of
     * command line arguments.
     *
     * \return structure that contains file data together with command line
     *    arguments (here: only file name)
     * \param filename input file name together with command line options and
     *    arguments
     * \param verbose select verbosity
     * \param tracekey key string for command line option that defines trace
     *   selection
     * \param format data format to be read
     */
    SFile readSSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose=false,
                   Ttracelistkey tracekey="t",
303
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324

    /*! \brief read complete list of SFF files with trace selection (single
     * precision version).
     *
     * \ingroup group_readtsdata, readtsdata_h
     *
     * Read a complete set of files like defined in the structure of command
     * line arguments.
     *
     * \return structure that contains file data together with command line
     *    arguments
     * \param flist list of file names together with
     *   command line options and arguments
     * \param verbose select verbosity
     * \param tracekey key string for command line option that defines trace
     *   selection
     * \param format data format to be read
     */
    TSFileList readSSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose=false,
                        Ttracelistkey tracekey="t",
325
                        const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
326
327
328


  } // namespace tsio
thomas.forbriger's avatar
thomas.forbriger committed
329

thomas.forbriger's avatar
thomas.forbriger committed
330
} // namespace tfxx
thomas.forbriger's avatar
thomas.forbriger committed
331
332
333
334

#endif // TF_READTSDATA_H_VERSION (includeguard)

/* ----- END OF readtsdata.h ----- */