croposp.h 4.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*! \file croposp.h
 * \brief declaration of classes, types and functions used in croposp 
 * 
 * ----------------------------------------------------------------------------
 * 
 * \author Thomas Forbriger
 * \date 06/02/2019
 * 
 * declaration of classes, types and functions used in croposp (prototypes)
 * 
 * Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach) 
 * 
 * ----
 * 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, see <http://www.gnu.org/licenses/>.
 * ----
 *
 * REVISIONS and CHANGES 
 *  - 06/02/2019   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */
#define CROPOSP_VERSION \
  "CROPOSP   V1.0   Cross power spectral density"

// include guard
#ifndef CROPOSP_H_VERSION

#define CROPOSP_H_VERSION \
  "CROPOSP_H   V1.0"

#include <string>
#include <vector>
#include <tfxx/commandline.h>
#include <tfxx/xcmdline.h>
#include <tsxx/wid2timeseries.h>
#include <tsxx/tscollection.h>
#include <psdxx/psd.h>

namespace croposp {

  // a struct to hold meta data
  struct Meta {
    tfxx::cmdline::Filename filearguments;
    std::string label;
  }; // struct Meta

  // type of time series collection to hold input data
  typedef ts::TimeSeriesCollection<double> TCollection;
  // a vector to gold meta data for each time series
  typedef std::vector<Meta> TMetaVector;

  // a struct to hold computation results for exactly one series
  struct NamedSeries {
    std::string label;
66
    psd::TDseries::Tcoc series;
67
68
  }; // struct NamedSeries

69
70
71
  // a struct to hold computation results cross PSD
  struct NamedCPSD {
    std::string label;
72
    psd::TDCseries::Tcoc series;
73
74
  }; // struct NamedCPSD

75
76
77
  // a vector type to hold results
  typedef std::vector<NamedSeries> TNamedSeriesVector;

78
79
80
  // a vector type to hold results
  typedef std::vector<NamedCPSD> TNamedCPSDVector;

81
82
83
84
85
86
87
88
89
90
91
92
  /* ====================================================================== */
  /* classes
   * -------
   */

  /*! provide index values to pairs 
   *
   * cycle through a complete set
   */
  class Pairs {
    public:
      Pairs(const unsigned int& n);
93
94
95
96
97
98
99
100
      unsigned int operator()(const unsigned int& k,
                              const unsigned int& l) const;
      bool swap(const unsigned int& k,
                const unsigned int& l) const;
      unsigned int size() const;
      unsigned int pairs() const;
    private:
      unsigned int Mn;
101
102
  }; // class Pairs

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  /* ---------------------------------------------------------------------- */

  /*! provide index values to triples 
   *
   * cycle through a complete set
   */
  class Triples {
    public:
      Triples(const Pairs& p, const bool& pairs_first=false);
      unsigned int operator()(const unsigned int& k,
                              const unsigned int& l) const;
      bool swap(const unsigned int& k,
                const unsigned int& l) const;
      unsigned int size() const;
      unsigned int pairs() const;
      unsigned int triples() const;
    private:
      Pairs Mpairs;
      bool Mpairs_first;
  }; // class Triples

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  /* ====================================================================== */
  /* functions
   * ---------
   */

  std::string patsubst(const std::string& templatestring,
                       const std::string& pattern,
                       const std::string& content);

  void report_collection(const TCollection& collection,
                         const TMetaVector& metadata,
                         const bool& debug=false);

  void write_named_series(const std::string& filename,
                          const std::string& comment,
                          psd::TDseries f,
                          const TNamedSeriesVector& nsv,
                          const bool& verbose,
                          const bool& overwrite=true);

} // namespace croposp

#endif // TF_CROPOSP_H_VERSION (includeguard)

/* ----- END OF croposp.h ----- */