ProfilePCA.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2008 by Paul Demorest
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9#ifndef __Pulsar_ProfilePCA_h
10#define __Pulsar_ProfilePCA_h
11
12#include "Pulsar/Algorithm.h"
13
14namespace Pulsar
15{
16 class Profile;
17 class Integration;
18
20 class ProfilePCA : public Algorithm
21 {
22 public:
23
25 ProfilePCA ();
26
29
31 void set_nharm_pca(unsigned nharm);
32
34 void set_nharm_cov(unsigned nharm);
35
37 unsigned get_nharm_pca();
38
40 unsigned get_nharm_cov();
41
43 void reset();
44
46 void add_Profile (const Profile* p);
47
49 void add_Integration (const Integration* i);
50
52 void compute();
53
55 double get_cov_value(unsigned i, unsigned j);
56
58 double get_pc_value(unsigned i);
59
61 Profile* get_pc_vector(int i, unsigned nbin);
62
64 std::vector<double> decompose(const Profile *p, unsigned n_pc);
65
67 void unload(const std::string& filename);
68
70 static ProfilePCA *load(const std::string& filename);
71
72 protected:
73
75 unsigned nharm_cov;
76
78 unsigned nharm_pca;
79
81 double *cov;
82
84 double *mean;
85
87 unsigned nprof;
88
90 double wt_sum;
91
93 double wt2_sum;
94
96 std::vector<double> pc_values;
97
99 double *pc_vectors;
100
101 };
102
103}
104
105
106#endif
107
108
109
Data manipulation implementations.
Definition Algorithm.h:19
Array of Profiles integrated over the same time interval.
Definition Integration.h:37
void reset()
Reset sums to zero.
Definition ProfilePCA.C:79
unsigned nharm_cov
Number of harmonics to store.
Definition ProfilePCA.h:75
~ProfilePCA()
Destructor.
Definition ProfilePCA.C:39
unsigned get_nharm_pca()
Get the number of harmonics currently in use.
Definition ProfilePCA.C:74
double wt2_sum
Sum of squared weights.
Definition ProfilePCA.h:93
double get_pc_value(unsigned i)
Return i-th largest PC value (eigenvalue).
Definition ProfilePCA.C:200
ProfilePCA()
Default constructor.
Definition ProfilePCA.C:25
static ProfilePCA * load(const std::string &filename)
Load PCA results from a file.
Definition ProfilePCA.C:344
void set_nharm_cov(unsigned nharm)
Set the number of harmonics store in cov matrix.
Definition ProfilePCA.C:46
unsigned get_nharm_cov()
Get the number of harmonics currently stored.
Definition ProfilePCA.C:64
void add_Integration(const Integration *i)
Adds all Profiles in the given Integration to the analysis.
Definition ProfilePCA.C:131
std::vector< double > pc_values
Principal component values (eigenvalues)
Definition ProfilePCA.h:96
double * cov
Current covariance matrix.
Definition ProfilePCA.h:81
double get_cov_value(unsigned i, unsigned j)
Return i,j cov matrix entry.
Definition ProfilePCA.C:190
Profile * get_pc_vector(int i, unsigned nbin)
Return i-th largest PC vector (eigenvector) as Profile.
Definition ProfilePCA.C:213
void add_Profile(const Profile *p)
Adds the given Profile to the analysis.
Definition ProfilePCA.C:90
void compute()
Compute principal components.
Definition ProfilePCA.C:140
std::vector< double > decompose(const Profile *p, unsigned n_pc)
Decompose given Profile using first n_pc PCs.
Definition ProfilePCA.C:245
double wt_sum
Sum of weights.
Definition ProfilePCA.h:90
double * pc_vectors
Principal component vectors (eigenvectors)
Definition ProfilePCA.h:99
double * mean
Current mean profile.
Definition ProfilePCA.h:84
unsigned nharm_pca
Number of harmonics to store.
Definition ProfilePCA.h:78
unsigned nprof
Total number of profiles added.
Definition ProfilePCA.h:87
void set_nharm_pca(unsigned nharm)
Set the number of harmonics to use for PCA.
Definition ProfilePCA.C:69
void unload(const std::string &filename)
Unload the PCA results to a file.
Definition ProfilePCA.C:272
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0