Profile.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2002 - 2023 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Base/Classes/Pulsar/Profile.h
10
11#ifndef __Pulsar_Profile_h
12#define __Pulsar_Profile_h
13
14#include "Pulsar/ProfileAmps.h"
15#include "Pulsar/Config.h"
16
17#include "Types.h"
18#include "Functor.h"
19#include "Estimate.h"
20
21namespace Pulsar {
22
23 class PhaseWeight;
25 class SNRatioEstimator;
26
28
40 class Profile : public ProfileAmps {
41
42 public:
43
45 friend class Integration;
46
48 static bool verbose;
49
52
55
58
61
63 Profile (unsigned nbin = 0);
64
66 Profile (const Profile& profile);
67
69 Profile (const Profile* profile);
70
72 ~Profile ();
73
75 static unsigned get_instance_count ();
76
78 virtual Profile* clone () const;
79
81 virtual void resize (unsigned nbin);
82
84 const Profile& operator = (const Profile& profile);
85
87 void copy (const Profile*, bool clone_strategy = true);
88
90 void average (const Profile* that);
91
93 void sum (const Profile* profile);
94
96 void diff (const Profile* profile);
97
99 const Profile& operator += (float offset);
100
102 const Profile& operator -= (float offset);
103
105 const Profile& operator *= (float scale);
106
108 void scale (double scale);
109
111 void offset (double offset);
112
114 void rotate_phase (double phase);
115
117 void derivative ();
118
120 void zero ();
121
123 void square_root ();
124
126 void absolute ();
127
129 void logarithm (double base = 10.0, double threshold = 0.0);
130
132 float max (int bin_start=0, int bin_end=0) const;
134 float min (int bin_start=0, int bin_end=0) const;
135
137 double sum (int bin_start=0, int bin_end=0) const;
139 double sumsq (int bin_start=0, int bin_end=0) const;
141 double sumfabs (int bin_start=0, int bin_end=0) const;
142
144 void stats (double* mean, double* variance = 0, double* varmean = 0,
145 int bin_start=0, int bin_end=0) const;
146
148 void stats (float phase,
149 double* mean, double* variance = 0, double* varmean = 0,
150 float duty_cycle = default_duty_cycle) const;
151
153 double mean (float phase, float duty_cycle = default_duty_cycle) const;
154
156 float find_max_phase (float duty_cycle = default_duty_cycle) const;
158 float find_min_phase (float duty_cycle = default_duty_cycle) const;
159
161 void find_transitions (int& highlow, int& lowhigh, int& width) const;
162
164 int find_max_bin (int bin_start=0, int bin_end=0) const;
166 int find_min_bin (int bin_start=0, int bin_end=0) const;
167
168 typedef Functor< std::pair<int,int> (const Profile*) > Edges;
171
173 void find_peak_edges (int& rise, int& fall) const;
174
175 class Strategies;
176
178 Strategies* get_strategy() const;
179
181 void set_strategy (Strategies*);
182
184 PhaseWeight* baseline () const;
185
187 float snr () const;
188
190 void dedisperse (double dm, double ref_freq, double pfold);
191
193 Estimate<double> shift (const Profile& std) const;
194
197 std::vector<float> get_weighted_amps () const;
198
200 double get_centre_frequency () const { return centrefreq; }
202 virtual void set_centre_frequency (double cfreq) { centrefreq = cfreq; }
203
205 float get_weight () const { return fabs(weight); }
207 virtual void set_weight (float);
208
210 void fft_convolve (const Profile* profile);
211
213 void convolve (const Profile* profile);
214
216 void correlate (const Profile* profile);
217
219 void correlate_normalized (const Profile* profile);
220
222 void pscrunch ();
223
225 void bscrunch (unsigned nscrunch);
226
228 void bscrunch_to_nbin (unsigned nbin);
229
231 void fold (unsigned nfold);
232
233 // //////////////////////////////////////////////////////////////////
234 //
235 // Extension access
236 //
237 // //////////////////////////////////////////////////////////////////
238
245
247 class Extension;
248
250 virtual unsigned get_nextension () const;
251
253 virtual const Extension* get_extension (unsigned iextension) const;
254
256 virtual Extension* get_extension (unsigned iextension);
257
259 template<class ExtensionType>
260 const ExtensionType* get () const;
261
263 template<class ExtensionType>
264 ExtensionType* get ();
265
267
269 virtual void add_extension (Extension* extension);
270
271 protected:
272
273 friend class PolnProfile;
274 friend class StandardSNR;
275
277 void convolve (const Profile* profile, int direction);
278
280 void init ();
281
284
286 float weight;
287
289 mutable std::vector< Reference::To<Extension> > extension;
290
293 };
294
295}
296
297
298
299
300#endif // !defined __Pulsar_Profile_h
Profile(unsigned nbin=0)
Default constructor.
Definition Profile.C:84
Configuration option.
Definition Config.h:69
Stores a weight for each Profile phase bin.
Definition PhaseWeight.h:24
ProfileAmps(unsigned nbin=0)
Constructor initializes the data array.
Definition ProfileAmps.C:56
PhaseWeight algorithms that receive an input Profile.
Definition ProfileWeightFunction.h:22
Definition ProfileExtension.h:24
Manages the strategies that implement algorithms.
Definition ProfileStrategies.h:22
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
void logarithm(double base=10.0, double threshold=0.0)
calculate the logarithm of each bin with value greater than threshold
Definition Profile.C:413
void sum(const Profile *profile)
add profile to this
Definition Profile.C:336
void bscrunch_to_nbin(unsigned nbin)
integrate neighbouring phase bins in profile
Definition Profile.C:549
virtual unsigned get_nextension() const
Return the number of extensions available.
Definition Profile.C:198
virtual void resize(unsigned nbin)
resize the data area
Definition Profile.C:134
double get_centre_frequency() const
get the centre frequency (in MHz)
Definition Profile.h:200
static Option< float > default_duty_cycle
fractional phase window used in most functions
Definition Profile.h:60
friend class StandardSNR
centre frequency of profile (in MHz)
Definition Profile.h:274
virtual void set_weight(float)
set the weight of the profile
Definition Profile.C:185
void convolve(const Profile *profile)
convolves this with the given profile in time domain
Definition Profile_convolve.C:16
void find_transitions(int &highlow, int &lowhigh, int &width) const
Find the bin numbers at which the mean power transits.
Definition Profile_find_transitions.C:45
static bool verbose
flag controls the amount output to stderr by Profile methods
Definition Profile.h:48
const Profile & operator+=(float offset)
adds offset to each bin of the profile
Definition Profile.C:275
void find_peak_edges(int &rise, int &fall) const
Find the bin numbers at which the cumulative power crosses thresholds.
Definition Profile_find_peak_edges.C:34
const Profile & operator*=(float scale)
multiplies each bin of the profile by scale
Definition Profile.C:295
void set_strategy(Strategies *)
Set the strategy manager.
Definition Profile.C:192
ExtensionType * get()
Template method searches for an Extension of the specified type.
double mean(float phase, float duty_cycle=default_duty_cycle) const
Convenience interface to stats, returns only the mean.
Definition Profile_stats.C:121
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.
Definition Profile_stats.C:27
void offset(double offset)
offsets each bin of the profile by offset
Definition Profile.C:301
Estimate< double > shift(const Profile &std) const
Returns the shift (in turns) between profile and standard.
Definition Profile_shift.C:20
static Option< bool > rotate_in_phase_domain
When true, Profile::rotate shifts bins in the phase domain.
Definition Profile.h:54
void absolute()
calculare the absolute value of each phase bin
Definition Profile.C:399
void rotate_phase(double phase)
rotates the profile by phase (in turns)
Definition Profile_rotate.C:38
PhaseWeight * baseline() const
Return a new PhaseWeight instance with the baseline phase bins masked.
Definition Profile_baseline.C:15
void diff(const Profile *profile)
subtract profile from this
Definition Profile.C:341
void zero()
set all amplitudes to zero
Definition Profile.C:365
static Option< float > transition_duty_cycle
fractional phase window used to find rise and fall of running mean
Definition Profile.h:57
double sumfabs(int bin_start=0, int bin_end=0) const
Returns the sum of the absolute value.
Definition Profile.C:701
void pscrunch()
some extensions may have to respond to pscrunch
Definition Profile.C:463
static Option< Edges > peak_edges_strategy
The default implementation of the edge detection algorithm.
Definition Profile.h:170
void init()
initializes all values to null
Definition Profile.C:73
void bscrunch(unsigned nscrunch)
integrate neighbouring phase bins in profile
Definition Profile.C:505
double sumsq(int bin_start=0, int bin_end=0) const
Returns the sum of all amplitudes squared.
Definition Profile.C:722
void copy(const Profile *, bool clone_strategy=true)
does the work for copy constructor and assignment operator
Definition Profile.C:154
void fold(unsigned nfold)
integrate neighbouring sections of the profile
Definition Profile.C:472
virtual Profile * clone() const
returns a pointer to a new copy of self
Definition Profile.C:124
const Profile & operator-=(float offset)
subtracts offset from each bin of the profile
Definition Profile.C:285
Reference::To< Strategies > strategy
The strategy manager.
Definition Profile.h:292
const Profile & operator=(const Profile &profile)
assignment operator
Definition Profile.C:148
void correlate(const Profile *profile)
cross-correlates this with the given profile in time domain
Definition Profile_convolve.C:21
virtual void set_centre_frequency(double cfreq)
set the centre frequency (in MHz)
Definition Profile.h:202
static bool rotate_phase_enabled
Rotation of pulse phase is enabled by default.
Definition Profile.h:51
float snr() const
Returns the signal to noise ratio of the profile.
Definition Profile_snr.C:15
void derivative()
compute the derivative of profile with respect to index
Definition Profile_derivative.C:20
float get_weight() const
get the weight of the profile
Definition Profile.h:205
static unsigned get_instance_count()
returns the number of Profile instances
Definition Profile.C:64
~Profile()
destructor
Definition Profile.C:113
void fft_convolve(const Profile *profile)
convolves this with the given profile (using fft method)
Definition Profile_convolve.C:69
float weight
weight of profile
Definition Profile.h:286
void correlate_normalized(const Profile *profile)
cross-correlates and normalizes this with the given profile in time domain
Definition Profile_convolve.C:26
std::vector< float > get_weighted_amps() const
Definition Profile.C:346
float find_max_phase(float duty_cycle=default_duty_cycle) const
Returns the phase of the centre of the region with maximum mean.
Definition Profile_find_minmax_phase.C:43
int find_min_bin(int bin_start=0, int bin_end=0) const
Returns the bin number with the minimum amplitude.
Definition Profile.C:636
friend class Integration
The Integration class may call protected methods.
Definition Profile.h:45
std::vector< Reference::To< Extension > > extension
The Extensions added to this Profile instance.
Definition Profile.h:289
double centrefreq
centre frequency of profile (in MHz)
Definition Profile.h:283
void dedisperse(double dm, double ref_freq, double pfold)
Rotates the profile to remove dispersion delay.
Definition Profile_dedisperse.C:24
void scale(double scale)
multiplies each bin of the profile by scale
Definition Profile.C:311
virtual void add_extension(Extension *extension)
Add an Extension to this instance.
Definition Profile.C:253
const ExtensionType * get() const
Template method searches for an Extension of the specified type.
friend class PolnProfile
centre frequency of profile (in MHz)
Definition Profile.h:273
int find_max_bin(int bin_start=0, int bin_end=0) const
Returns the bin number with the maximum amplitude.
Definition Profile.C:622
float min(int bin_start=0, int bin_end=0) const
Returns the minimum amplitude.
Definition Profile.C:665
Profile(unsigned nbin=0)
Default constructor.
Definition Profile.C:84
virtual const Extension * get_extension(unsigned iextension) const
Return a pointer to the specified extension.
Definition Profile.C:225
void square_root()
calculate the signed sqrt of the absolute value of each bin
Definition Profile.C:381
float max(int bin_start=0, int bin_end=0) const
Returns the maximum amplitude.
Definition Profile.C:651
float find_min_phase(float duty_cycle=default_duty_cycle) const
Returns the phase of the centre of the region with minimum mean.
Definition Profile_find_minmax_phase.C:21
Strategies * get_strategy() const
Returns the strategy manager.
Definition StrategySet.C:122
void average(const Profile *that)
set this to the weighted average of this and that
Definition Profile_average.C:52
Algorithms that estimate the signal-to-noise ratio of pulse profiles.
Definition SNRatioEstimator.h:23
Defines the PSRCHIVE library.
Definition CalSource.h:17
void phase(Profile *input)
Compute the phase of the input complex-valued Profile.
Definition Fourier.C:135
STL namespace.

Generated using doxygen 1.14.0