SpectralKurtosis.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2011 by Andrew Jameson
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/Base/Extensions/Pulsar/SpectralKurtosis.h
10 
11 #ifndef __Pulsar_SpectralKurtosis_h
12 #define __Pulsar_SpectralKurtosis_h
13 
14 #include "Pulsar/IntegrationExtension.h"
15 #include "TextInterface.h"
16 
17 namespace Pulsar {
18 
20  class SpectralKurtosis : public Pulsar::Integration::Extension {
21 
22  public:
23 
26 
28  SpectralKurtosis (const SpectralKurtosis& extension);
29 
31  const SpectralKurtosis& operator= (const SpectralKurtosis& extension);
32 
35 
37  SpectralKurtosis* clone () const { return new SpectralKurtosis( *this ); }
38 
41 
42  // Text interface to a SpectralKurtosis instance
43  class Interface : public TextInterface::To<SpectralKurtosis>
44  {
45  public:
46  Interface( SpectralKurtosis *s_instance = NULL );
47  };
48 
49  // Abstract loader for SpectralKurtosis extension
50  class Loader : public Reference::Able
51  {
52  public:
53  virtual void load (SpectralKurtosis * s) = 0;
54  };
55 
57  std::string get_short_name () const { return "skz"; }
58 
60  const SpectralKurtosis& operator += (const SpectralKurtosis& extension);
61 
63  void set_loader (SpectralKurtosis::Loader *);
64 
66  void resize (unsigned npol, unsigned nchan);
67 
69  void integrate (const Integration* subint);
70 
72  void update (const Integration* subint);
73 
75  void set_npol (unsigned n) { npol = n; }
77  unsigned get_npol() const { get_data(); return npol; }
78 
80  void set_nchan (unsigned n) { nchan = n; }
82  unsigned get_nchan() const { get_data(); return nchan; }
83 
85  void set_M (unsigned _M);
87  unsigned get_M() const;
88 
90  void set_excision_threshold (unsigned nsigma);
92  unsigned get_excision_threshold () const;
93 
95  float get_filtered_sum (unsigned ichan, unsigned ipol) const;
97  void set_filtered_sum (unsigned ichan, unsigned ipol, float sum);
98 
100  uint64_t get_filtered_hits (unsigned ichan) const;
102  void set_filtered_hits (unsigned ichan, uint64_t hits);
103 
105  float get_unfiltered_sum (unsigned ichan, unsigned ipol) const;
107  void set_unfiltered_sum (unsigned ichan, unsigned ipol, float sum);
108 
109  // Get the unfiltered hits, common to all channels and polarizations
110  uint64_t get_unfiltered_hits () const;
111  // Set the unfiltered hits, common to all channels and polarizations
112  void set_unfiltered_hits (uint64_t hits);
113 
115  void set_ipol_mean (unsigned ipol) { ipol_mean = ipol; }
116  unsigned get_ipol_mean () const { return ipol_mean; }
117 
119  float get_unfiltered_mean (unsigned ichan) const;
120  float get_filtered_mean (unsigned ichan) const;
121 
122  protected:
123 
126 
128  unsigned npol = 0;
129 
131  unsigned nchan = 0;
132 
134  unsigned M = 0;
135 
137  unsigned nsigma = 0;
138 
140  std::vector<float> filtered_sum;
141 
143  std::vector<uint64_t> filtered_hits;
144 
146  std::vector<float> unfiltered_sum;
147 
149  uint64_t unfiltered_hits = 0;
150 
152  void get_data () const;
153  void load ();
154 
156  void range_check (unsigned ichan, unsigned ipol, const char* method) const;
157 
158  unsigned ipol_mean = 0;
159  };
160 
161 }
162 
163 #endif
164 
double evaluate(std::vector< double > *grad=0) const
Definition: IntegrationExtension.h:29
void fit(const Pulsar::Parameters *model, std::vector< toa > &data, Pulsar::Parameters *postfit=NULL, bool track=false, Tempo::toa::State min_state=Tempo::toa::Normal)
float get_filtered_sum(unsigned ichan, unsigned ipol) const
Get the filtered sum of the specified channel and polarization.
Definition: SpectralKurtosis.C:130
void resize(unsigned npol, unsigned nchan)
Resize the extension.
Definition: SpectralKurtosis.C:229
void set_filtered_hits(unsigned ichan, uint64_t hits)
Set the filtered hits of the specified channel and polarization.
Definition: SpectralKurtosis.C:160
void integrate(const Integration *subint)
Integrate information from another Integration.
Definition: SpectralKurtosis.C:239
unsigned get_nchan() const
Get the number of channels.
Definition: SpectralKurtosis.h:92
static bool verbose
flag controls the amount output to stderr by Integration methods
Definition: Integration.h:42
std::vector< float > unfiltered_sum
Average SK statistic for each channel formed from block length SK estimates.
Definition: SpectralKurtosis.h:156
const ScalarMath log(const ScalarMath &x)
uint64_t get_filtered_hits(unsigned ichan) const
Get the filtered hits of the specified channel and polarization.
Definition: SpectralKurtosis.C:149
SpectralKurtosis()
Default constructor.
Definition: SpectralKurtosis.C:16
SpectralKurtosis * clone() const
Clone method.
Definition: SpectralKurtosis.h:47
static Archive * load(const std::string &name)
Factory returns a new instance loaded from filename.
Definition: Archive_load.C:28
void set_centre(double centre)
static void set_verbosity(unsigned level)
Set the verbosity level (0 to 3)
Definition: Archive_verbose.C:19
Value get_Value(const Type &value)
unsigned M
Number of samples integrated into each atomic SK statistic.
Definition: SpectralKurtosis.h:144
std::string get_short_name() const
Short name.
Definition: SpectralKurtosis.h:67
const ScalarMath sqrt(const ScalarMath &x)
const SpectralKurtosis & operator+=(const SpectralKurtosis &extension)
Addition operator.
Definition: SpectralKurtosis.C:47
void range_check(unsigned ichan, unsigned ipol, const char *method) const
Ensure that ichan < nchan and ipol < npol.
Definition: SpectralKurtosis.C:214
unsigned npol
number of polarizations
Definition: SpectralKurtosis.h:138
unsigned get_M() const
Get the base integration factor used in the SK statistic.
Definition: SpectralKurtosis.C:105
std::vector< uint64_t > filtered_hits
Hits on filtered average for each channel.
Definition: SpectralKurtosis.h:153
void set_height(double height)
void set_excision_threshold(unsigned nsigma)
Set the excision threshold in terms of std deviations.
Definition: SpectralKurtosis.C:115
Spectral Kurtosis Staticstics calculated during observation.
Definition: SpectralKurtosis.h:25
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
void set_unfiltered_sum(unsigned ichan, unsigned ipol, float sum)
Set the unfiltered sum of the specified channel and polarization.
Definition: SpectralKurtosis.C:178
void set_filtered_sum(unsigned ichan, unsigned ipol, float sum)
Set the filtered sum of the specified channel and polarization.
Definition: SpectralKurtosis.C:141
unsigned get_npol() const
Get the number of polarizations.
Definition: SpectralKurtosis.h:87
void set_loader(SpectralKurtosis::Loader *)
Set the loader used for this integration.
Definition: SpectralKurtosis.C:223
Reference::To< SpectralKurtosis::Loader > loader
loads the SK data from file
Definition: SpectralKurtosis.h:135
bool verbose
Definition: timer++.C:25
void update(const Integration *subint)
Update information based on the provided Integration.
Definition: SpectralKurtosis.C:256
virtual void set_abscissa(double value)
void set_npol(unsigned n)
Set the number of polarizations.
Definition: SpectralKurtosis.h:85
const SpectralKurtosis & operator=(const SpectralKurtosis &extension)
Assignment operator.
Definition: SpectralKurtosis.C:29
unsigned get_excision_threshold() const
Get the excision threshold in terms of std deviations.
Definition: SpectralKurtosis.C:120
float get_unfiltered_mean(unsigned ichan) const
Get the unfiltered mean of the specified channel.
Definition: SpectralKurtosis.C:201
void get_data() const
Load the integration data from file.
Definition: SpectralKurtosis.C:276
void set_nchan(unsigned n)
Set the number of channels.
Definition: SpectralKurtosis.h:90
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void set_M(unsigned _M)
Set the base integration factor used to calculate the SK statistic.
Definition: SpectralKurtosis.C:100
TextInterface::Parser * get_interface()
Return a text interfaces that can be used to access this instance.
Definition: SpectralKurtosis.C:295
void set_ipol_mean(unsigned ipol)
Set the polarization for which means will be computed.
Definition: SpectralKurtosis.h:125
void set_argument(unsigned dimension, Argument *axis)
float get_unfiltered_sum(unsigned ichan, unsigned ipol) const
Get the unfiltered sum of the specified channel and polarization.
Definition: SpectralKurtosis.C:167
~SpectralKurtosis()
Destructor.
Definition: SpectralKurtosis.C:95
unsigned nchan
number of channels
Definition: SpectralKurtosis.h:141
uint64_t unfiltered_hits
Hits on unfiltered SK statistic, same for each channel/pol.
Definition: SpectralKurtosis.h:159
void set_width(double width)
std::vector< float > filtered_sum
Average SK statistic for each channel, post f/t scrunch zapping.
Definition: SpectralKurtosis.h:150
unsigned nsigma
Threshold used to excise RFI in SK Detection.
Definition: SpectralKurtosis.h:147

Generated using doxygen 1.8.17