SquareWave.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/SquareWave.h
10 
11 #ifndef __Pulsar_SquareWave_h
12 #define __Pulsar_SquareWave_h
13 
14 #include "Pulsar/Config.h"
15 #include "Pulsar/SNRatioEstimator.h"
16 #include "Estimate.h"
17 
18 namespace Pulsar {
19 
20  class Profile;
21  class Integration;
22  class PhaseWeight;
23 
25 
26  class SquareWave : public SNRatioEstimator {
27 
28  public:
29 
32 
34  SquareWave ();
35 
37  float get_snr (const Profile* profile);
38 
41 
43  class Interface;
44 
46  SquareWave* clone () const;
47 
49  void get_transitions (const Profile* profile,
50  std::vector<unsigned>& up,
51  std::vector<unsigned>& down);
52 
54  unsigned count_transitions (const Profile* profile);
55 
56  void levels (const Integration* subint,
57  std::vector<std::vector<Estimate<double> > >& high,
58  std::vector<std::vector<Estimate<double> > >& low);
59 
61  PhaseWeight* get_mask (const Profile*, bool on, int start, int low);
62 
64  void set_risetime (float turns) { risetime = turns; }
65 
67  float get_risetime () const { return risetime; }
68 
70  void set_threshold (float turns) { threshold = turns; }
71 
73  float get_threshold () const { return threshold; }
74 
76  void set_outlier_threshold (float f) { outlier_threshold = f; }
77 
79  float get_outlier_threshold () const { return outlier_threshold; }
80 
81  bool verbose;
82 
83  protected:
84 
85  float risetime;
86  float threshold;
87  unsigned use_nbin;
88  float outlier_threshold;
89  };
90 
91 }
92 
93 #endif
void set_include(PhaseWeight *include)
Include only the specified phase bins for consideration.
Definition: ProfileWeightFunction.C:43
SquareWave * clone() const
Return a copy constructed instance of self.
Definition: SquareWave.C:419
Smooth * get_smooth() const
Get the smoothing function.
Definition: BaselineWindow.C:77
float get_threshold() const
Get the threshold for square wave detection.
Definition: SquareWave.h:78
SquareWave()
Default constructor.
Definition: SquareWave.C:38
unsigned get_nbin() const
Get the number of weights in the array.
Definition: PhaseWeight.h:70
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition: ProfileAmps.C:141
PhaseWeight * get_mask(const Profile *, bool on, int start, int low)
Returns the phase bins that were not flagged as outliers.
Definition: SquareWave.C:212
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
The primary interface to pulsar observational data.
Definition: Archive.h:45
unsigned get_nbin() const
Return the number of bins.
Definition: ProfileAmps.h:50
Type * release()
const ExtensionType * get() const
Template method searches for an Extension of the specified type.
void set_threshold(float sigma)
Set the threshold below which samples are included in the baseline.
Definition: GaussianBaseline.C:39
virtual Profile * clone() const
returns a pointer to a new copy of self
Definition: Profile.C:124
float get_outlier_threshold() const
Get the threshold used to reject outliers when computing levels.
Definition: SquareWave.h:84
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
Adaptively computes the baseline, assuming normally distributed noise.
Definition: GaussianBaseline.h:70
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
void set_outlier_threshold(float f)
Set the threshold used to reject outliers when computing levels.
Definition: SquareWave.h:81
TextInterface::Parser * get_interface()
Return a text interface that can be used to configure this instance.
Definition: SquareWave.C:413
void set_turns(float)
Set the width of the smoothing window in turns.
Definition: Smooth.C:23
Finds the phase window in which the smoothed Profile is an extremum.
Definition: BaselineWindow.h:28
void set_find_maximum(bool f=true)
Set to find the maximum mean.
Definition: BaselineWindow.C:135
void set_initial_baseline(BaselineEstimator *)
Set the BaselineEstimator used to find the initial baseline.
Definition: IterativeBaseline.C:38
float find_phase(const std::vector< float > &amps)
Return the phase at which minimum or maximum mean is found.
Definition: BaselineWindow.C:187
void set_risetime(float turns)
Set the rise time of the square wave in turns of phase.
Definition: SquareWave.h:69
void set_find_mean(float mean)
Set to find the mean closest to the specified value.
Definition: BaselineWindow.C:145
static Option< float > transition_phase
If set, use the specified pulse phase for lo->hi transition.
Definition: SquareWave.h:36
float get_risetime() const
Get the rise time of the square wave in turns of phase.
Definition: SquareWave.h:72
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 set_threshold(float turns)
Set the threshold for square wave detection.
Definition: SquareWave.h:75
PhaseWeight * operate(const Profile *)
Convenience interface.
Definition: BaselineEstimator.C:43
Defines the PSRCHIVE library.
Definition: CalSource.h:17
unsigned count_transitions(const Profile *profile)
Count the level transitions.
Definition: SquareWave.C:174
float get_snr(const Profile *profile)
Return the signal to noise ratio.
Definition: SquareWave.C:48
void get_transitions(const Profile *profile, std::vector< unsigned > &up, std::vector< unsigned > &down)
Search for multiple level transitions.
Definition: SquareWave.C:127
Stores information about the reference source (ATNF)
Definition: CalInfoExtension.h:28
Calculates the signal-to-noise ratio using (on-off)/rms.
Definition: SquareWave.h:31
void set_all(float weight)
Set all weights to the specified value.
Definition: PhaseWeight.C:114

Generated using doxygen 1.8.17