RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
psd_est.cpp
Go to the documentation of this file.
1 //
2 // file = psd_est.cpp
3 //
4 
5 #include <iostream>
6 #include <stdlib.h>
7 
8 #include "psd_est.h"
9 
10 using namespace std;
11 
12 PsdEstimate::PsdEstimate(int num_samps, double samp_intvl)
13 {
14  Num_Samps = num_samps;
15  Delta_F = 1.0 / samp_intvl / num_samps;
16  Delta_T = samp_intvl;
17  Psd_Est = new double[Num_Samps];
18 }
19 void
20 PsdEstimate::DumpNumeric(ofstream* out_file, CpfskSpectrum* ref_spec)
21 {
22  int samp_idx;
23  double freq, value, theor_val;
24  for (samp_idx = 0; samp_idx < Num_Samps / 2; samp_idx++) {
25  freq = samp_idx * Delta_F;
26  theor_val = ref_spec->GetPsdValue(freq);
27  value = Psd_Est[samp_idx];
28  (*out_file) << freq << ", " << value << ", " << theor_val << std::endl;
29  }
30 };
31 
32 void
33 PsdEstimate::DumpNumeric(ofstream* out_file)
34 {
35  int samp_idx;
36  double freq, value;
37  for (samp_idx = 0; samp_idx < Num_Samps / 2; samp_idx++) {
38  freq = samp_idx * Delta_F;
39  value = Psd_Est[samp_idx];
40  (*out_file) << freq << ", " << value << std::endl;
41  }
42 };
43 
44 void
45 PsdEstimate::DumpDecibels(ofstream* out_file, CpfskSpectrum* ref_spec)
46 {
47  int samp_idx;
48  double freq, value, theor_val;
49  for (samp_idx = 0; samp_idx < Num_Samps / 2; samp_idx++) {
50  freq = samp_idx * Delta_F;
51  theor_val = 10.0 * log10(ref_spec->GetPsdValue(freq));
52  value = 10.0 * log10(Psd_Est[samp_idx]);
53  (*out_file) << freq << ", " << value << ", " << theor_val << std::endl;
54  }
55 };
56 void
57 PsdEstimate::DumpDecibels(ofstream* out_file)
58 {
59  int samp_idx;
60  double freq, value;
61  for (samp_idx = 0; samp_idx < Num_Samps / 2; samp_idx++) {
62  freq = samp_idx * Delta_F;
63  value = 10.0 * log10(Psd_Est[samp_idx]);
64  (*out_file) << freq << ", " << value << std::endl;
65  }
66 };
void DumpDecibels(std::ofstream *out_stream, CpfskSpectrum *ref_spect)
void DumpNumeric(std::ofstream *out_stream, CpfskSpectrum *ref_spect)
double GetPsdValue(double freq)
Definition: fsk_spec.cpp:58
PsdEstimate(int num_samps, double samp_intvl)
Definition: psd_est.cpp:12