Calculates profile shifts by fitting to a template/standard. More...

#include <ProfileShiftFit.h>

Inheritance diagram for Pulsar::ProfileShiftFit:
Pulsar::Algorithm Reference::Able Reference::HeapTracked

Public Types

enum  Error_Method { Traditional_Chi2, MCMC_Variance, Numerical }
 Method to use for calculating shift error.
 

Public Member Functions

 ProfileShiftFit ()
 Default constructor.
 
 ~ProfileShiftFit ()
 Destructor.
 
void reset ()
 Reset everything to zero, free internal memory.
 
void set_nharm (unsigned nh)
 Set the number of harmonics to use for fit.
 
unsigned get_nharm ()
 Get the number of harmonics currently in use.
 
void set_error_method (Error_Method e)
 Set the error method.
 
void set_mcmc_iterations (int nit)
 Set number of iterations for MCMC errors.
 
int get_mcmc_iterations () const
 Get number of iterations.
 
void set_standard (const Profile *p)
 Set the standard or template profile to use.
 
void set_Profile (const Profile *p)
 Set the data profile to use.
 
void compute ()
 Run the fit.
 
Tempo::toa toa (const Integration *)
 Return a TOA object for the current fit.
 
Estimate< double > get_shift ()
 Get the resulting shift.
 
Estimate< double > get_scale ()
 Get the resulting scale factor.
 
double get_mse ()
 Get the resulting Mean Squared Error (per fit DOF)
 
double get_sigma2 ()
 Get the resulting noise per harmonic.
 
double get_snr ()
 Get the resulting SNR.
 
double get_reduced_chisq () const
 Get the reduced chi-squared.
 
double get_effective_duty_cycle () const
 Get the effective duty cycle of the standard. More...
 
void apply_scale_and_shift (Profile *p)
 Determine, then apply a shift a scale to data profile. More...
 
- Public Member Functions inherited from Reference::Able
 Able (const Able &)
 
Ableoperator= (const Able &)
 
unsigned get_reference_count () const
 
- Public Member Functions inherited from Reference::HeapTracked
 HeapTracked (const HeapTracked &)
 
HeapTrackedoperator= (const HeapTracked &)
 
bool __is_on_heap () const
 

Public Attributes

int mcmc_trials
 Current MCMC accept stats.
 
int mcmc_accept
 
bool choose_maximum_harmonic
 Set true when set_standard should choose the maximum harmonic.
 

Protected Member Functions

void init ()
 Initialize vars.
 
void choose_nharm ()
 Choose the maximum number of harmonics using LastHarmonic.
 
double ccf (double phi)
 Evaluate ccf at phase shift phi.
 
double dccf (double phi)
 Evaluate d(ccf)/d(phi) at phase shift phi.
 
double d2ccf (double phi)
 Evaluate d^2(ccf)/d(phi)^2 at phase shift phi.
 
double log_shift_pdf (double phi)
 Returns log of a value proportional to the posterior shift PDF.
 
double log_shift_pdf_pos (double phi)
 Same as above, but with scale>0 prior.
 
void error_traditional ()
 Calculate "traditional" parameter uncertainties.
 
void error_numerical ()
 Calculate "traditional" parameter uncertainties.
 
void error_mcmc_pdf_var ()
 Calculate shift uncertainty as posterior PDF variance using MCMC.
 
- Protected Member Functions inherited from Reference::Able
Handle__reference (bool active) const
 
void __dereference (bool auto_delete=true) const
 

Protected Attributes

unsigned nharm
 Number of harmonics to use.
 
unsigned effective_nharm
 Effective number of harmonics = min (nharm, nbins_prof/2-1)
 
Reference::To< const Profilestd
 Current template profile.
 
unsigned nbins_std
 Current template nbin.
 
float * fstd
 R2C FFT of current template.
 
double std_pow
 Template normalization factor.
 
Reference::To< const Profileprof
 Current data profile.
 
unsigned nbins_prof
 Number of bins in profile.
 
float * fprof
 R2C FFT of current profile.
 
float * fccf
 Current freq domain cross-correlation function.
 
unsigned nbins_ccf
 Number of bins in ccf.
 
Error_Method err_meth
 Error method to use.
 
int mcmc_it
 Number of iterations to use for MCMC.
 
bool computed
 Have valid results been computed.
 
double shift
 Current shift result.
 
double eshift
 Current shift error.
 
double correction
 Correction for profile nbins != template nbins.
 
double scale
 Current scale result.
 
double escale
 Current scale error.
 
double sigma2
 Current sigma^2 estimate.
 
double mse
 Current fit MSE.
 
double chi2
 Current fit Chi^2 (not reduced)
 
unsigned dof
 Current degrees of freedom.
 
double snr
 Current profile SNR.
 

Additional Inherited Members

- Static Public Member Functions inherited from Reference::Able
static size_t get_instance_count ()
 
- Static Public Member Functions inherited from Reference::HeapTracked
static void * operator new (size_t size, void *ptr=0)
 
static void operator delete (void *location, void *ptr)
 
static void operator delete (void *location)
 
static size_t get_heap_queue_size ()
 

Detailed Description

Calculates profile shifts by fitting to a template/standard.

This class essentially reimplements the standard "Taylor fftfit" timing algorithm (used in PSRCHIVE's PhaseGradientShift method, etc). This has several benefits over the existing implementation in model_profile.C:

  1. It caches the FFT'd template, resulting in about half as many FFT calls (when timing many profiles) versus the old routines.
  2. It uses only the standard PSRCHIVE FFT interface, and avoids the old Fortran "fccf" routines.
  3. The Chi2 minimization procedure is much more straightforward - at least in the author's opinion ;)
  4. Additional information (fitted amplitude, profile sigma, etc) is returned in a cleaner, more extensible object oriented way.
  5. Supports multiple/alternate phase shift error calculation algorithms.

Member Function Documentation

◆ apply_scale_and_shift()

void Pulsar::ProfileShiftFit::apply_scale_and_shift ( Profile p)

Determine, then apply a shift a scale to data profile.

Convenience function to determine, then apply, scale and shift.

References Pulsar::Profile::rotate_phase(), and Pulsar::Profile::scale().

◆ get_effective_duty_cycle()

double Pulsar::ProfileShiftFit::get_effective_duty_cycle ( ) const

Get the effective duty cycle of the standard.

Refer to Equation 13 of van Straten (2006) or Equation B1 of Downs & Reichley (1983) [these equations are Fourier transform pairs]. The effective duty cycle is obtained when gain, g, and noise, sigma, both equal unity.

References Pulsar::ProfileStats::get_onpulse_nbin(), Pulsar::ProfileStats::get_total(), Estimate< class, class >::get_value(), and Pulsar::ProfileStats::set_profile().


The documentation for this class was generated from the following files:

Generated using doxygen 1.8.17