ProfileStats.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2005 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/General/Pulsar/ProfileStats.h
10 
11 #ifndef __Pulsar_ProfileStats_h
12 #define __Pulsar_ProfileStats_h
13 
14 #include "Pulsar/PhaseWeight.h"
15 #include "Pulsar/Algorithm.h"
16 #include "Pulsar/HasBaselineEstimator.h"
17 
18 #include "PhaseRange.h"
19 #include "TextInterface.h"
20 #include "Estimate.h"
21 
22 namespace Pulsar
23 {
24  class Profile;
25  class ProfileWeightFunction;
26  class SNRatioEstimator;
27  class WidthEstimator;
28 
30  class ProfileStats : public Algorithm, public HasBaselineEstimator
31  {
32  public:
33 
35  static unsigned get_instance_count ();
36 
38  ProfileStats (const Profile* profile = 0);
39 
41  ProfileStats (const ProfileStats&);
42 
44  ~ProfileStats();
45 
47  ProfileStats* clone () const;
48 
51  ProfileWeightFunction* get_include_estimator () const;
52 
55  ProfileWeightFunction* get_exclude_estimator () const;
56 
58  void set_profile (const Profile*);
59  void set_Profile (const Profile* profile) { set_profile(profile); }
60 
62  void select_profile (const Profile*);
63 
65  void deselect_onpulse (const Profile* profile, float threshold);
66 
69  ProfileWeightFunction* get_onpulse_estimator () const;
70 
73 
75  void set_regions (const PhaseWeight& pulse, const PhaseWeight& baseline);
76 
78  void get_regions (PhaseWeight& pulse, PhaseWeight& base) const;
79 
81  unsigned get_onpulse_nbin () const;
82 
84  bool get_onpulse (unsigned ibin) const;
85 
87  void set_onpulse (unsigned ibin, bool);
88 
90  unsigned get_baseline_nbin () const;
91 
93  bool get_baseline (unsigned ibin) const;
94 
96  Estimate<double> get_total (bool subtract_baseline = true) const;
97 
100 
103 
106 
108  PhaseWeight* get_all ();
109 
112  SNRatioEstimator* get_snratio_estimator () const;
113 
115  void set_snr_estimator (const std::string& name);
116 
118  double get_snr () const;
119 
122 
125  WidthEstimator* get_width_estimator () const;
126 
128  void set_pulse_width_estimator (const std::string& name);
129 
132 
135 
138 
140  class Interface;
141 
142  protected:
143 
146 
149 
152 
155 
157  bool regions_set;
158 
160  mutable PhaseWeight onpulse;
161 
163  mutable PhaseWeight baseline;
164 
166  mutable PhaseWeight all;
167 
170 
173 
175  mutable PhaseWeight include;
176 
179 
181  mutable PhaseWeight exclude;
182 
184  void build () const;
185 
186  private:
187 
189  mutable bool built;
190  };
191 
192 }
193 
194 
195 #endif
196 
197 
198 
void set_baseline_estimator(BaselineEstimator *)
Set the BaselineEstimator used to find the off-pulse phase bins.
Definition: PeakConsecutive.C:78
static WidthEstimator * factory(const std::string &name_and_parse)
Construct a new WidthEstimator from a string.
Definition: WidthEstimator.C:26
PhaseWeight all
All phase bins (subject to include and exclude)
Definition: ProfileStats.h:171
void set_baseline_estimator(ProfileWeightFunction *)
The algorithm used to find the off-pulse phase bins.
Definition: ProfileStats.C:187
Reference::To< const Profile, false > profile
The Profile from which statistics will be derived.
Definition: ProfileStats.h:145
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition: ProfileAmps.C:141
ProfileStats(const Profile *profile=0)
Default constructor.
Definition: ProfileStats.C:27
unsigned get_baseline_nbin() const
Get the number of phase bins in the baseline window.
Definition: ProfileStats.C:296
static SNRatioEstimator * factory(const std::string &name_and_parse)
Construct a new SNRatioEstimator from a string.
Definition: SNRatioEstimator.C:22
bool regions_set
True when the onpulse and baseline regions have been set.
Definition: ProfileStats.h:162
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
std::string get_value(const std::string &name) const
PhaseWeight * get_baseline()
Return the off-pulse baseline mask.
Definition: ProfileStats.C:389
void set_regions(const PhaseWeight &pulse, const PhaseWeight &baseline)
Set the on-pulse and baseline regions.
Definition: ProfileStats.C:229
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
void set_onpulse_estimator(ProfileWeightFunction *)
The algorithm used to find the on-pulse phase bins.
Definition: ProfileStats.C:170
void set_width_estimator(WidthEstimator *)
The algorithm used to estimate the pulse width.
Definition: ProfileStats.C:197
TextInterface::Parser * get_interface()
Return a text interface that can be used to configure this instance.
Definition: ProfileStats.C:547
Calculates the pulse width in the phase domain.
Definition: PhaseWidth.h:27
unsigned get_nbin() const
Return the number of bins.
Definition: ProfileAmps.h:50
void get_regions(PhaseWeight &pulse, PhaseWeight &base) const
Set the on-pulse and baseline regions.
Definition: ProfileStats.C:242
static bool verbose
flag controls the amount output to stderr by Profile methods
Definition: Profile.h:53
void deselect_onpulse(const Profile *profile, float threshold)
Deselect onpulse phase bins in profile that fall below threshold.
Definition: ProfileStats.C:148
PhaseWeight baseline
The off-pulse baseline mask.
Definition: ProfileStats.h:168
~ProfileStats()
Destructor.
Definition: ProfileStats.C:69
unsigned get_onpulse_nbin() const
Get the number of phase bins in the on pulse window.
Definition: ProfileStats.C:289
Estimate< double > get_baseline_variance() const
Returns the variance of the baseline.
Definition: ProfileStats.C:339
TextInterface::Parser * get_pulse_width_interface()
Get the text interface of the pulse width estimator.
Definition: ProfileStats.C:539
void set_pulse_width_estimator(const std::string &name)
Set the pulse width estimator.
Definition: ProfileStats.C:527
Reference::To< ProfileWeightFunction > exclude_estimator
The algorithm used to find the excluded phase bins.
Definition: ProfileStats.h:183
Estimate< double > baseline_variance
The variance of the total intensity baseline.
Definition: ProfileStats.h:174
void build() const
Computes the phase bin masks.
Definition: ProfileStats.C:408
Adaptively computes the baseline, assuming normally distributed noise.
Definition: GaussianBaseline.h:70
Finds pulse defined by number of consecutive points above threshold.
Definition: PeakConsecutive.h:31
void select_profile(const Profile *)
Set the Profile that defines the baseline and on-pulse regions.
Definition: ProfileStats.C:128
void set_onpulse(unsigned ibin, bool)
Set if the specified phase bin is in the on pulse window.
Definition: ProfileStats.C:316
static unsigned get_instance_count()
Get the number of ProfileStats instances in existence.
Definition: ProfileStats.C:21
PhaseWeight onpulse
The on-pulse phase bin mask.
Definition: ProfileStats.h:165
void set_include_estimator(ProfileWeightFunction *)
The algorithm used to find the included phase bins.
Definition: ProfileStats.C:81
PhaseWeight algorithms that receive an input Profile.
Definition: ProfileWeightFunction.h:26
virtual void set_baseline_estimator(ProfileWeightFunction *)
Set the algorithm used to find the off-pulse phase bins.
Definition: HasBaselineEstimator.C:33
PhaseWeight * get_onpulse()
Return the on-pulse phase bin mask.
Definition: ProfileStats.C:376
ProfileStats * clone() const
Clone operator.
Definition: ProfileStats.C:74
Algorithms that estimate the signal-to-noise ratio of pulse profiles.
Definition: SNRatioEstimator.h:27
void set_snratio_estimator(SNRatioEstimator *)
The algorithm used to estimate the signal-to-noise ratio.
Definition: ProfileStats.C:212
TextInterface::Parser * get_snr_interface()
Get the text interface of the signal-to-noise ratio estimator.
Definition: ProfileStats.C:518
Reference::To< ProfileWeightFunction > include_estimator
The algorithm used to find the included phase bins.
Definition: ProfileStats.h:177
Profile statistics text interface.
Definition: ProfileStatsInterface.h:25
Defines the PSRCHIVE library.
Definition: CalSource.h:17
Reference::To< ProfileWeightFunction > onpulse_estimator
The algorithm used to find the on-pulse phase bins.
Definition: ProfileStats.h:153
Estimate< double > get_total(bool subtract_baseline=true) const
Returns the total flux of the on-pulse phase bins.
Definition: ProfileStats.C:251
Computes pulse profile statistics.
Definition: ProfileStats.h:35
double get_snr() const
Get the signal-to-noise ratio.
Definition: ProfileStats.C:506
void set_snr_estimator(const std::string &name)
Set the signal-to-noise ratio estimator.
Definition: ProfileStats.C:500
Manages a baseline estimator and its interface.
Definition: HasBaselineEstimator.h:27
PhaseWeight exclude
The excluded phase bin mask.
Definition: ProfileStats.h:186
void set_profile(const Profile *)
Set the Profile from which statistics will be derived.
Definition: ProfileStats.C:115
Reference::To< SNRatioEstimator > snratio_estimator
The algorithm used to compute the signal-to-noise ratio.
Definition: ProfileStats.h:156
void set_exclude_estimator(ProfileWeightFunction *)
The algorithm used to find the excluded phase bins.
Definition: ProfileStats.C:98
PhaseWeight * get_all()
Return the all pulse phase bin mask.
Definition: ProfileStats.C:401
Algorithms that estimate the width of the pulse profile.
Definition: WidthEstimator.h:31
::Phase::Value get_pulse_width() const
Get the pulse width.
Definition: ProfileStats.C:533
Reference::To< WidthEstimator > width_estimator
The algorithm used to estimate the pulse width.
Definition: ProfileStats.h:159
PhaseWeight include
The included phase bin mask.
Definition: ProfileStats.h:180

Generated using doxygen 1.8.17