ProfileShiftFit.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_ProfileShiftFit_h
10#define __Pulsar_ProfileShiftFit_h
11
12#include "Pulsar/Algorithm.h"
13#include "FTransform.h"
14#include "Estimate.h"
15#include "toa.h"
16#include "BoxMuller.h"
17
18namespace Pulsar
19{
20 class Profile;
21 class Integration;
22
24
44 {
45
46 public:
47
50 Traditional_Chi2, // Chi-squared 2nd derivatives
51 MCMC_Variance, // Shift variance from MCMC
52 Numerical, // Shift variance from numerical integration
53 };
54
57
60
62 void reset();
63
65 void set_nharm(unsigned nh);
66
68 unsigned get_nharm();
69
72
74 void set_mcmc_iterations(int nit) { mcmc_it = nit; }
75
77 int get_mcmc_iterations() const { return mcmc_it; }
78
80 void set_standard (const Profile* p);
81
83 void set_Profile (const Profile* p);
84
86 void compute();
87
89 Tempo::toa toa (const Integration*);
90
93
96
98 double get_mse();
99
101 double get_sigma2();
102
104 double get_snr();
105
107 double get_reduced_chisq () const;
108
110
114 double get_effective_duty_cycle () const;
115
118
121 int mcmc_accept;
122
125
126 protected:
127
129 void init();
130
132 void choose_nharm ();
133
135 unsigned nharm;
136
139
142
144 unsigned nbins_std;
145
147 float *fstd;
148
150 double std_pow;
151
154
156 unsigned nbins_prof;
157
159 float *fprof;
160
162 float *fccf;
163
165 unsigned nbins_ccf;
166
167
169 double ccf(double phi);
170
172 double dccf(double phi);
173
175 double d2ccf(double phi);
176
178 double log_shift_pdf(double phi);
179
181 double log_shift_pdf_pos(double phi);
182
185
187 void error_traditional();
188
190 void error_numerical();
191
193 void error_mcmc_pdf_var();
194
197
200
202 double shift;
203
205 double eshift;
206
209
211 double scale;
212
214 double escale;
215
217 double sigma2;
218
220 double mse;
221
223 double chi2;
224
226 unsigned dof;
227
229 double snr;
230
231 private:
232
234 BoxMuller nrand;
235
237 double mcmc_state;
238
240 double mcmc_log_pdf;
241
243 void mcmc_init();
244
246 double mcmc_sample();
247
249 double max_log_pdf;
250
252 static double f_pdf(double phi, void *_psf);
253 static double f_pdf_x2(double phi, void *_psf);
254
255 };
256
257}
258
259
260#endif
261
262
263
Data manipulation implementations.
Definition Algorithm.h:19
Array of Profiles integrated over the same time interval.
Definition Integration.h:37
int mcmc_trials
Current MCMC accept stats.
Definition ProfileShiftFit.h:120
double get_effective_duty_cycle() const
Get the effective duty cycle of the standard.
Definition ProfileShiftFit.C:591
void compute()
Run the fit.
Definition ProfileShiftFit.C:261
double escale
Current scale error.
Definition ProfileShiftFit.h:214
void reset()
Reset everything to zero, free internal memory.
Definition ProfileShiftFit.C:82
bool computed
Have valid results been computed.
Definition ProfileShiftFit.h:199
void set_standard(const Profile *p)
Set the standard or template profile to use.
Definition ProfileShiftFit.C:123
float * fccf
Current freq domain cross-correlation function.
Definition ProfileShiftFit.h:162
Reference::To< const Profile > prof
Current data profile.
Definition ProfileShiftFit.h:153
void apply_scale_and_shift(Profile *p)
Determine, then apply a shift a scale to data profile.
Definition ProfileShiftFit.C:621
void error_numerical()
Calculate "traditional" parameter uncertainties.
Definition ProfileShiftFit.C:474
int get_mcmc_iterations() const
Get number of iterations.
Definition ProfileShiftFit.h:77
double get_sigma2()
Get the resulting noise per harmonic.
Definition ProfileShiftFit.C:585
double mse
Current fit MSE.
Definition ProfileShiftFit.h:220
Error_Method
Method to use for calculating shift error.
Definition ProfileShiftFit.h:49
unsigned nharm
Number of harmonics to use.
Definition ProfileShiftFit.h:135
double log_shift_pdf_pos(double phi)
Same as above, but with scale>0 prior.
Definition ProfileShiftFit.C:350
double get_snr()
Get the resulting SNR.
Definition ProfileShiftFit.C:579
double scale
Current scale result.
Definition ProfileShiftFit.h:211
double get_reduced_chisq() const
Get the reduced chi-squared.
Definition ProfileShiftFit.C:612
double shift
Current shift result.
Definition ProfileShiftFit.h:202
Error_Method err_meth
Error method to use.
Definition ProfileShiftFit.h:184
double log_shift_pdf(double phi)
Returns log of a value proportional to the posterior shift PDF.
Definition ProfileShiftFit.C:343
double sigma2
Current sigma^2 estimate.
Definition ProfileShiftFit.h:217
double chi2
Current fit Chi^2 (not reduced)
Definition ProfileShiftFit.h:223
unsigned nbins_prof
Number of bins in profile.
Definition ProfileShiftFit.h:156
double std_pow
Template normalization factor.
Definition ProfileShiftFit.h:150
Estimate< double > get_scale()
Get the resulting scale factor.
Definition ProfileShiftFit.C:567
~ProfileShiftFit()
Destructor.
Definition ProfileShiftFit.C:80
double d2ccf(double phi)
Evaluate d^2(ccf)/d(phi)^2 at phase shift phi.
Definition ProfileShiftFit.C:241
unsigned get_nharm()
Get the number of harmonics currently in use.
Definition ProfileShiftFit.C:118
float * fprof
R2C FFT of current profile.
Definition ProfileShiftFit.h:159
void set_mcmc_iterations(int nit)
Set number of iterations for MCMC errors.
Definition ProfileShiftFit.h:74
double correction
Correction for profile nbins != template nbins.
Definition ProfileShiftFit.h:208
void error_traditional()
Calculate "traditional" parameter uncertainties.
Definition ProfileShiftFit.C:357
ProfileShiftFit()
Default constructor.
Definition ProfileShiftFit.C:74
void set_Profile(const Profile *p)
Set the data profile to use.
Definition ProfileShiftFit.C:164
void error_mcmc_pdf_var()
Calculate shift uncertainty as posterior PDF variance using MCMC.
Definition ProfileShiftFit.C:482
bool choose_maximum_harmonic
Set true when set_standard should choose the maximum harmonic.
Definition ProfileShiftFit.h:124
void set_error_method(Error_Method e)
Set the error method.
Definition ProfileShiftFit.h:71
unsigned nbins_std
Current template nbin.
Definition ProfileShiftFit.h:144
double ccf(double phi)
Evaluate ccf at phase shift phi.
Definition ProfileShiftFit.C:204
void set_nharm(unsigned nh)
Set the number of harmonics to use for fit.
Definition ProfileShiftFit.C:90
float * fstd
R2C FFT of current template.
Definition ProfileShiftFit.h:147
Tempo::toa toa(const Integration *)
Return a TOA object for the current fit.
Definition ProfileShiftFit.C:547
double dccf(double phi)
Evaluate d(ccf)/d(phi) at phase shift phi.
Definition ProfileShiftFit.C:222
unsigned dof
Current degrees of freedom.
Definition ProfileShiftFit.h:226
double snr
Current profile SNR.
Definition ProfileShiftFit.h:229
unsigned nbins_ccf
Number of bins in ccf.
Definition ProfileShiftFit.h:165
unsigned effective_nharm
Effective number of harmonics = min (nharm, nbins_prof/2-1)
Definition ProfileShiftFit.h:138
int mcmc_it
Number of iterations to use for MCMC.
Definition ProfileShiftFit.h:196
double eshift
Current shift error.
Definition ProfileShiftFit.h:205
void choose_nharm()
Choose the maximum number of harmonics using LastHarmonic.
Definition ProfileShiftFit.C:153
double get_mse()
Get the resulting Mean Squared Error (per fit DOF)
Definition ProfileShiftFit.C:573
void init()
Initialize vars.
Definition ProfileShiftFit.C:40
Estimate< double > get_shift()
Get the resulting shift.
Definition ProfileShiftFit.C:561
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
Defines the PSRCHIVE library.
Definition CalSource.h:17
STL namespace.

Generated using doxygen 1.14.0