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 
14 namespace Pulsar
15 {
16  class Profile;
17  class Integration;
18 
20  class ProfilePCA : public Algorithm
21  {
22  public:
23 
26 
28  ~ProfilePCA();
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 
double * mean
Current mean profile.
Definition: ProfilePCA.h:89
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:98
void reset()
Reset sums to zero.
Definition: ProfilePCA.C:79
void add_Integration(const Integration *i)
Adds all Profiles in the given Integration to the analysis.
Definition: ProfilePCA.C:131
double * cov
Current covariance matrix.
Definition: ProfilePCA.h:86
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition: ProfileAmps.C:141
double * pc_vectors
Principal component vectors (eigenvectors)
Definition: ProfilePCA.h:104
void frc1d(size_t nfft, float *into, const float *from)
float get_weight() const
get the weight of the profile
Definition: Profile.h:207
double wt_sum
Sum of weights.
Definition: ProfilePCA.h:95
void compute()
Compute principal components.
Definition: ProfilePCA.C:140
void bcr1d(size_t nfft, float *into, const float *from)
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
unsigned get_nbin() const
Return the number of bins.
Definition: ProfileAmps.h:50
~ProfilePCA()
Destructor.
Definition: ProfilePCA.C:39
double get_cov_value(unsigned i, unsigned j)
Return i,j cov matrix entry.
Definition: ProfilePCA.C:190
Type * release()
static ProfilePCA * load(const std::string &filename)
Load PCA results from a file.
Definition: ProfilePCA.C:344
unsigned nharm_pca
Number of harmonics to store.
Definition: ProfilePCA.h:83
void set_nharm_pca(unsigned nharm)
Set the number of harmonics to use for PCA.
Definition: ProfilePCA.C:69
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 unload(const std::string &filename)
Unload the PCA results to a file.
Definition: ProfilePCA.C:272
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
Examines profile shape variation with principal components analysis.
Definition: ProfilePCA.h:25
std::vector< double > pc_values
Principal component values (eigenvalues)
Definition: ProfilePCA.h:101
std::vector< double > decompose(const Profile *p, unsigned n_pc)
Decompose given Profile using first n_pc PCs.
Definition: ProfilePCA.C:245
ProfilePCA()
Default constructor.
Definition: ProfilePCA.C:25
void set_nharm_cov(unsigned nharm)
Set the number of harmonics store in cov matrix.
Definition: ProfilePCA.C:46
unsigned nharm_cov
Number of harmonics to store.
Definition: ProfilePCA.h:80
virtual unsigned get_nchan() const =0
Get the number of chans.
Defines the PSRCHIVE library.
Definition: CalSource.h:17
unsigned nprof
Total number of profiles added.
Definition: ProfilePCA.h:92
Profile * get_Profile(unsigned ipol, unsigned ichan)
Returns a pointer to the Profile given by the specified indeces.
Definition: Integration.C:306
unsigned get_nharm_cov()
Get the number of harmonics currently stored.
Definition: ProfilePCA.C:64
double get_pc_value(unsigned i)
Return i-th largest PC value (eigenvalue).
Definition: ProfilePCA.C:200

Generated using doxygen 1.8.17