CompareWith.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2021 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/General/Pulsar/CompareWith.h
10
11#ifndef __CompareWith_h
12#define __CompareWith_h
13
14#include "Pulsar/HasArchive.h"
15#include "Pulsar/TimeDomainCovariance.h"
16#include "Pulsar/ScrunchFactor.h"
17
18#include "ChiSquared.h"
19#include "ndArray.h"
20
21class BinaryStatistic;
22class UnaryStatistic;
23
24namespace Pulsar {
25
27
28 class CompareWith : public Reference::Able
29 {
30 protected:
31
34
37
40 unsigned nprimary;
41
44 unsigned ncompare;
45
48
50
52 bool use_null_space;
53
56
58 virtual void setup (unsigned start_primary, unsigned nprimary = 1);
59
62
65
66 void set (ndArray<2,double>& result,
67 unsigned iprimary, unsigned icompare,
68 double value);
69
71 void check ();
72
74 void compute_mean (unsigned start_primary, unsigned nprimary);
76
78
81
83 void get_amps (std::vector<double>& amps, const Profile* profile);
84
86 void get_residual (std::vector<double>& amps,
87 const std::vector<double>& mamps);
88
91
93 BinaryStatistics::ChiSquared chi;
94
96 virtual void compute (unsigned iprimary, ndArray<2,double>& result) = 0;
97
99 std::vector<bool> compute_mask;
100
102 FILE* fptr;
103
104 public:
105
106 CompareWith ();
107
108 void set_statistic (BinaryStatistic*);
109 void set_data (HasArchive*);
110
112 void set_setup_data (const Archive*);
113
116
118 const ScrunchFactor get_bscrunch () const { return bscrunch_factor; }
119
121 /* Not all comparisons require a global set up */
122 bool get_setup () { return is_setup; }
123
124 void set_transpose (bool);
125 void set_primary (unsigned n, void (HasArchive::*) (Index));
126 void set_compare (unsigned n, void (HasArchive::*) (Index));
127
128 void set_compare_all (bool flag = true) { compare_all = flag; }
129
131 void set_compute_mask (const std::vector<bool>& flags)
132 { compute_mask = flags; }
133
134 virtual void compute (ndArray<2,double>& result);
135
137 void set_file (FILE* f) { fptr = f; }
138
139 };
140}
141
142#endif
The primary interface to pulsar observational data.
Definition Archive.h:46
void set_bscrunch(const ScrunchFactor &f)
Compute covariance matrix from bscrunched clone of data.
Definition CompareWith.h:115
void compute_mean(unsigned start_primary, unsigned nprimary)
Compute the mean of the profiles to be compared.
Definition CompareWith.C:947
bool get_setup()
Return true if call to set_setup_data sets anything up.
Definition CompareWith.h:122
Reference::To< BinaryStatistic > statistic
Used to perform comparison.
Definition CompareWith.h:33
void set_file(FILE *f)
Set the file to which auxiliary data will be printed.
Definition CompareWith.h:137
void(HasArchive::* primary)(Index)
Pointer to the method used to loop over the primary dimension.
Definition CompareWith.h:39
HasArchive * data
Interface to the Archive.
Definition CompareWith.h:36
void set_compute_mask(const std::vector< bool > &flags)
Flags for subset of primary axis to be computed.
Definition CompareWith.h:131
void(HasArchive::* compare)(Index)
Pointer to the method used to loop over the compare dimension.
Definition CompareWith.h:43
bool is_setup
Set true when setup has completed during set_setup_data.
Definition CompareWith.h:64
virtual void setup(unsigned start_primary, unsigned nprimary=1)
Perform an eigenanalysis and set up the generalized chi squared.
Definition CompareWith.C:623
void get_residual(std::vector< double > &amps, const std::vector< double > &mamps)
Set amps to the residual after best fit of amps to mamps.
Definition CompareWith.C:228
const ScrunchFactor get_bscrunch() const
Get the phase bin scrunch factor.
Definition CompareWith.h:118
ScrunchFactor bscrunch_factor
Compute covariance matrix from bscrunched clone of data.
Definition CompareWith.h:80
bool model_residual
Compute the covariance matrix of the best-fit residual.
Definition CompareWith.h:51
bool transpose
Transpose indeces when computing results.
Definition CompareWith.h:55
BinaryStatistics::ChiSquared chi
Used to compute the residual.
Definition CompareWith.h:93
Reference::To< Profile > temp
After call to get_residual, also stores residual profile amplitudes.
Definition CompareWith.h:90
virtual void compute(unsigned iprimary, ndArray< 2, double > &result)=0
Compute the comparison summary for primary dimension.
std::vector< bool > compute_mask
Flags for subset of sub-integrations to be computed.
Definition CompareWith.h:99
void check()
Check that necessary attributes have been set.
Definition CompareWith.C:131
void set_setup_data(const Archive *)
Use to compute the covariance matrix before an fscrunch or tscrunch.
Definition CompareWith.C:83
FILE * fptr
File to which auxiliary data will be printed.
Definition CompareWith.h:102
bool setup_completed
Set true when setup has completed.
Definition CompareWith.h:61
void get_amps(std::vector< double > &amps, const Profile *profile)
Set amps to the normalized and bscrunched profile amplitudes.
Definition CompareWith.C:187
bool compare_all
Compare over both dimensions.
Definition CompareWith.h:47
Manages an archive and its index interface.
Definition HasArchive.h:25
Combines an index value and integrate flag.
Definition Index.h:19
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
Manages a combined scrunch factor or target dimension.
Definition ScrunchFactor.h:21
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0