Statistics.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 - 2016 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/General/Pulsar/Statistics.h
10 
11 #ifndef __Pulsar_Statistics_h
12 #define __Pulsar_Statistics_h
13 
14 #include "Pulsar/HasArchive.h"
15 #include "TextInterface.h"
16 #include "PhaseRange.h"
17 
18 namespace Pulsar {
19 
20  class ProfileStats;
21  class PhaseWeight;
22  class StrategySet;
23 
25  class Statistics : public Reference::Able, public HasArchive
26  {
27 
28  public:
29 
31  static unsigned get_instance_count ();
32 
34  Statistics (const Archive* = 0);
35 
37  ~Statistics ();
38 
40  StrategySet* get_strategy () const;
41 
43  Phase::Value get_peak () const;
44 
46  double get_effective_duty_cycle () const;
47 
49  double get_nfnr () const;
50 
52  unsigned get_cal_ntrans () const;
53 
55  unsigned get_nzero () const;
56 
58  double get_design_effect () const;
59 
61  double get_2bit_dist () const;
62 
64  PhaseWeight* get_baseline ();
65 
67  PhaseWeight* get_onpulse ();
68 
70  PhaseWeight* get_all ();
71 
73  ProfileStats* get_stats ();
74 
76  double get_weighted_frequency () const;
77 
79  double get_bin_width () const;
80 
82  double get_dispersive_smearing () const;
83 
85  class Interface;
86 
89 
91  class Plugin;
92 
94  void add_plugin (Plugin*);
95 
96  protected:
97 
98  void setup_stats ();
99  mutable Reference::To<ProfileStats> stats;
100 
101  mutable std::vector< Reference::To<Plugin> > plugins;
102 
104  void set_period (Phase::HasUnit&) const;
105 
106  };
107 
108  class Statistics::Plugin : public Reference::Able
109  {
110  public:
111 
112  Plugin () { setup = false; }
113 
114  virtual TextInterface::Parser* get_interface () = 0;
115 
116  const Integration* get_Integration ()
117  { return parent->get_Integration(); }
118 
119  protected:
120  friend class Statistics;
122  virtual void set_setup (bool flag) { setup = flag; }
123  mutable bool setup;
124  };
125 
126 }
127 
128 // standard interface constructor defined in More/General/standard_interface.C
129 TextInterface::Parser* standard_interface (Pulsar::Archive*);
130 
131 // also defined in More/General/standard_interface.C
132 std::string process (TextInterface::Parser* interface, const std::string& txt);
133 
134 #endif
Archive statistics text interface.
Definition: StatisticsInterface.h:25
double get_weighted_frequency() const
Get the weighted frequency from the Pulsar::Archive.
Definition: Statistics.C:203
StrategySet * get_strategy() const
Get the strategy manager owned by the Archive.
Definition: Statistics.C:51
double get_dispersive_smearing() const
Get the dispersive smearing in the worst channel in seconds.
Definition: Statistics.C:215
const Integration * get_Integration(const Archive *data, Index subint)
Return the requested profile, cloning and integrating when needed.
Definition: Index.C:118
double get_2bit_dist() const
Get the predicted level of 2-bit distortion.
Definition: Statistics.C:148
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
The primary interface to pulsar observational data.
Definition: Archive.h:45
~Statistics()
Destructor.
Definition: Statistics.C:39
void add_plugin(Plugin *)
Add a plugin.
Definition: Statistics.C:267
double get_effective_duty_cycle() const
Get the effective duty cycle.
Definition: Statistics.C:82
Type * get() const
double get_distortion(unsigned idig) const
Get the difference between the measured and theoretical distributions.
Definition: TwoBitStats.C:129
ProfileStats * get_stats()
Get the Profile statistics interface.
Definition: Statistics.C:192
TextInterface::Parser * get_interface()
Get the text interface to this.
Definition: Statistics.C:46
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
void set_period(Phase::HasUnit &) const
Set the period attribute of the Phase::Value/Range/Ranges argument.
Definition: Statistics.C:67
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
unsigned get_ndig() const
Get the number of digitizers.
Definition: TwoBitStats.C:56
Phase::Value get_peak() const
Get the phase of the pulse peak.
Definition: Statistics.C:60
double get_design_effect() const
Get Kish's design effect.
Definition: Statistics.C:98
PhaseWeight * get_all()
Get all phase bins.
Definition: Statistics.C:182
void set_period(double P_ms)
PhaseWeight * get_baseline()
Get the off-pulse baseline.
Definition: Statistics.C:162
Statistics(const Archive *=0)
Default constructor.
Definition: Statistics.C:33
Calculates profile shifts by fitting to a template/standard.
Definition: ProfileShiftFit.h:48
Computes the noise to Fourier noise ratio.
Definition: NoiseStatistics.h:50
double get_nfnr() const
Get the Fourier-noise-to-noise ratio.
Definition: Statistics.C:74
Stores histograms of two-bit low-voltage states.
Definition: TwoBitStats.h:30
double get_bin_width() const
Get the width of a phase bin in seconds.
Definition: Statistics.C:209
Defines the PSRCHIVE library.
Definition: CalSource.h:17
const Integration * get_Integration() const
Get the sub-integration defined by the current indeces.
Definition: HasArchive.C:47
const Profile * get_Profile(const Archive *data, Index subint, Index pol, Index chan)
Return the requested profile, cloning and integrating when needed.
Definition: Index.C:24
void set_baseline_time(float width)
Set the fractional number of phase bins used to calculate noise.
Definition: NoiseStatistics.C:38
unsigned count_transitions(const Profile *profile)
Count the level transitions.
Definition: SquareWave.C:174
Computes pulse profile statistics.
Definition: ProfileStats.h:35
unsigned get_nzero() const
Get the number of profiles that have zero weight.
Definition: Statistics.C:126
static unsigned get_instance_count()
Get the number of Statistics objects in existence.
Definition: Statistics.C:27
Calculates the signal-to-noise ratio using (on-off)/rms.
Definition: SquareWave.h:31
PhaseWeight * get_onpulse()
Get the on-pulse phase bins.
Definition: Statistics.C:172
unsigned get_cal_ntrans() const
Get the number of cal transitions.
Definition: Statistics.C:91
float get_nfnr(const Profile *profile)
Return the noise to Fourier noise ratio.
Definition: NoiseStatistics.C:48

Generated using doxygen 1.8.17