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
26template<typename T> class Stokes;
27
28namespace Pulsar {
29
30 class PolnProfile;
31 class PhaseWeight;
32 class Archive;
33
35
37 class Integration : public Container {
38
39 public:
40
42 static unsigned 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
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
281 double get_effective_dispersion_measure () const;
282
284
285 double get_effective_rotation_measure () const;
286
288 double get_relative_dispersion_measure () const;
289
291 double get_relative_rotation_measure () const;
292
294 double get_absolute_dispersion_measure () const;
295
297 double get_absolute_rotation_measure () const;
299
300
301 // //////////////////////////////////////////////////////////////////
302 //
303 // Access to data
304 //
305 // //////////////////////////////////////////////////////////////////
306
312
314 Profile* get_Profile (unsigned ipol, unsigned ichan);
315
317 const Profile* get_Profile (unsigned ipol, unsigned ichan) const;
318
320 PolnProfile* new_PolnProfile (unsigned ichan);
321
323 PolnProfile* new_PolnProfile (unsigned ichan) const;
324
326 Stokes<float> get_Stokes (unsigned ichan, unsigned ibin) const;
327
329 void get_Stokes (std::vector< Stokes<float> >& S, unsigned iother,
330 Signal::Dimension abscissa = Signal::Phase ) const;
331
332 // //////////////////////////////////////////////////////////////////
333 //
334 // Extension access
335 //
336 // //////////////////////////////////////////////////////////////////
337
344
346 class Extension;
347
349 virtual unsigned get_nextension () const;
350
352 virtual const Extension* get_extension (unsigned iextension) const;
353
355 virtual Extension* get_extension (unsigned iextension);
356
358 template<class ExtensionType>
359 const ExtensionType* get () const;
360
362 template<class ExtensionType>
363 ExtensionType* get ();
364
366 template<class ExtensionType>
367 ExtensionType* getadd ();
368
370
377 virtual void add_extension (Extension* extension);
378
380 virtual std::string list_extensions () const;
381
383 virtual void edit_extensions (const std::string& name);
384
386
388 class Expert;
389
391 Expert* expert ();
392 const Expert* expert () const;
393
396
397 protected:
398
399 // //////////////////////////////////////////////////////////////////
400 //
401 // Dimension Attributes
402 //
403 // //////////////////////////////////////////////////////////////////
404
413
415 virtual void set_nbin (unsigned nbin) = 0;
416
418 virtual void set_nchan (unsigned nchan) = 0;
419
421 virtual void set_npol (unsigned npol) = 0;
422
424 virtual void resize (unsigned npol=0, unsigned nchan=0, unsigned nbin=0);
425
427 virtual void insert (Integration*);
428
430 virtual void remove (unsigned ichan);
431
433 virtual void remove (unsigned ichan_first, unsigned ichan_last);
434
436 void reverse_chan ();
437
439
440 friend class Archive;
441 friend class Extension;
442 friend class Calibrator;
443 friend class Expert;
444
446 void combine (const Integration* from);
447
449 bool mixable (const Integration* integ, std::string& reason) const;
450
452 virtual void copy (const Integration* subint, bool management = true);
453
455 void swap_profiles (unsigned ipol, unsigned ichan, unsigned jpol, unsigned jchan);
456
458 void rotate (double time);
459
461 void rotate_phase (double phase);
462
464 void fold (unsigned nfold);
465
467 void bscrunch (unsigned nscrunch);
468
470 void bscrunch_to_nbin (unsigned nbin);
471
473 void fscrunch (unsigned nscrunch = 0);
474
476 void pscrunch ();
477
479 void invint ();
480
482 void transform (const Jones<float>& response);
483
485 void transform (const std::vector< Jones<float> >& response);
486
488 void convert_state (Signal::State state);
489
491 virtual Profile* new_Profile ();
492
494 mutable std::vector< Reference::To<Extension> > extension;
495
497 std::vector< std::vector< Reference::To<Profile> > > profiles;
498
501
502 class Meta;
503
506
508 void range_check (unsigned ipol, unsigned ichan) const;
509
512
513 private:
514
516 void dedisperse (unsigned ichan, unsigned kchan,
517 double reference_frequency);
518
520 void defaraday (unsigned ichan, unsigned kchan,
521 double reference_frequency);
522
524
525 void update_absolute_dispersion();
526
528
529 void update_absolute_rotation();
530
532 void poln_convert (Signal::State out_state);
533
535 bool zero_phase_aligned;
536
538 void update_nbin ();
539 };
540
541 template<typename UnaryProfileMethod, typename Argument>
542 void foreach (Integration* integration,
543 UnaryProfileMethod method, const Argument& arg)
544 {
545 const unsigned npol = integration->get_npol();
546 const unsigned nchan = integration->get_nchan();
547
548 for (unsigned ipol=0; ipol<npol; ipol++)
549 for (unsigned ichan=0; ichan<nchan; ichan++)
550 (integration->get_Profile(ipol, ichan)->*(method)) (arg);
551 }
552
553 template<typename BinaryProfileMethod>
554 void foreach (Integration* integration, const Integration* operand,
555 BinaryProfileMethod method)
556 {
557 const unsigned npol = integration->get_npol();
558 const unsigned nchan = integration->get_nchan();
559
560 for (unsigned ipol=0; ipol<npol; ipol++)
561 for (unsigned ichan=0; ichan<nchan; ichan++)
562 {
563 Profile* into = integration->get_Profile(ipol, ichan);
564 const Profile* from = operand->get_Profile(ipol, ichan);
565 (into->*(method)) (from);
566 }
567 }
568}
569
570#endif
Array of Profiles integrated over the same time interval.
Definition Integration.h:37
virtual unsigned get_nchan() const =0
Get the number of chans.
virtual unsigned get_npol() const =0
Get the number of polarization measurements.
Profile * get_Profile(unsigned ipol, unsigned ichan)
Returns a pointer to the Profile given by the specified indeces.
Definition Integration.C:312
Integration()
Default constructor.
Definition Integration.C:158
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
The primary interface to pulsar observational data.
Definition Archive.h:46
Provides access to private and protected members of Integration.
Definition IntegrationExpert.h:28
Definition IntegrationExtension.h:25
Provides a text interface to get and set Integration attributes.
Definition IntegrationInterface.h:21
Stores otherwise shared attributes of orphaned Integrations.
Definition IntegrationMeta.h:22
Array of Profiles integrated over the same time interval.
Definition Integration.h:37
virtual void copy(const Integration *subint, bool management=true)
Copy the profiles and attributes through set_ get_ methods.
Definition Integration.C:228
virtual void resize(unsigned npol=0, unsigned nchan=0, unsigned nbin=0)
Set the dimensions of the data container.
Definition Integration_resize.C:20
Integration * total() const
Return an orphaned pscrunched dedispersed fscrunched clone of self.
Definition Integration_total.C:22
MJD get_start_time() const
Get the MJD at the start of the integration (convenience interface)
Definition Integration.C:725
virtual Profile * new_Profile()
All new Profile instances are created through this method.
Definition Integration.C:215
float get_weight(unsigned ichan) const
Get the Profile weight attribute of the given channel.
Definition Integration.C:400
virtual unsigned get_nextension() const
Return the number of extensions available.
Definition Integration.C:30
virtual void set_duration(double seconds)=0
Set the total time integrated (in seconds)
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 unsigned get_nbin() const =0
Get the number of bins in each profile.
void bscrunch(unsigned nscrunch)
Call Profile::bsrunch on every profile.
Definition Integration.C:669
bool mixable(const Integration *integ, std::string &reason) const
Test if integration may be combined with this.
Definition Integration_mixable.C:27
void pscrunch()
Integrate profiles from single polarizations into one total intensity.
Definition Integration.C:693
double get_rotation_measure() const
Get the rotation measure (in )
Definition Integration.C:490
bool get_dedispersed() const
Inter-channel dispersion delay has been removed.
Definition Integration.C:479
void uniform_weight(float new_weight=1.0)
Set the weight of each profile to the given number.
Definition Integration.C:735
virtual MJD get_epoch() const =0
Get the epoch of the rising edge of bin zero.
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
virtual unsigned get_nchan() const =0
Get the number of chans.
void rotate(double time)
Rotate each profile by time (in seconds); updates the epoch attribute.
Definition Integration_rotate.C:11
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
static double match_max_frequency_difference
Maximum centre frequency difference in Integration::mixable.
Definition Integration.h:45
float find_max_phase() const
Returns the centre phase of the region with maximum total intensity.
Definition Integration_find.C:106
virtual double get_folding_period() const =0
Get the folding or topocentric pulsar period (in seconds)
void fold(unsigned nfold)
Call Profile::fold on every profile.
Definition Integration.C:659
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 bscrunch_to_nbin(unsigned nbin)
Call Profile::bsrunch_to_nbin on every profile.
Definition Integration.C:679
void rotate_phase(double phase)
Rotate each profile by phase; does not update the epoch attribute.
Definition Integration_rotate.C:28
Reference::To< Meta > orphaned
The orphaned Integration's attributes.
Definition Integration.h:505
std::vector< Reference::To< Extension > > extension
The Extensions added to this Integration instance.
Definition Integration.h:494
void reverse_chan()
Reverse the order of frequency channels.
Definition Integration.C:644
virtual void edit_extensions(const std::string &name)
Add or remove extensions with the specified short name.
Definition Integration.C:124
double get_bandwidth() const
Get the bandwidth (in MHz)
Definition Integration.C:457
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
void adopt(const Archive *)
Connect to a new parent archive (also useful after cloning)
Definition Integration.C:283
void set_weight(unsigned ichan, float weight)
Set the Profile weight attributes of the given channel.
Definition Integration.C:413
virtual void set_nbin(unsigned nbin)=0
Set the number of pulsar phase bins.
void dedisperse()
Remove dispersion delays with respect to centre frequency.
Definition Integration_dedisperse.C:16
bool get_absolute_birefringence_corrected() const
Absolute inter-channel birefringence has been removed.
Definition Integration.C:596
bool get_faraday_corrected() const
Data has been corrected for ISM faraday rotation.
Definition Integration.C:501
friend class Archive
The Extensions added to this Integration instance.
Definition Integration.h:440
void orphan()
Disconnect from parent archive (useful after cloning a working copy)
Definition Integration_orphan.C:17
bool get_absolute_dispersion_corrected() const
Absolute inter-channel dispersive delay has been removed.
Definition Integration.C:548
virtual void remove(unsigned ichan)
Remove a channel from this Integration.
Definition Integration_remove.C:14
std::vector< std::vector< Reference::To< Profile > > > profiles
Data: npol by nchan profiles.
Definition Integration.h:497
virtual double get_duration() const =0
Get the total time integrated (in seconds)
double get_centre_frequency() const
Get the centre frequency (in MHz)
Definition Integration.C:446
virtual void set_folding_period(double seconds)=0
Set the folding or topocentric pulsar period (in seconds)
double get_absolute_rotation_measure() const
Get the absolute rotation measure that remains to be corrected.
Definition Integration.C:576
virtual void set_npol(unsigned npol)=0
Set the number of polarization measurements.
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
PhaseWeight * baseline() const
Return a new PhaseWeight instance with the baseline phase bins masked.
Definition Integration_remove_baseline.C:20
virtual double get_gate_duty_cycle() const
Get the fraction of the pulse period recorded (in turns)
Definition Integration.h:220
std::string get_telescope() const
Get the telescope name.
Definition Integration.C:424
virtual void insert(Integration *)
Inserts Profiles from Integration into this.
Definition Integration_insert.C:26
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:292
virtual ~Integration()
Destructor.
Definition Integration.C:198
Signal::State get_state() const
Get the polarimetric state of the profiles.
Definition Integration.C:624
Profile * get_Profile(unsigned ipol, unsigned ichan)
Returns a pointer to the Profile given by the specified indeces.
Definition Integration.C:312
virtual unsigned get_npol() const =0
Get the number of polarization measurements.
double get_effective_rotation_measure() const
Get the effective rotation measure that remains to be corrected.
Definition Integration.C:564
void remove_baseline(const PhaseWeight *baseline=0)
Remove the baseline from all profiles.
Definition Integration_remove_baseline.C:35
virtual const Extension * get_extension(unsigned iextension) const
Return a pointer to the specified extension.
Definition Integration.C:68
sky_coord get_coordinates() const
Get the source coordinates.
Definition Integration.C:435
double get_absolute_dispersion_measure() const
Get the absolute dispersion measure that remains to be corrected.
Definition Integration.C:525
static unsigned get_instance_count()
returns the number of Integration instances
Definition Integration.C:153
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
double get_relative_dispersion_measure() const
Get the relative dispersion measure that remains to be corrected.
Definition Integration.C:517
double get_relative_rotation_measure() const
Get the relative rotation measure that remains to be corrected.
Definition Integration.C:569
virtual Integration * clone() const =0
Return a new copy of self.
ExtensionType * getadd()
Template method returns an Extension of the specified type.
virtual void add_extension(Extension *extension)
Add an Extension to the Integration instance.
Definition Integration.C:90
virtual void set_gate_duty_cycle(double turns)
Set the fraction of the pulse period recorded (in turns)
Definition Integration.h:224
Integration & operator=(const Integration &subint)
Assignment operator.
Definition Integration.C:185
void swap_profiles(unsigned ipol, unsigned ichan, unsigned jpol, unsigned jchan)
Swap the two specified profiles.
Definition Integration.C:635
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
void combine(const Integration *from)
Combine from into this.
Definition Integration_combine.C:28
Expert * expert()
Provide access to the expert interface.
Definition Integration.C:168
static unsigned verbose
flag controls the amount output to stderr by Integration methods
Definition Integration.h:42
Reference::To< const Archive, false > parent
The Archive that manages this integration.
Definition Integration.h:500
Reference::To< Expert > expert_interface
Expert interface.
Definition Integration.h:511
Integration()
Default constructor.
Definition Integration.C:158
void set_centre_frequency(unsigned ichan, double frequency)
Set the Profile centre frequency attributes of the given channel.
Definition Integration.C:384
virtual void set_epoch(const MJD &mjd)=0
Set the epoch of the rising edge of bin zero.
MJD get_end_time() const
Get the MJD at the end of the integration (convenience interface)
Definition Integration.C:730
friend class Calibrator
The Extensions added to this Integration instance.
Definition Integration.h:442
Profile::Strategies * get_strategy() const
Returns the strategy manager.
Definition StrategySet.C:153
const ExtensionType * get() const
Template method searches for an Extension of the specified type.
double get_dispersion_measure() const
Get the dispersion measure (in )
Definition Integration.C:468
void defaraday()
Remove Faraday rotation with respect to centre frequency.
Definition Integration_defaraday.C:18
void convert_state(Signal::State state)
Convert polarimetric data to the specified state.
Definition Integration_convert_state.C:22
virtual std::string list_extensions() const
Return a comma-separated list of the short names of all extensions.
Definition Integration.C:107
Signal::Basis get_basis() const
Get the feed configuration of the receiver.
Definition Integration.C:613
void zero()
Zero all the profiles, keeping all else the same.
Definition Integration.C:191
double get_effective_dispersion_measure() const
Get the effective dispersion measure that remains to be corrected.
Definition Integration.C:512
PolnProfile * new_PolnProfile(unsigned ichan)
Returns a pointer to a new PolnProfile containing references to Profiles.
Definition Integration_new_PolnProfile.C:16
void invint()
Transform from Stokes (I,Q,U,V) to the polarimetric invariant interval.
Definition Integration_invint.C:19
void transform(const Jones< float > &response)
Perform the congruence transformation on each polarimetric profile.
Definition Integration_transform.C:44
ExtensionType * get()
Template method searches for an Extension of the specified type.
void fscrunch(unsigned nscrunch=0)
Integrate profiles from neighbouring chans.
Definition Integration_fscrunch.C:28
virtual Interface * get_interface()
Return a text interface that can be used to access this instance.
Definition Integration.C:206
Stores a weight for each Profile phase bin.
Definition PhaseWeight.h:24
Polarimetric pulse profile transformations and derivations.
Definition PolnProfile.h:29
Manages the strategies that implement algorithms.
Definition ProfileStrategies.h:22
Any quantity recorded as a function of pulse phase.
Definition Profile.h:40
Defines the PSRCHIVE library.
Definition CalSource.h:17
void phase(Profile *input)
Compute the phase of the input complex-valued Profile.
Definition Fourier.C:135

Generated using doxygen 1.14.0