TimeFrequencyZap.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2018 by Paul Demorest
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __Pulsar_TimeFrequencyZap_h
10 #define __Pulsar_TimeFrequencyZap_h
11 
12 #include "Pulsar/Transformation.h"
13 #include "Pulsar/Archive.h"
14 #include "Pulsar/TimeFrequencySmooth.h"
15 #include "Pulsar/TimeFrequencyMask.h"
16 #include "Pulsar/ScrunchFactor.h"
17 
18 namespace Pulsar {
19 
20  class ArchiveStatistic;
21 
23 
27  class TimeFrequencyZap : public Transformation<Archive>
28  {
29 
30  public:
31 
33 
34  void transform (Archive*);
35 
38 
39  // Text interface to the TimeFrequencyZap class
40  class Interface : public TextInterface::To<TimeFrequencyZap> {
41  public:
42  Interface (TimeFrequencyZap* = 0);
43  };
44 
46  void set_expression (const std::string&);
47 
49  std::string get_expression () const { return expression; }
50 
52  void set_statistic (ArchiveStatistic*);
53 
55  ArchiveStatistic* get_statistic () const;
56 
58  void set_logarithmic (bool flag = true) { logarithmic = flag; }
59 
61  bool get_logarithmic () const { return logarithmic; }
62 
64  void set_smoother (TimeFrequencySmooth*);
65 
67  TimeFrequencySmooth* get_smoother () const;
68 
70  void set_masker (TimeFrequencyMask*);
71 
73  TimeFrequencyMask* get_masker () const;
74 
76  void set_cutoff_threshold (float t) { masker->set_threshold(t); }
77 
79  float get_cutoff_threshold () const { return masker->get_threshold(); }
80 
82  void set_fscrunch (const ScrunchFactor& f) { fscrunch_factor = f; }
83 
85  const ScrunchFactor get_fscrunch () const { return fscrunch_factor; }
86 
88  void set_bscrunch (const ScrunchFactor& f) { bscrunch_factor = f; }
89 
91  const ScrunchFactor get_bscrunch () const { return bscrunch_factor; }
92 
94  void set_max_iterations (unsigned n) { max_iterations = n; }
95 
97  unsigned get_max_iterations () const { return max_iterations; }
98 
100  void set_jobs (const std::string& p) { jobs = p; }
101 
103  std::string get_jobs () const { return jobs; }
104 
106  void set_polarizations (const std::string& p) { polns = p; }
107 
109  std::string get_polarizations () const { return polns; }
110 
112  void set_recompute (bool flag = true) { recompute = flag; }
113 
115  bool get_recompute () const { return recompute; }
116 
118  void set_report (bool flag = true) { report = flag; }
119 
121  bool get_report () const { return report; }
122 
124  void set_filename (const std::string& name) { filename = name; }
125 
127  const std::string& get_filename () const { return filename; }
128 
130  void set_aux_filename (const std::string& name) { aux_filename = name; }
131 
133  const std::string& get_aux_filename () const { return aux_filename; }
134 
135  protected:
136 
138  void compute_mask (Archive* data);
139 
141  virtual void compute_stat (Archive* data);
142 
144  virtual void update_mask();
145 
147  void apply_mask (Archive* archive,
149  unsigned chan_offset = 0);
150 
152  std::string expression;
153 
156 
158  bool logarithmic;
159 
161  bool regions_from_total;
162 
164  bool pscrunch;
165 
168 
171 
173  std::string jobs;
174 
176  std::string polns;
177 
180 
183 
185  unsigned nchan;
186 
188  unsigned nsubint;
189 
191  unsigned npol;
192 
194  std::vector<unsigned> pol_i;
195 
197  std::vector<float> freq;
198 
200  std::vector<float> time;
201 
203  std::vector<float> stat;
204 
206  std::vector<float> mask;
207 
209  unsigned idx(unsigned isubint, unsigned ichan) const {
210  return nchan*isubint + ichan;
211  }
212 
214  unsigned idx(unsigned isubint, unsigned ichan, unsigned ipol) const {
215  return nchan*npol*isubint + npol*ichan + ipol;
216  }
217 
219  void iteration (Archive* archive);
220 
222  unsigned max_iterations;
223 
225  bool recompute;
226 
228  bool recompute_original;
229 
231  bool report;
232 
234  std::string filename;
235 
237  std::string aux_filename;
238 
239  private:
240 
242  unsigned nmasked;
243 
245  unsigned nmasked_original;
246 
248  unsigned nmasked_during_iterations;
249 
251 
252  std::vector<bool> compute_subint;
253 
255 
256  std::vector<bool> compute_chan;
257 
259  Reference::To<Archive> last_dedispersed;
260 
262  Reference::To<Archive> dedispersed_clone;
263  };
264 
265 }
266 
267 #endif
TimeFrequencySmooth * get_smoother() const
Get the smoother.
Definition: TimeFrequencyZap.C:734
static const ScrunchFactor none
Useful for passing default = disabled.
Definition: ScrunchFactor.h:40
std::string jobs
Tasks performed on clone before computing statistic.
Definition: TimeFrequencyZap.h:178
void set_polarizations(const std::string &p)
Set the list of polns to look at.
Definition: TimeFrequencyZap.h:111
void set_jobs(const std::string &p)
Set tasks performed on clone before computing statistic.
Definition: TimeFrequencyZap.h:105
void set_nchan(unsigned numchan)
Set the number of frequency channels.
Definition: ArchiveExpert.h:52
bool recompute
Recompute the statistic on each iteration.
Definition: TimeFrequencyZap.h:230
Compute mask from statistic vs time/freq.
Definition: TimeFrequencyMask.h:27
float get_cutoff_threshold() const
Get the cut-off threshold.
Definition: TimeFrequencyZap.h:84
void apply_mask(Archive *archive, const ScrunchFactor &fscrunch=ScrunchFactor::none, unsigned chan_offset=0)
apply the current mask to the archive
Definition: TimeFrequencyZap.C:649
std::string filename
Name of file to which statistics are printed on first iteration.
Definition: TimeFrequencyZap.h:239
void set_expression(const std::string &)
Set the statistical expression.
Definition: TimeFrequencyZap.C:715
void set_max_iterations(unsigned n)
Set the maximum number of iterations.
Definition: TimeFrequencyZap.h:99
Archive * result()
Return the top of the interpreter stack.
Definition: StandardOptions.C:73
unsigned nsubint
num subints in the current archive
Definition: TimeFrequencyZap.h:193
virtual unsigned get_nsubint() const =0
Get the number of sub-integrations stored in the file.
Reference::To< ArchiveStatistic > statistic
The statistic to be derived from each profile.
Definition: TimeFrequencyZap.h:160
const ScrunchFactor get_fscrunch() const
Get the frequency scrunch factor.
Definition: TimeFrequencyZap.h:90
void set_masker(TimeFrequencyMask *)
Set the masker.
Definition: TimeFrequencyZap.C:740
The primary interface to pulsar observational data.
Definition: Archive.h:45
TextInterface::Parser * get_interface()
Get the text interface to the configuration attributes.
Definition: TimeFrequencyZap.C:34
bool get_logarithmic() const
Get flag to compute the logarithm of the statistic.
Definition: TimeFrequencyZap.h:66
Reference::To< TimeFrequencySmooth > smoother
Method to use for constructing the smoothed stat vs time/freq/pol.
Definition: TimeFrequencyZap.h:184
bool get_report() const
Get flag to print a one-line report.
Definition: TimeFrequencyZap.h:126
ScrunchFactor fscrunch_factor
Compute mask from fscrunched clone of data (twice)
Definition: TimeFrequencyZap.h:172
std::string get_jobs() const
Get tasks performed on clone before computing statistic.
Definition: TimeFrequencyZap.h:108
Type * get() const
Manages a combined scrunch factor or target dimension.
Definition: ScrunchFactor.h:25
Commmon statistics that can be derived from an Archive.
Definition: ArchiveStatistic.h:29
void fscrunch(Container *, const ScrunchFactor &)
Integrate frequency channels.
Definition: ScrunchFactor.h:102
void iteration(Archive *archive)
One iteration of the transformation.
Definition: TimeFrequencyZap.C:310
virtual void add_job(const std::string &job)
Add to the jobs.
Definition: StandardOptions.C:34
unsigned idx(unsigned isubint, unsigned ichan) const
Index into the freqs, mask arrays vs chan and subint.
Definition: TimeFrequencyZap.h:214
bool get_recompute() const
Get flag to recompute the statistic on each iteration.
Definition: TimeFrequencyZap.h:120
virtual unsigned get_nchan() const =0
Get the number of frequency channels used.
TimeFrequencyMask * get_masker() const
Get the masker.
Definition: TimeFrequencyZap.C:746
bool report
Print a report on stdout.
Definition: TimeFrequencyZap.h:236
Find bad data using a statistic vs time and frequency.
Definition: TimeFrequencyZap.h:32
float get_weight(unsigned ichan) const
Get the Profile weight attribute of the given channel.
Definition: Integration.C:388
void set_bscrunch(const ScrunchFactor &f)
Compute covariance matrix from bscrunched clone of data.
Definition: TimeFrequencyZap.h:93
void set_statistic(ArchiveStatistic *)
Set the statistic.
Definition: TimeFrequencyZap.C:708
Integration * get_Integration(unsigned subint)
Return pointer to the specified Integration.
Definition: IntegrationManager.C:41
void set_logarithmic(bool flag=true)
Set flag to compute the logarithm of the statistic.
Definition: TimeFrequencyZap.h:63
void set_fscrunch(const ScrunchFactor &f)
Set the frequency scrunch factor.
Definition: TimeFrequencyZap.h:87
std::string get_polarizations() const
Get the list of polns to look at.
Definition: TimeFrequencyZap.h:114
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
std::string get_expression() const
Get the statistical expression.
Definition: TimeFrequencyZap.h:54
Standard interpreter command line options.
Definition: StandardOptions.h:26
virtual void compute_stat(Archive *data)
compute the relevant statistic
Definition: TimeFrequencyZap.C:491
bool pscrunch
pscrunch first
Definition: TimeFrequencyZap.h:169
Expert * expert()
Provide access to the expert interface.
Definition: Archive.C:40
Implement the SumThreshold masking algorithm.
Definition: SumThreshold.h:27
void set_aux_filename(const std::string &name)
Set name of file to which auxiliary data are printed.
Definition: TimeFrequencyZap.h:135
void set_recompute(bool flag=true)
Set flag to recompute the statistic on each iteration.
Definition: TimeFrequencyZap.h:117
void set_weight(unsigned ichan, float weight)
Set the Profile weight attributes of the given channel.
Definition: Integration.C:401
Smooth a statistic vs time freq.
Definition: TimeFrequencySmooth.h:27
void set_report(bool flag=true)
Set flag to print a one-line report.
Definition: TimeFrequencyZap.h:123
void compute_mask(Archive *data)
computer the mask
Definition: TimeFrequencyZap.C:418
void set_cutoff_threshold(float t)
Set the cut-off threshold.
Definition: TimeFrequencyZap.h:81
unsigned npol
num poln in the current archive
Definition: TimeFrequencyZap.h:196
unsigned get_nscrunch() const
Get the number of elements to be integrated.
Definition: ScrunchFactor.h:51
ArchiveStatistic * get_statistic() const
Get the statistic.
Definition: TimeFrequencyZap.C:722
bool regions_from_total
Use the archive total profile to determine on/off pulse regions.
Definition: TimeFrequencyZap.h:166
void set_smoother(TimeFrequencySmooth *)
Set the smoother.
Definition: TimeFrequencyZap.C:728
Reference::To< TimeFrequencyMask > masker
Method to use for constructing the mask.
Definition: TimeFrequencyZap.h:187
std::vector< float > freq
Frequencies.
Definition: TimeFrequencyZap.h:202
std::string expression
The statistical expression.
Definition: TimeFrequencyZap.h:157
std::string aux_filename
Name of file to which auxiliary data is printed on first iteration.
Definition: TimeFrequencyZap.h:242
virtual void update_mask()
determine the time/freq mask
Definition: TimeFrequencyZap.C:624
bool logarithmic
Use the logarithm of the statistic.
Definition: TimeFrequencyZap.h:163
const std::string & get_filename() const
Get name of file to which data are printed.
Definition: TimeFrequencyZap.h:132
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void transform(Archive *)
Defined by derived classes.
Definition: TimeFrequencyZap.C:196
std::vector< float > time
Times.
Definition: TimeFrequencyZap.h:205
Computes pulse profile statistics.
Definition: ProfileStats.h:35
const ScrunchFactor get_bscrunch() const
Get the phase bin scrunch factor.
Definition: TimeFrequencyZap.h:96
unsigned max_iterations
Maximum number of times to loop.
Definition: TimeFrequencyZap.h:227
unsigned nchan
num channels in the current archive
Definition: TimeFrequencyZap.h:190
std::vector< float > mask
The current weights mask.
Definition: TimeFrequencyZap.h:211
void process(Archive *)
Preprocess the archive using the standard_shell interpreter.
Definition: StandardOptions.C:50
unsigned get_max_iterations() const
Get the maximum number of iterations.
Definition: TimeFrequencyZap.h:102
std::vector< float > stat
The current statistic values.
Definition: TimeFrequencyZap.h:208
bool recompute_original
Iterate and recompute after masking the original data.
Definition: TimeFrequencyZap.h:233
void set_filename(const std::string &name)
Set name of file to which data are printed.
Definition: TimeFrequencyZap.h:129
const std::string & get_aux_filename() const
Get name of file to which auxiliary data are printed.
Definition: TimeFrequencyZap.h:138
std::vector< unsigned > pol_i
List of polarizations to analyze.
Definition: TimeFrequencyZap.h:199
std::string polns
The list of polarizations to analyze.
Definition: TimeFrequencyZap.h:181
ScrunchFactor bscrunch_factor
Compute covariance matrix from bscrunched clone of data.
Definition: TimeFrequencyZap.h:175
Median smooth in time then frequency.
Definition: DoubleMedian.h:28

Generated using doxygen 1.8.17