cmdlinefiles.h 18.7 KB
Newer Older
1
2
3
/*! \file cmdlinefiles.h
 * \brief containers for data files with file specific command line parameters
 *        (prototypes).
thomas.forbriger's avatar
thomas.forbriger committed
4
5
6
 * 
 * ----------------------------------------------------------------------------
 * 
7
 * $Id: $
thomas.forbriger's avatar
thomas.forbriger committed
8
 * \author Thomas Forbriger
9
10
11
12
 * \since 31/01/2007
 * \date 30/01/2014
 * 
 * Copyright (c) 2007, 2010, 2011, 2014 by Thomas Forbriger (BFO Schiltach) 
thomas.forbriger's avatar
thomas.forbriger committed
13
 * 
14
 * containers for data files with file specific command line parameters
thomas.forbriger's avatar
GPL    
thomas.forbriger committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 * (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
 * ----
32
 *
thomas.forbriger's avatar
thomas.forbriger committed
33
 * REVISIONS and CHANGES 
34
35
 *  - 30/01/2014   V1.0   Thomas Forbriger (thof):
 *                        copied from readtsdata.h
thomas.forbriger's avatar
thomas.forbriger committed
36
37
38
39
40
 * 
 * ============================================================================
 */

// include guard
41
#ifndef TSIO_CMDLINEFILES_H_VERSION
thomas.forbriger's avatar
thomas.forbriger committed
42

43
44
45
46
#define TSIO_CMDLINEFILES_H_VERSION \
  "TF_CMDLINEFILES_H   2014/01/30"
#define TSIO_CMDLINEFILES_H_CVSID \
  "$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>
52
#include<tsioxx/sffheaders.h>
thomas.forbriger's avatar
thomas.forbriger committed
53
54
#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
/*! \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.
 *
62
63
64
65
66
67
 * This module is presented in file readtsdata.h
 *
 * It is placed ton top of the module presented in sffheaders.h
 * and supports to read a complete set of files as presented on the command
 * line together with all file specific parameters and trace selectors.
 *
thomas.forbriger's avatar
thomas.forbriger committed
68
69
 */

70
71
72
namespace ts {

  namespace sff {
thomas.forbriger's avatar
thomas.forbriger committed
73

thomas.forbriger's avatar
thomas.forbriger committed
74
75
76
77
78
79
80
81
82
83
84
85
    /*! \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
86
87
    typedef tfxx::RangeList<int> Ttracelist;

thomas.forbriger's avatar
thomas.forbriger committed
88
89
90
91
92
93
94
    /*! \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
95
    typedef const char* Ttracelistkey;
thomas.forbriger's avatar
thomas.forbriger committed
96

thomas.forbriger's avatar
thomas.forbriger committed
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

    /*! \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
123
124
125
126
127
128
129
130
131
132
133
134
    /*! \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
135
    struct DFile {
thomas.forbriger's avatar
thomas.forbriger committed
136
      //! provides reading into doubles
thomas.forbriger's avatar
thomas.forbriger committed
137
      typedef double Tvalue;
thomas.forbriger's avatar
thomas.forbriger committed
138
      //! container to be used
thomas.forbriger's avatar
thomas.forbriger committed
139
      typedef aff::Series<Tvalue> Tseries;
thomas.forbriger's avatar
thomas.forbriger committed
140
      //! file container
thomas.forbriger's avatar
thomas.forbriger committed
141
      typedef ts::sff::File<Tseries> Tfile;
thomas.forbriger's avatar
thomas.forbriger committed
142
      //! command line arguments
thomas.forbriger's avatar
thomas.forbriger committed
143
      tfxx::cmdline::Filename arguments;
thomas.forbriger's avatar
thomas.forbriger committed
144
      //! container to hold data headers and samples
thomas.forbriger's avatar
thomas.forbriger committed
145
      ts::sff::File<Tseries> data;
thomas.forbriger's avatar
thomas.forbriger committed
146
    }; // struct DFile
thomas.forbriger's avatar
thomas.forbriger committed
147

thomas.forbriger's avatar
thomas.forbriger committed
148
149
150
151
152
153
154
    /*! \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
155
    typedef std::list<DFile> TDFileList;
thomas.forbriger's avatar
thomas.forbriger committed
156
157
158
159
160
161
162
163
164

    /*! \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
165
    
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
    /*======================================================================*/

    /*! \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,
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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
     */
    DFile readDSFF(const std::string& filename,
                   const Ttracelist& selection,
                   const bool& verbose=false,
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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
     */
    DFile readDSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose=false,
                   Ttracelistkey tracekey="t",
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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
     */
    TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose=false,
                        Ttracelistkey tracekey="t",
                        const std::string& format=datrw::anyID(datrw::Fsff));
    
    /*----------------------------------------------------------------------*/

    /*! \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,
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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,
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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",
                   const std::string& format=datrw::anyID(datrw::Fsff));

    /*----------------------------------------------------------------------*/

    /*! \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",
                        const std::string& format=datrw::anyID(datrw::Fsff));

    /*======================================================================*/

thomas.forbriger's avatar
thomas.forbriger committed
341
342
343
344
345
346
347
348
349
350
351
352
353
354
    /*! \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,
355
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
356

357
358
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    /*! \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
373
    DFile readDSFF(const std::string& filename,
thomas.forbriger's avatar
thomas.forbriger committed
374
                   const Ttracelist& selection,
thomas.forbriger's avatar
thomas.forbriger committed
375
                   const bool& verbose=false,
376
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
377

378
379
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
    /*! \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
396
397
    DFile readDSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose=false,
thomas.forbriger's avatar
thomas.forbriger committed
398
                   Ttracelistkey tracekey="t",
399
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
400

401
402
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
    /*! \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
419
420
    TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose=false,
thomas.forbriger's avatar
thomas.forbriger committed
421
                        Ttracelistkey tracekey="t",
422
                        const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
423
    
424
425
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
426
427
428
429
430
431
432
433
434
435
436
437
438
439
    /*! \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,
440
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
441

442
443
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
    /*! \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,
462
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
463

464
465
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
    /*! \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",
486
                   const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
487

488
489
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
    /*! \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",
510
                        const datrw::Eformat& format=datrw::Fsff);
thomas.forbriger's avatar
thomas.forbriger committed
511

512
513
  } // namespace sff
} // namespace ts
thomas.forbriger's avatar
thomas.forbriger committed
514

515
#endif // TSIO_CMDLINEFILES_H_VERSION (includeguard)
thomas.forbriger's avatar
thomas.forbriger committed
516

517
/* ----- END OF cmdlinefiles.h ----- */