Any quantity recorded as a function of pulse phase. More...

#include <Profile.h>

Inheritance diagram for Pulsar::Profile:
Pulsar::ProfileAmps Pulsar::Container Reference::Able Reference::HeapTracked

Classes

class  Extension
class  Strategies
 Manages the strategies that implement algorithms. More...

Public Types

typedef Functor< std::pair< int, int >(const Profile *) > Edges

Public Member Functions

 Profile (unsigned nbin=0)
 Default constructor.
 Profile (const Profile &profile)
 copy constructor
 Profile (const Profile *profile)
 copy constructor
 ~Profile ()
 destructor
virtual Profileclone () const
 returns a pointer to a new copy of self
virtual void resize (unsigned nbin)
 resize the data area
const Profileoperator= (const Profile &profile)
 assignment operator
void copy (const Profile *, bool clone_strategy=true)
 does the work for copy constructor and assignment operator
void average (const Profile *that)
 set this to the weighted average of this and that
void sum (const Profile *profile)
 add profile to this
void diff (const Profile *profile)
 subtract profile from this
const Profileoperator+= (float offset)
 adds offset to each bin of the profile
const Profileoperator-= (float offset)
 subtracts offset from each bin of the profile
const Profileoperator*= (float scale)
 multiplies each bin of the profile by scale
void scale (double scale)
 multiplies each bin of the profile by scale
void offset (double offset)
 offsets each bin of the profile by offset
void rotate_phase (double phase)
 rotates the profile by phase (in turns)
void derivative ()
 compute the derivative of profile with respect to index
void zero ()
 set all amplitudes to zero
void square_root ()
 calculate the signed sqrt of the absolute value of each bin
void absolute ()
 calculare the absolute value of each phase bin
void logarithm (double base=10.0, double threshold=0.0)
 calculate the logarithm of each bin with value greater than threshold
float max (int bin_start=0, int bin_end=0) const
 Returns the maximum amplitude.
float min (int bin_start=0, int bin_end=0) const
 Returns the minimum amplitude.
double sum (int bin_start=0, int bin_end=0) const
 Returns the sum of all amplitudes.
double sumsq (int bin_start=0, int bin_end=0) const
 Returns the sum of all amplitudes squared.
double sumfabs (int bin_start=0, int bin_end=0) const
 Returns the sum of the absolute value.
void stats (double *mean, double *variance=0, double *varmean=0, int bin_start=0, int bin_end=0) const
 Calculates the mean, variance, and variance of the mean.
void stats (float phase, double *mean, double *variance=0, double *varmean=0, float duty_cycle=default_duty_cycle) const
 Convenience interface to stats (start_bin, end_bin)
double mean (float phase, float duty_cycle=default_duty_cycle) const
 Convenience interface to stats, returns only the mean.
float find_max_phase (float duty_cycle=default_duty_cycle) const
 Returns the phase of the centre of the region with maximum mean.
float find_min_phase (float duty_cycle=default_duty_cycle) const
 Returns the phase of the centre of the region with minimum mean.
void find_transitions (int &highlow, int &lowhigh, int &width) const
 Find the bin numbers at which the mean power transits.
int find_max_bin (int bin_start=0, int bin_end=0) const
 Returns the bin number with the maximum amplitude.
int find_min_bin (int bin_start=0, int bin_end=0) const
 Returns the bin number with the minimum amplitude.
void find_peak_edges (int &rise, int &fall) const
 Find the bin numbers at which the cumulative power crosses thresholds.
Strategiesget_strategy () const
 Returns the strategy manager.
void set_strategy (Strategies *)
 Set the strategy manager.
PhaseWeightbaseline () const
 Return a new PhaseWeight instance with the baseline phase bins masked.
float snr () const
 Returns the signal to noise ratio of the profile.
void dedisperse (double dm, double ref_freq, double pfold)
 Rotates the profile to remove dispersion delay.
Estimate< double > shift (const Profile &std) const
 Returns the shift (in turns) between profile and standard.
std::vector< float > get_weighted_amps () const
double get_centre_frequency () const
 get the centre frequency (in MHz)
virtual void set_centre_frequency (double cfreq)
 set the centre frequency (in MHz)
float get_weight () const
 get the weight of the profile
virtual void set_weight (float)
 set the weight of the profile
void fft_convolve (const Profile *profile)
 convolves this with the given profile (using fft method)
void convolve (const Profile *profile)
 convolves this with the given profile in time domain
void correlate (const Profile *profile)
 cross-correlates this with the given profile in time domain
void correlate_normalized (const Profile *profile)
 cross-correlates and normalizes this with the given profile in time domain
void pscrunch ()
 some extensions may have to respond to pscrunch
void bscrunch (unsigned nscrunch)
 integrate neighbouring phase bins in profile
void bscrunch_to_nbin (unsigned nbin)
 integrate neighbouring phase bins in profile
void fold (unsigned nfold)
 integrate neighbouring sections of the profile
template<class T>
const T * get () const
template<class T>
T * get ()
Public Member Functions inherited from Pulsar::ProfileAmps
 ProfileAmps (unsigned nbin=0)
 Constructor initializes the data array.
virtual ~ProfileAmps ()
 Destructor destroys the data array.
 ProfileAmps (const ProfileAmps &)
 Copy constructor.
unsigned get_nbin () const
 Return the number of bins.
const float * get_amps () const
 Return a pointer to the amplitudes array.
float * get_amps ()
 Return a pointer to the amplitudes array.
template<typename T>
void set_amps (const T *data)
 set the amplitudes array equal to the contents of the data array
template<typename T>
void set_amps (const std::vector< T > &data)
 set the amplitudes array equal to the contents of the data array
template<typename T>
void get_amps (std::vector< T > &data) const
 set the amplitudes array equal to the contents of the data array
void remove (const std::vector< unsigned > &indeces)
 remove the elements specified in the array of indeces
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

Static Public Member Functions

static unsigned get_instance_count ()
 returns the number of Profile instances
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 ()

Static Public Attributes

static bool verbose = false
 flag controls the amount output to stderr by Profile methods
static bool rotate_phase_enabled = true
 Rotation of pulse phase is enabled by default.
static Option< bool > rotate_in_phase_domain
 When true, Profile::rotate shifts bins in the phase domain.
static Option< float > transition_duty_cycle
 fractional phase window used to find rise and fall of running mean
static Option< float > default_duty_cycle
 fractional phase window used in most functions
static Option< Edgespeak_edges_strategy
 The default implementation of the edge detection algorithm.
Static Public Attributes inherited from Pulsar::ProfileAmps
static bool no_amps = false
 When true, no memory is allocated for amps.

Friends

class Integration
 The Integration class may call protected methods.

Extension Interface

Additional algorithms or information can be made available through use of Extension classes.

class PolnProfile
 centre frequency of profile (in MHz)
class StandardSNR
 centre frequency of profile (in MHz)
double centrefreq
 centre frequency of profile (in MHz)
float weight
 weight of profile
std::vector< Reference::To< Extension > > extension
 The Extensions added to this Profile instance.
Reference::To< Strategiesstrategy
 The strategy manager.
virtual unsigned get_nextension () const
 Return the number of extensions available.
virtual const Extensionget_extension (unsigned iextension) const
 Return a pointer to the specified extension.
virtual Extensionget_extension (unsigned iextension)
 Return a pointer to the specified extension.
template<class ExtensionType>
const ExtensionType * get () const
 Template method searches for an Extension of the specified type.
template<class ExtensionType>
ExtensionType * get ()
 Template method searches for an Extension of the specified type.
virtual void add_extension (Extension *extension)
 Add an Extension to this instance.
void convolve (const Profile *profile, int direction)
 does the work for convolve and correlate
void init ()
 initializes all values to null

Additional Inherited Members

Protected Member Functions inherited from Reference::Able
Handle__reference (bool active) const
void __dereference (bool auto_delete=true) const

Detailed Description

Any quantity recorded as a function of pulse phase.

The Pulsar::Profile class implements a useful, yet minimal, set of functionality required to store, manipulate, and analyse pulsar profiles. Note that:

  • All methods that change the size of a Profile are protected.
  • The Integration class is declared as a friend.

This arrangement protects the size of each Profile object from becoming unsynchronized with the Integration in which it is contained. The data in each Profile may still be manipulated through public methods.

Member Function Documentation

◆ add_extension()

void Pulsar::Profile::add_extension ( Extension * ext)
virtual

Add an Extension to this instance.

The derived class must ensure that only one instance of the Extension type is stored.

Derived classes need only define this method, as the non-const version implemented by the Profile base class simply calls this method.

References extension, and verbose.

Referenced by copy().

◆ average()

void Pulsar::Profile::average ( const Profile * profile)

set this to the weighted average of this and that

A series of additions using this operator preserves the relationship:

$ \bar{x} = \sum_{i=1}^N W(x_i) x_i / W(\bar{x}) $

where $ W(x_i) $ is the weight assigned to $ x_i $ and

$ W(\bar{x}) = \sum_{i=1}^N W(x_i) $

References extension, Pulsar::Profile::Extension::integrate(), and Profile().

Referenced by Pulsar::Integration::combine(), Pulsar::FrequencyIntegrate::transform(), and Pulsar::TimeIntegrate::transform().

◆ baseline()

Pulsar::PhaseWeight * Pulsar::Profile::baseline ( ) const

Return a new PhaseWeight instance with the baseline phase bins masked.

Return a PhaseWeight mask with the baseline phase bins enabled.

References baseline(), Pulsar::Profile::Strategies::baseline(), get_strategy(), Pulsar::ProfileWeightFunction::operate(), and verbose.

Referenced by baseline(), Pulsar::FluxPlot::get_flux_error(), Pulsar::AdaptiveSNR::get_snr(), and Pulsar::FortranSNR::get_snr().

◆ dedisperse()

void Pulsar::Profile::dedisperse ( double dm,
double ref_freq,
double pfold )

Rotates the profile to remove dispersion delay.

A convenience interface to Profile::rotate_phase. Rotates the profile in order to remove the dispersion delay with respect to a reference frequency.

Parameters
dmthe dispersion measure (in ${\rm pc\, cm}^{-3}$)
ref_freqthe reference frequency (in MHz)
pfoldthe folding periond (in seconds)

References centrefreq, rotate_phase(), and verbose.

◆ find_max_phase()

float Pulsar::Profile::find_max_phase ( float duty_cycle = default_duty_cycle) const

Returns the phase of the centre of the region with maximum mean.

Returns the centre phase of the region with maximum mean

Parameters
duty_cyclewidth of the region over which the mean is calculated

References Pulsar::ProfileAmps::get_amps(), Pulsar::ProfileAmps::get_nbin(), mean(), and verbose.

Referenced by Pulsar::Statistics::get_peak().

◆ find_min_phase()

float Pulsar::Profile::find_min_phase ( float duty_cycle = default_duty_cycle) const

Returns the phase of the centre of the region with minimum mean.

Returns the centre phase of the region with minimum mean

Parameters
duty_cyclewidth of the region over which the mean is calculated

References Pulsar::ProfileAmps::get_amps(), Pulsar::ProfileAmps::get_nbin(), mean(), and verbose.

Referenced by Pulsar::find_spike_edges(), Pulsar::NoiseStatistics::get_nfnr(), Pulsar::PhaseSNR::get_snr(), and Pulsar::InfoLabel::plot().

◆ find_transitions()

void Pulsar::Profile::find_transitions ( int & hi2lo,
int & lo2hi,
int & width ) const

Find the bin numbers at which the mean power transits.

Finds the transitions at which the mean power of a sliding window drops below the mean power (high to low) and at which it jumps back above the mean power (low to high). The function is best-suited to detect the transitions of a pulsed calibrator profile, which is usually a square wave with 0.5 duty cycle. The width of the sliding window is given by Pulsar::Profile::transition_duty_cycle.

Return values
hi2lobin at which the mean power drops (from left to right)
lo2hibin at which the mean power jumps (from left to right)
widthnumber of bins in the sliding window used to find transitions

References Pulsar::ProfileAmps::get_amps(), Pulsar::ProfileAmps::get_nbin(), stats(), transition_duty_cycle, and verbose.

Referenced by Pulsar::ProfilePlot::draw_transitions(), and Pulsar::SquareWave::get_snr().

◆ get() [1/2]

template<class T>
T * Pulsar::Profile::get ( )

e.g. Profile* profile; MyExtension* ext = profile->get<MyExtension>();

References verbose.

◆ get() [2/2]

template<class T>
const T * Pulsar::Profile::get ( ) const

e.g. const Profile* profile; const MyExtension* ext = profile->get<MyExtension>();

References verbose.

◆ get_extension() [1/2]

Pulsar::Profile::Extension * Pulsar::Profile::get_extension ( unsigned iext)
virtual

Return a pointer to the specified extension.

Simply calls get_extension const

References extension.

◆ get_extension() [2/2]

const Pulsar::Profile::Extension * Pulsar::Profile::get_extension ( unsigned iext) const
virtual

Return a pointer to the specified extension.

Derived classes need only define this method, as the non-const version implemented by the Profile base class simply calls this method.

References extension.

Referenced by copy().

◆ get_weighted_amps()

vector< float > Pulsar::Profile::get_weighted_amps ( ) const

returns a vector representation of the array of amplitudes, with all zero-weighted points cleaned out

References Pulsar::ProfileAmps::get_amps(), Pulsar::ProfileAmps::get_nbin(), and weight.

Referenced by Pulsar::LinePhasePlot::draw().

◆ mean()

double Pulsar::Profile::mean ( float phase,
float duty_cycle = default_duty_cycle ) const

Convenience interface to stats, returns only the mean.

Parameters
phasecentre of region
duty_cyclewidth of region
Returns
mean of region

References Pulsar::phase(), and stats().

Referenced by correlate_normalized(), find_max_phase(), find_min_phase(), Pulsar::find_spike_edges(), Pulsar::InfoLabel::plot(), stats(), and stats().

◆ operator=()

const Pulsar::Profile & Pulsar::Profile::operator= ( const Profile & input)

assignment operator

Sets all attributes of this Profile equal to that of the input Profile, resizes and copies the amps array.

References copy(), and Profile().

◆ resize()

◆ snr()

float Pulsar::Profile::snr ( ) const

Returns the signal to noise ratio of the profile.

This method calls Profile::snr_strategy

References Pulsar::SNRatioEstimator::get_snr(), get_strategy(), Pulsar::Profile::Strategies::snratio(), and verbose.

Referenced by Pulsar::SNRWeight::get_weight().

◆ stats() [1/2]

void Pulsar::Profile::stats ( double * mean,
double * variance = 0,
double * varmean = 0,
int istart = 0,
int iend = 0 ) const

Calculates the mean, variance, and variance of the mean.

Returns the mean, variance, and variance of the mean over the specified interval.

Return values
meanthe mean of the interval
variancethe variance of the interval
varmeanthe variance of the mean of the interval
Parameters
istartthe first bin of the interval
iendone greater than the last bin of the interval

References Pulsar::ProfileAmps::get_amps(), Pulsar::ProfileAmps::get_nbin(), mean(), and verbose.

Referenced by correlate_normalized(), Pulsar::ProfilePlot::draw_transitions(), find_transitions(), Pulsar::NoiseStatistics::get_nfnr(), Pulsar::PhaseSNR::get_snr(), Pulsar::SquareWave::get_snr(), mean(), Pulsar::InfoLabel::plot(), Pulsar::Archive::rms_baseline(), and stats().

◆ stats() [2/2]

void Pulsar::Profile::stats ( float phase,
double * mean,
double * variance = 0,
double * varmean = 0,
float duty_cycle = default_duty_cycle ) const

Convenience interface to stats (start_bin, end_bin)

Parameters
phasecentre of region
Return values
meanthe mean of the interval
variancethe variance of the interval
varmeanthe variance of the mean of the interval
Parameters
phasecentre of region over which statistics will be calculated
duty_cyclewidth of region

References Pulsar::ProfileAmps::get_nbin(), mean(), Pulsar::phase(), stats(), and verbose.

Member Data Documentation

◆ default_duty_cycle

Pulsar::Option< float > Pulsar::Profile::default_duty_cycle
static

fractional phase window used in most functions

Default fractional pulse phase window used to calculate statistics related to the baseline.

Referenced by Pulsar::LawnMower::LawnMower(), Pulsar::NoiseStatistics::NoiseStatistics(), and Pulsar::Smooth::Smooth().

◆ peak_edges_strategy

Pulsar::Option< Pulsar::Profile::Edges > Pulsar::Profile::peak_edges_strategy
static

The default implementation of the edge detection algorithm.

The PeakEdgesInterpreter class sets the peak_edges_strategy attribute according to commands specified either in the configuration file or via the psrsh interpreter. It enables convenient experimentation with the peak edges estimation algorithm.

Referenced by find_peak_edges().

◆ rotate_phase_enabled

bool Pulsar::Profile::rotate_phase_enabled = true
static

Rotation of pulse phase is enabled by default.

Rotate the profile by the specified phase. The profile will be rotated such that the power at phase will be found at phase zero. ie.

$t^\prime=t+\phi P$

where $t^\prime$ is the new start time (rising edge of bin 0), $t$ is the original start time, $\phi$ is equal to phase, and $P$ is the period at the time of folding.

Referenced by rotate_phase().

◆ transition_duty_cycle

Pulsar::Option< float > Pulsar::Profile::transition_duty_cycle
static

fractional phase window used to find rise and fall of running mean

Fractional pulse phase window used to calculate the transitions in Pulsar::Profile::find_cal_transition

Referenced by find_transitions().

◆ verbose

bool Pulsar::Profile::verbose = false
static

flag controls the amount output to stderr by Profile methods

When true, Profile methods will output debugging information on cerr

Referenced by absolute(), add_extension(), baseline(), bscrunch(), Pulsar::PeakConsecutive::build(), Pulsar::PeakCumulative::build(), Pulsar::PhaseWeight::build(), Pulsar::ProfileStats::build(), Pulsar::Mower::build_mask(), Pulsar::IterativeBaseline::calculate(), Pulsar::OnPulseThreshold::calculate(), dedisperse(), derivative(), Pulsar::ProfileStats::deselect_onpulse(), find_max_bin(), find_max_phase(), find_min_bin(), find_min_phase(), find_transitions(), fold(), get(), get(), Pulsar::GaussianBaseline::get_bounds(), Pulsar::get_Integration(), Pulsar::PolnProfile::get_linear_variance(), Pulsar::NoiseStatistics::get_nfnr(), Pulsar::PhaseGradShift::get_shift(), Pulsar::AdaptiveSNR::get_snr(), Pulsar::FourierSNR::get_snr(), Pulsar::ModularSNR::get_snr(), Pulsar::PhaseSNR::get_snr(), Pulsar::get_Stokes(), Pulsar::get_Stokes(), Pulsar::ProfileStats::get_total(), logarithm(), max(), min(), Pulsar::Integration::new_PolnProfile(), Pulsar::Integration::new_PolnProfile(), Pulsar::RemoveBaseline::Total::operate(), Profile(), Profile(), Pulsar::ColdPlasma< Calculator, History >::range(), rotate_phase(), Pulsar::ProfileStats::select_profile(), Pulsar::ProfileStats::set_baseline_estimator(), Pulsar::ProfileStats::set_exclude_estimator(), Pulsar::ProfileStats::set_include_estimator(), Pulsar::ProfileStats::set_onpulse_estimator(), Pulsar::ProfileStats::set_profile(), Pulsar::ProfileStats::set_regions(), Pulsar::ProfileStats::set_snratio_estimator(), Pulsar::ExponentialBaseline::set_threshold(), Pulsar::GaussianBaseline::set_threshold(), Pulsar::Archive::set_verbosity(), Pulsar::ProfileStats::set_width_estimator(), snr(), square_root(), Pulsar::PhaseWeight::stats(), stats(), stats(), sum(), sumfabs(), sumsq(), Pulsar::TimerProfile_load(), Pulsar::TimerProfile_unload(), Pulsar::Correlate::transform(), Pulsar::ImageCorrection::transform(), Pulsar::Mower::transform(), Pulsar::PolnProfile::transform(), Pulsar::PolnProfile::transform(), Pulsar::ScatteredPowerCorrection::transform(), Pulsar::StokesCovariance::transform(), Pulsar::StokesCovariance::transform(), Pulsar::PolnProfile::~PolnProfile(), and Pulsar::StokesCovariance::~StokesCovariance().


The documentation for this class was generated from the following files:
  • Profile.h
  • Profile.C
  • Profile_average.C
  • Profile_derivative.C
  • Profile_rotate.C
  • ProfileExtension.h
  • Profile_baseline.C
  • Profile_convolve.C
  • Profile_dedisperse.C
  • Profile_find_minmax_phase.C
  • Profile_find_peak_edges.C
  • Profile_find_transitions.C
  • Profile_shift.C
  • Profile_snr.C
  • Profile_stats.C
  • StrategySet.C

Generated using doxygen 1.14.0