Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Tdrt-TDT-Reference.h
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef TDRT_TDT_REFERENCE_H_
25 #define TDRT_TDT_REFERENCE_H_
26 
27 #include "cheetah/tdrt/TimeSeries.h"
28 #include <tuple>
29 
30 namespace ska {
31 namespace cheetah {
32 namespace tdrt {
33 namespace test {
34 
42 {
43  public:
45 
46  void process(TimeSeries<float>& h_input,
47  TimeSeries<float>& h_output,
48  float acceleration); // m/s/s
49 
50 
51  // Data generators:
52 
53  // Simulates a pulsar with a constant acceleration.
54  // Each simulated pulse is one-bin wide and has an amplitude =1.
55  // More often than not, I new pulse does not land exactly in a time bin,
56  // so the signal is distributed appropriately between two bins.
57 
58  void const_accel_pulsar(double acceleration, // m/s/s
59  float period, // s
60  TimeSeries<float>& h_output);
61 
62  // sine generator for calibration. period in sec.
63  void sine_calibration_signal(float period, TimeSeries<float>& h_output);
64 
65  // Resampled period:
66 
67  // Calculates the new period of the pulsar after resampling
68  // Can be used to verify that resample functions working correctly
69  double resampled_period(double acceleration, double period, double tsamp, int length);
70 
71  // Data checkers:
72 
73  // The simplest way to compare the two output vectors is to take the
74  // correlation (SUM(tsA[i]*tsB[i]). In this function I normalize the
75  // Correlation by the number of pulses found. Given the nature of the
76  // input vectors, this will yield a correlation = 1 when they're identical.
77  // One "feature" to this test is it will be highly sensitive to the pulses
78  // being off even by potentially one bin. It may or may not be too stringent.
79 
80  float tdrt_correlation(TimeSeries<float>& h_tsA, TimeSeries<float>& h_tsB);
81 
82 
83  // This function moves through each vector, records the location of each
84  // pulse, finds the difference pulse-wise between the two vectors, sums
85  // these differences, and normalizes by the number of pulses. In short,
86  // this is an mean difference in the locations of what should be nominally
87  // the same pulse. In the ideal case this is zero.
88 
89  float tdrt_bin_diff(TimeSeries<float>& h_tsA, TimeSeries<float>& h_tsB);
90 
91  // Calculates the mean recovered amplitude for each time series independently
92  // and then compare the results
93 
94  // Folds a time series with given period
95  // NOTE: This will only work with integer periods
96  // The function casts period to an int and folds accordingly
97  // It then find the bin with the max value and reports the sum of the
98  // max bin and +/- adjacent bins from the max
99  double fold_pulsar(TimeSeries<float>& h_ts, double period, int adjacent);
100 
101  std::tuple<float, size_t> tdrt_recover_amp(TimeSeries<float>& h_ts);
102 
103  void tdrt_bin_spacing(TimeSeries<float>& h_ts);
104 
105  private:
106 };
107 
108 } // namespace test
109 } // namespace tdrt
110 } // namespace cheetah
111 } // namespace ska
112 
113 #endif /* TDRT_TDT_REFERENCE_H_ */
Some limits and constants for FLDO.
Definition: Brdz.h:35
void process(TimeSeries< float > &h_input, TimeSeries< float > &h_output, float acceleration)
Time Domain Resampler Reference Model.