Integration.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // /psrchive/Base/Classes/Pulsar/Integration.h
10 
11 #ifndef __Pulsar_Integration_h
12 #define __Pulsar_Integration_h
13 
14 #include "Pulsar/Pulsar.h"
15 #include "Pulsar/Container.h"
16 #include "Pulsar/Profile.h"
17 
18 #include "MJD.h"
19 #include "Types.h"
20 #include "Estimate.h"
21 #include "Jones.h"
22 #include "sky_coord.h"
23 
24 #include <vector>
25 
26 template<typename T> class Stokes;
27 
28 namespace Pulsar {
29 
30  class PolnProfile;
31  class PhaseWeight;
32  class Archive;
33 
35 
37  class Integration : public Container {
38 
39  public:
40 
42  static bool verbose;
43 
46 
48  Integration ();
49 
51  Integration (const Integration& subint);
52 
54  Integration& operator = (const Integration& subint);
55 
57  virtual ~Integration ();
58 
60  static unsigned get_instance_count ();
61 
63  class Interface;
64 
66  virtual Interface* get_interface ();
67 
69  void zero ();
70 
72  MJD get_start_time () const;
73 
75  MJD get_end_time () const;
76 
78  double get_centre_frequency (unsigned ichan) const;
80  void set_centre_frequency (unsigned ichan, double frequency);
81 
83  float get_weight (unsigned ichan) const;
85  void set_weight (unsigned ichan, float weight);
86 
88  void find_transitions (int& hi2lo, int& lo2hi, int& buffer) const;
89 
91  void find_peak_edges (int& rise, int& fall) const;
92 
94  float find_max_phase () const;
95 
97  float find_min_phase (float dc = 0.10) const;
98 
100  PhaseWeight* baseline () const;
101 
103  void baseline_stats (std::vector< std::vector< Estimate<double> > >* mean,
104  std::vector< std::vector<double> >* variance = 0,
105  const PhaseWeight* baseline = 0) const;
106 
108  void remove_baseline (const PhaseWeight* baseline = 0);
109 
111  void cal_levels (std::vector< std::vector< Estimate<double> > >& hi,
112  std::vector< std::vector< Estimate<double> > >& lo) const;
113 
115  double weighted_frequency (unsigned ch_start=0, unsigned ch_end=0) const;
116 
118  double effective_bandwidth (unsigned ch_start=0, unsigned ch_end=0) const;
119 
121  void uniform_weight (float new_weight = 1.0);
122 
124  void dedisperse ();
125 
127  void defaraday ();
128 
129  // //////////////////////////////////////////////////////////////////
130  //
131  // Copying and cloning
132  //
133  // //////////////////////////////////////////////////////////////////
134 
141 
143  virtual Integration* clone () const = 0;
144 
146  void orphan ();
147 
149  void adopt (const Archive*);
150 
152  Integration* total () const;
153 
155 
156 
157  // //////////////////////////////////////////////////////////////////
158  //
159  // Dimension Attributes
160  //
161  // //////////////////////////////////////////////////////////////////
162 
170 
172 
173  virtual unsigned get_nchan () const = 0;
174 
176 
177  virtual unsigned get_npol () const = 0;
178 
180 
181  virtual unsigned get_nbin () const = 0;
182 
184 
185 
186  // //////////////////////////////////////////////////////////////////
187  //
188  // Integration Unique Attributes
189  //
190  // //////////////////////////////////////////////////////////////////
191 
198 
200  virtual MJD get_epoch () const = 0;
202  /* When not dealing with single-pulse data, the epoch should
203  refer to that of the rising edge of phase bin zero near the
204  middle of the integration. */
205  virtual void set_epoch (const MJD& mjd) = 0;
206 
208  virtual double get_duration() const =0;
210  virtual void set_duration (double seconds) = 0;
211 
213  virtual double get_folding_period() const = 0;
215  /* The topocentric folding period of the pulsar should be equal
216  to that at the epoch defined by get_epoch. */
217  virtual void set_folding_period (double seconds) = 0;
218 
220  virtual double get_gate_duty_cycle() const { return 1.0; }
222  /* When gated data are recorded, this is the duty cycle of the
223  recording window */
224  virtual void set_gate_duty_cycle (double turns) { }
225 
227 
228 
229  // //////////////////////////////////////////////////////////////////
230  //
231  // Archive Shared Attributes
232  //
233  // //////////////////////////////////////////////////////////////////
234 
242 
244  std::string get_telescope() const;
245 
247  sky_coord get_coordinates() const;
248 
250  double get_centre_frequency() const;
251 
253  double get_bandwidth() const;
254 
256  double get_dispersion_measure () const;
257 
259  bool get_dedispersed () const;
260 
262  double get_rotation_measure () const;
263 
265  bool get_faraday_corrected () const;
266 
268  Signal::Basis get_basis () const;
269 
271  Signal::State get_state () const;
272 
275 
278 
280  double get_effective_dispersion_measure () const;
281 
283  double get_effective_rotation_measure () const;
284 
286 
287 
288  // //////////////////////////////////////////////////////////////////
289  //
290  // Access to data
291  //
292  // //////////////////////////////////////////////////////////////////
293 
299 
301  Profile* get_Profile (unsigned ipol, unsigned ichan);
302 
304  const Profile* get_Profile (unsigned ipol, unsigned ichan) const;
305 
307  PolnProfile* new_PolnProfile (unsigned ichan);
308 
310  const PolnProfile* new_PolnProfile (unsigned ichan) const;
311 
313  Stokes<float> get_Stokes (unsigned ichan, unsigned ibin) const;
314 
316  void get_Stokes (std::vector< Stokes<float> >& S, unsigned iother,
317  Signal::Dimension abscissa = Signal::Phase ) const;
318 
319  // //////////////////////////////////////////////////////////////////
320  //
321  // Extension access
322  //
323  // //////////////////////////////////////////////////////////////////
324 
331 
333  class Extension;
334 
336  virtual unsigned get_nextension () const;
337 
339  virtual const Extension* get_extension (unsigned iextension) const;
340 
342  virtual Extension* get_extension (unsigned iextension);
343 
345  template<class ExtensionType>
346  const ExtensionType* get () const;
347 
349  template<class ExtensionType>
350  ExtensionType* get ();
351 
353  template<class ExtensionType>
354  ExtensionType* getadd ();
355 
357 
364  virtual void add_extension (Extension* extension);
365 
367  virtual std::string list_extensions () const;
368 
370  virtual void edit_extensions (const std::string& name);
371 
373 
375  class Expert;
376 
378  Expert* expert ();
379  const Expert* expert () const;
380 
383 
384  protected:
385 
386  // //////////////////////////////////////////////////////////////////
387  //
388  // Dimension Attributes
389  //
390  // //////////////////////////////////////////////////////////////////
391 
400 
402  virtual void set_nbin (unsigned nbin) = 0;
403 
405  virtual void set_nchan (unsigned nchan) = 0;
406 
408  virtual void set_npol (unsigned npol) = 0;
409 
411  virtual void resize (unsigned npol=0, unsigned nchan=0, unsigned nbin=0);
412 
414  virtual void insert (Integration*);
415 
417  virtual void remove (unsigned ichan);
418 
420  virtual void remove (unsigned ichan_first, unsigned ichan_last);
421 
423  void reverse_chan ();
424 
426 
427  friend class Archive;
428  friend class Extension;
429  friend class Calibrator;
430  friend class Expert;
431 
433  void combine (const Integration* from);
434 
436  bool mixable (const Integration* integ, std::string& reason) const;
437 
439  virtual void copy (const Integration* subint, bool management = true);
440 
442  void swap_profiles (unsigned ipol, unsigned ichan,
443  unsigned jpol, unsigned jchan);
444 
446  void rotate (double time);
447 
449  void rotate_phase (double phase);
450 
452  void fold (unsigned nfold);
453 
455  void bscrunch (unsigned nscrunch);
456 
458  void bscrunch_to_nbin (unsigned nbin);
459 
461  void fscrunch (unsigned nscrunch = 0);
462 
464  void pscrunch ();
465 
467  void invint ();
468 
470  void transform (const Jones<float>& response);
471 
473  void transform (const std::vector< Jones<float> >& response);
474 
476  void convert_state (Signal::State state);
477 
479  virtual Profile* new_Profile ();
480 
482  mutable std::vector< Reference::To<Extension> > extension;
483 
485  std::vector< std::vector< Reference::To<Profile> > > profiles;
486 
489 
490  class Meta;
491 
494 
496  void range_check (unsigned ipol, unsigned ichan) const;
497 
500 
501  private:
502 
504  void dedisperse (unsigned ichan, unsigned kchan,
505  double reference_frequency);
506 
508  void defaraday (unsigned ichan, unsigned kchan,
509  double reference_frequency);
510 
512  void poln_convert (Signal::State out_state);
513 
515  bool zero_phase_aligned;
516 
518  void update_nbin ();
519  };
520 
521  template<typename UnaryProfileMethod, typename Argument>
522  void foreach (Integration* integration,
523  UnaryProfileMethod method, const Argument& arg)
524  {
525  const unsigned npol = integration->get_npol();
526  const unsigned nchan = integration->get_nchan();
527 
528  for (unsigned ipol=0; ipol<npol; ipol++)
529  for (unsigned ichan=0; ichan<nchan; ichan++)
530  (integration->get_Profile(ipol, ichan)->*(method)) (arg);
531  }
532 
533  template<typename BinaryProfileMethod>
534  void foreach (Integration* integration, const Integration* operand,
535  BinaryProfileMethod method)
536  {
537  const unsigned npol = integration->get_npol();
538  const unsigned nchan = integration->get_nchan();
539 
540  for (unsigned ipol=0; ipol<npol; ipol++)
541  for (unsigned ichan=0; ichan<nchan; ichan++)
542  {
543  Profile* into = integration->get_Profile(ipol, ichan);
544  const Profile* from = operand->get_Profile(ipol, ichan);
545  (into->*(method)) (from);
546  }
547  }
548 }
549 
550 #endif
Definition: IntegrationExtension.h:29
bool range_checking_enabled
Container classes should check array indeces at the cost of performance.
Definition: Pulsar.C:10
void baseline_stats(std::vector< std::vector< Estimate< double > > > *mean, std::vector< std::vector< double > > *variance=0, const PhaseWeight *baseline=0) const
Return the statistics of every profile baseline.
Definition: Integration_remove_baseline.C:54
void find_transitions(int &hi2lo, int &lo2hi, int &buffer) const
Find the transitions between high and low states in total intensity.
Definition: Integration_find.C:22
void phase(Profile *input)
Compute the phase of the input complex-valued Profile.
Definition: Fourier.C:135
void rotate_phase(double phase)
Rotate each profile by phase; does not update the epoch attribute.
Definition: Integration_rotate.C:28
void fscrunch(unsigned nscrunch=0)
Integrate profiles from neighbouring chans.
Definition: Integration_fscrunch.C:28
Signal::Basis get_basis() const
Get the feed configuration of the receiver.
Definition: Integration.C:588
void fold(unsigned nfold)
Call Profile::fold on every profile.
Definition: Integration.C:634
virtual double get_gate_duty_cycle() const
Get the fraction of the pulse period recorded (in turns)
Definition: Integration.h:220
Data storage implementations.
Definition: Container.h:24
virtual unsigned get_npol() const =0
Get the number of polarization measurements.
void zero()
Zero all the profiles, keeping all else the same.
Definition: Integration.C:185
Provides a text interface to get and set Integration attributes.
Definition: IntegrationTI.h:25
void invint()
Transform from Stokes (I,Q,U,V) to the polarimetric invariant interval.
Definition: Integration_invint.C:19
std::string get_telescope() const
Get the telescope name.
Definition: Integration.C:412
virtual unsigned get_nextension() const
Return the number of extensions available.
Definition: Integration.C:30
Expert * expert()
Provide access to the expert interface.
Definition: Integration.C:162
Polarization and flux calibrators.
Definition: Calibrator.h:34
void transform(const Jones< float > &response)
Perform the congruence transformation on each polarimetric profile.
Definition: Integration_transform.C:42
virtual MJD get_epoch() const =0
Get the epoch of the rising edge of bin zero.
virtual void resize(unsigned npol=0, unsigned nchan=0, unsigned nbin=0)
Set the dimensions of the data container.
Definition: Integration_resize.C:20
Manages the strategies that implement algorithms.
Definition: ProfileStrategies.h:26
static bool verbose
flag controls the amount output to stderr by Integration methods
Definition: Integration.h:42
virtual std::string list_extensions() const
Return a comma-separated list of the short names of all extensions.
Definition: Integration.C:107
virtual void copy(const Integration *subint, bool management=true)
Copy the profiles and attributes through set_ get_ methods.
Definition: Integration.C:222
std::string get_extension_name() const
Return the name of the Extension.
Definition: Integration.C:45
virtual Profile * new_Profile()
All new Profile instances are created through this method.
Definition: Integration.C:209
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
friend class Extension
The Extensions added to this Integration instance.
Definition: Integration.h:428
void set_centre_frequency(unsigned ichan, double frequency)
Set the Profile centre frequency attributes of the given channel.
Definition: Integration.C:372
std::vector< Reference::To< Extension > > extension
The Extensions added to this Integration instance.
Definition: Integration.h:482
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
virtual const Extension * get_extension(unsigned iextension) const
Return a pointer to the specified extension.
Definition: Integration.C:68
Stores otherwise shared attributes of orphaned Integrations.
Definition: IntegrationMeta.h:26
virtual void set_epoch(const MJD &mjd)=0
Set the epoch of the rising edge of bin zero.
The primary interface to pulsar observational data.
Definition: Archive.h:45
virtual void set_nbin(unsigned nbin)=0
Set the number of pulsar phase bins.
virtual unsigned get_nbin() const =0
Get the number of bins in each profile.
void bscrunch_to_nbin(unsigned nbin)
Call Profile::bsrunch_to_nbin on every profile.
Definition: Integration.C:654
Reference::To< Expert > expert_interface
Expert interface.
Definition: Integration.h:499
Extension(const char *name)
Construct with a name.
Definition: Integration.C:36
bool get_faraday_corrected() const
Data has been corrected for ISM faraday rotation.
Definition: Integration.C:489
Signal::State get_state() const
Get the polarimetric state of the profiles.
Definition: Integration.C:599
std::vector< std::vector< Reference::To< Profile > > > profiles
Data: npol by nchan profiles.
Definition: Integration.h:485
sky_coord get_coordinates() const
Get the source coordinates.
Definition: Integration.C:423
virtual void add_extension(Extension *extension)
Add an Extension to the Integration instance.
Definition: Integration.C:90
bool get_auxiliary_birefringence_corrected() const
Auxiliary inter-channel birefringence has been removed.
Definition: Integration.C:570
virtual Integration * clone() const =0
Return a new copy of self.
void cal_levels(std::vector< std::vector< Estimate< double > > > &hi, std::vector< std::vector< Estimate< double > > > &lo) const
Returns the mean hi/lo and variance of the mean hi/lo of every profile.
Definition: Integration_cal_levels.C:16
double get_rotation_measure() const
Get the auxiliary rotation measure.
Definition: AuxColdPlasmaMeasures.C:41
double effective_bandwidth(unsigned ch_start=0, unsigned ch_end=0) const
Computes the effective bandwidth of an interval of sub-channels.
Definition: Integration_weighted_frequency.C:27
float get_weight(unsigned ichan) const
Get the Profile weight attribute of the given channel.
Definition: Integration.C:388
virtual std::string get_short_name() const
Return an abbreviated name that can be typed relatively quickly.
Definition: Integration.C:50
MJD get_start_time() const
Get the MJD at the start of the integration (convenience interface)
Definition: Integration.C:696
virtual double get_duration() const =0
Get the total time integrated (in seconds)
virtual ~Extension()
Destructor.
Definition: Integration.C:41
double get_rotation_measure() const
Get the rotation measure (in )
Definition: Integration.C:478
void adopt(const Archive *)
Connect to a new parent archive (also useful after cloning)
Definition: Integration.C:277
Provides access to private and protected members of Integration.
Definition: IntegrationExpert.h:33
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
double get_dispersion_measure() const
Get the dispersion measure (in )
Definition: Integration.C:456
PhaseWeight * baseline() const
Return a new PhaseWeight instance with the baseline phase bins masked.
Definition: Integration_remove_baseline.C:20
virtual void set_nchan(unsigned nchan)=0
Set the number of frequency channels.
void range_check(unsigned ipol, unsigned ichan) const
Throw exception if ipol or ichan are out of range.
Definition: Integration.C:286
void reverse_chan()
Reverse the order of frequency channels.
Definition: Integration.C:619
ExtensionType * getadd()
Template method returns an Extension of the specified type.
void rotate(double time)
Rotate each profile by time (in seconds); updates the epoch attribute.
Definition: Integration_rotate.C:11
Polarimetric pulse profile transformations and derivations.
Definition: PolnProfile.h:34
double get_effective_rotation_measure() const
Get the effective rotation measure that remains to be corrected.
Definition: Integration.C:549
void find_peak_edges(int &rise, int &fall) const
Find the bins in which the total intensity exceeds a threshold.
Definition: Integration_find.C:51
virtual void set_duration(double seconds)=0
Set the total time integrated (in seconds)
float find_min_phase(float dc=0.10) const
Returns the centre phase of the region with minimum total intensity.
Definition: Integration_find.C:81
void set_weight(unsigned ichan, float weight)
Set the Profile weight attributes of the given channel.
Definition: Integration.C:401
Stokes< float > get_Stokes(unsigned ichan, unsigned ibin) const
Return the Stokes 4-vector for the frequency channel and phase bin.
Definition: Integration_get_Stokes.C:27
virtual ~Integration()
Destructor.
Definition: Integration.C:192
void combine(const Integration *from)
Combine from into this.
Definition: Integration_combine.C:28
void defaraday()
Remove Faraday rotation with respect to centre frequency.
Definition: Integration_defaraday.C:18
friend class Expert
The Extensions added to this Integration instance.
Definition: Integration.h:430
bool mixable(const Integration *integ, std::string &reason) const
Test if integration may be combined with this.
Definition: Integration_mixable.C:27
static unsigned get_instance_count()
returns the number of Integration instances
Definition: Integration.C:147
void remove_baseline(const PhaseWeight *baseline=0)
Remove the baseline from all profiles.
Definition: Integration_remove_baseline.C:35
double get_bandwidth() const
Get the bandwidth (in MHz)
Definition: Integration.C:445
void dedisperse()
Remove dispersion delays with respect to centre frequency.
Definition: Integration_dedisperse.C:16
virtual void set_npol(unsigned npol)=0
Set the number of polarization measurements.
Reference::To< const Archive, false > parent
The Archive that manages this integration.
Definition: Integration.h:488
Integration * total() const
Return an orphaned pscrunched dedispersed fscrunched clone of self.
Definition: Integration_total.C:22
double get_effective_dispersion_measure() const
Get the effective dispersion measure that remains to be corrected.
Definition: Integration.C:500
const Archive * get_parent(const Integration *subint) const
Provide Extension derived classes with access to parent Archive.
Definition: Integration.C:56
void zero()
set all amplitudes to zero
Definition: Profile.C:365
Profile::Strategies * get_strategy() const
Returns the strategy manager.
Definition: StrategySet.C:143
Integration()
Default constructor.
Definition: Integration.C:152
MJD get_end_time() const
Get the MJD at the end of the integration (convenience interface)
Definition: Integration.C:701
void convert_state(Signal::State state)
Convert polarimetric data to the specified state.
Definition: Integration_convert_state.C:22
Auxiliary cold plasma dispersion and birefringence corrections.
Definition: AuxColdPlasma.h:26
virtual unsigned get_nchan() const =0
Get the number of chans.
State pscrunch(State state)
double get_dispersion_measure() const
Get the auxiliary dispersion measure.
Definition: AuxColdPlasmaMeasures.C:29
bool get_dedispersed() const
Inter-channel dispersion delay has been removed.
Definition: Integration.C:467
bool get_auxiliary_dispersion_corrected() const
Auxiliary inter-channel dispersion delay has been removed.
Definition: Integration.C:530
Integration & operator=(const Integration &subint)
Assignment operator.
Definition: Integration.C:179
Reference::To< Meta > orphaned
The orphaned Integration's attributes.
Definition: Integration.h:490
float find_max_phase() const
Returns the centre phase of the region with maximum total intensity.
Definition: Integration_find.C:106
Defines the PSRCHIVE library.
Definition: CalSource.h:17
virtual void insert(Integration *)
Inserts Profiles from Integration into this.
Definition: Integration_insert.C:26
double get_centre_frequency() const
Get the centre frequency (in MHz)
Definition: Integration.C:434
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
Stores parameters used to correct auxiliary dispersion and birefringence.
Definition: AuxColdPlasmaMeasures.h:24
virtual void edit_extensions(const std::string &name)
Add or remove extensions with the specified short name.
Definition: Integration.C:124
virtual double get_folding_period() const =0
Get the folding or topocentric pulsar period (in seconds)
void pscrunch()
Integrate profiles from single polarizations into one total intensity.
Definition: Integration.C:668
void orphan()
Disconnect from parent archive (useful after cloning a working copy)
Definition: Integration_orphan.C:17
Profile * get_Profile(unsigned ipol, unsigned ichan)
Returns a pointer to the Profile given by the specified indeces.
Definition: Integration.C:306
void bscrunch(unsigned nscrunch)
Call Profile::bsrunch on every profile.
Definition: Integration.C:644
PolnProfile * new_PolnProfile(unsigned ichan)
Returns a pointer to a new PolnProfile instance.
Definition: Integration_new_PolnProfile.C:16
void uniform_weight(float new_weight=1.0)
Set the weight of each profile to the given number.
Definition: Integration.C:706
void swap_profiles(unsigned ipol, unsigned ichan, unsigned jpol, unsigned jchan)
Swap the two specified profiles.
Definition: Integration.C:610
static double match_max_frequency_difference
Maximum centre frequency difference in Integration::mixable.
Definition: Integration.h:45
virtual void remove(unsigned ichan)
Remove a channel from this Integration.
Definition: Integration_remove.C:14
const ExtensionType * get() const
Template method searches for an Extension of the specified type.
virtual void set_folding_period(double seconds)=0
Set the folding or topocentric pulsar period (in seconds)
virtual Interface * get_interface()
Return a text interface that can be used to access this instance.
Definition: Integration.C:200
double weighted_frequency(unsigned ch_start=0, unsigned ch_end=0) const
Computes the weighted centre frequency of an interval of sub-channels.
Definition: Integration_weighted_frequency.C:20
virtual void set_gate_duty_cycle(double turns)
Set the fraction of the pulse period recorded (in turns)
Definition: Integration.h:224

Generated using doxygen 1.8.17