PulsarCalibrator.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Polarimetry/Pulsar/PulsarCalibrator.h
10 
11 #ifndef __Pulsar_PulsarCalibrator_H
12 #define __Pulsar_PulsarCalibrator_H
13 
14 #include "Pulsar/SystemCalibrator.h"
15 #include "Pulsar/PhaseWeight.h"
16 
17 #include "MEAL/Mean.h"
18 
19 #include "toa.h"
20 
21 #include <stdio.h>
22 
23 namespace Pulsar {
24 
25  class Archive;
26  class Integration;
27  class PolnProfileFit;
28  class ReferenceCalibrator;
29 
31 
38  class PulsarCalibrator : public SystemCalibrator {
39 
40  public:
41 
44 
47 
49  bool calibrator_match (const Archive*, std::string& reason_for_not_matching);
50 
52  void set_fixed_phase (bool flag = true);
53 
55  void share_phase ();
56 
58  unsigned get_nchan () const;
59 
61  unsigned get_nstate_pulsar () const;
62 
64  void set_maximum_harmonic (unsigned max);
65 
67  void set_choose_maximum_harmonic (bool flag = true);
68 
70  unsigned get_nharmonic () const;
71 
73  void set_standard (const Archive* data);
74 
76  void set_solve_each (bool = true);
77 
79  void set_unload_each (Unloader*);
80 
82  void wait ();
83 
85  void update_solution ();
86 
89  unsigned isub, unsigned ichan);
90 
92  const PolnProfileFit* get_mtm (unsigned ichan) const;
93 
96 
97  protected:
98 
99  friend class MatrixTemplateMatching;
100 
103 
105  bool solve_each;
106 
108  typedef std::map< unsigned, Reference::Vector<MEAL::Complex2> > Storage;
109  Storage store_each;
110 
113 
115  MEAL::Complex2* new_transformation (unsigned ichan);
116 
119 
121  std::vector<float> reduced_chisq;
122 
124 
127 
129  bool fixed_phase;
130 
132  bool shared_phase;
133 
135  unsigned maximum_harmonic;
136 
139 
141  unsigned chosen_maximum_harmonic;
142 
145 
148 
150  void init_model (unsigned ichan);
151 
153  void solve1 (const Calibration::CoherencyMeasurementSet& measurements);
154 
156  void setup (const Integration* data, unsigned ichan);
157 
159  virtual void export_prepare () const;
160 
162  virtual void match (const Archive*);
163 
165  virtual void add_pulsar (const Archive* data, unsigned isub);
166 
169  const Integration*, unsigned ichan);
170 
172  virtual void add_calibrator (const ReferenceCalibrator*);
173 
174  private:
175 
176  // used to communicate between solve and add_observation
177  unsigned big_difference;
178 
180  void build (unsigned nchan);
181 
182  };
183 
184 }
185 
186 #endif
unsigned maximum_harmonic
The maximum number of harmonics to include in the fit.
Definition: PulsarCalibrator.h:140
Reference::To< Pulsar::Archive > standard
The template/standard.
Definition: PulsarCalibrator.h:107
bool monitor_gimbal_lock
Set true to detect gimbal lock when rotations are not quaternion.
Definition: PulsarCalibrator.h:100
MEAL::Rotation1 * get_rotation_transformation()
Get the rotation transformation.
Definition: SingleAxis.C:314
Warning warning
Warning messages filter.
Definition: Pulsar.C:12
PhaseWeight onpulse
The on-pulse region.
Definition: PulsarCalibrator.h:149
Phenomenological description of the instrument.
Definition: Instrument.h:31
void get_regions(PhaseWeight &on, PhaseWeight &off) const
Set the on-pulse and baseline regions.
Definition: FluctSpectStats.h:50
Estimates phase shift in Fourier domain using matrix template matching.
Definition: MatrixTemplateMatching.h:26
Reference::To< Unloader > unload_each
Unload the solution derived from each sub-integration.
Definition: PulsarCalibrator.h:117
void set_check_state(bool flag=true)
Set to check the state attribute.
Definition: ArchiveMatch.C:195
void set_check_standard(bool flag=true)
Set to check that a standard and observation may be compared.
Definition: ArchiveMatch.C:115
virtual Signal::Source get_type() const =0
Get the observation type (psr, cal)
bool required(const Archive *)
Return true if the archive needs to be corrected.
Definition: FrontendCorrection.C:18
void set_check_calibrator(bool flag=true)
Set to check that a calibrator may be applied to an observation.
Definition: ArchiveMatch.C:179
void resize(unsigned n)
bool shared_phase
Share a single phase estimate between multiple observations.
Definition: PulsarCalibrator.h:137
const PolnProfileFit * get_mtm(unsigned ichan) const
The matrix template matching engine used to fit the specified channel.
Definition: PulsarCalibrator.C:775
virtual bool match(const Archive *a, const Archive *b) const
Check that the selected attributes match.
Definition: ArchiveMatch.C:353
Unloads Pulsar::SystemCalibrator solution to file.
Definition: SystemCalibratorUnloader.h:24
Reference::Vector< PolnProfileFit > mtm
The calibration model as a function of frequency.
Definition: PulsarCalibrator.h:123
virtual void match(const Archive *)
Ensure that the pulsar observation can be added to the data set.
Definition: PulsarCalibrator.C:329
const SingleAxis * get_backend() const
Provide access to the SingleAxis model.
Definition: VariableBackend.C:127
virtual void export_prepare() const
Prepare to export the solution in current state; e.g. for plotting.
Definition: PulsarCalibrator.C:69
const Archive * get_Archive() const
Return a const reference to the calibrator archive.
Definition: Calibrator.C:125
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
std::map< unsigned, Reference::Vector< MEAL::Complex2 > > Storage
Store the solution derived from each sub-integration.
Definition: PulsarCalibrator.h:113
The primary interface to pulsar observational data.
Definition: Archive.h:45
virtual unsigned get_nbin() const =0
Get the number of bins in each profile.
const Feed * get_feed() const
Provide access to the Feed model.
Definition: Instrument.C:177
virtual void print(std::string &text) const
void set_fixed_phase(bool flag=true)
When set, pulse phase is removed from the model.
Definition: PulsarCalibrator.C:88
Models a set of transformations and source polarizations.
Definition: ReceptionModel.h:32
Phenomenological description of the receiver feed.
Definition: Feed.h:32
void select_profile(const ProfileType *)
Set the Profile that defines the last harmonic and baseline.
Definition: FluctSpectStats.h:128
void set_choose_maximum_harmonic(bool flag=true)
Allow software to choose the maximum harmonic.
Definition: PulsarCalibrator.C:83
~PulsarCalibrator()
Destructor.
Definition: PulsarCalibrator.C:65
void set_check_bandwidth_sign(bool flag=true)
Set to check the sign of the bandwidth attribute.
Definition: ArchiveMatch.C:326
virtual Integration * clone() const =0
Return a new copy of self.
virtual unsigned get_nchan() const =0
Get the number of frequency channels used.
virtual Signal::State get_state() const =0
Get the state of the profile data.
void integrate(const MEAL::Complex2 *model)
Add the Model parameters to the running mean.
Definition: MeanInstrument.C:23
bool solve_each
Solve the measurement equation for each sub-integration.
Definition: PulsarCalibrator.h:110
virtual void add_calibrator(const ReferenceCalibrator *)
Add the ReferenceCalibrator observation to the set of constraints.
Definition: PulsarCalibrator.C:482
void solve1(const Calibration::CoherencyMeasurementSet &measurements)
Solve the measurement equation for the given measurements.
Definition: PulsarCalibrator.C:602
float get_weight(unsigned ichan) const
Get the Profile weight attribute of the given channel.
Definition: Integration.C:388
virtual bool get_poln_calibrated() const =0
Data has been calibrated for polarimetric response of instrument.
unsigned size() const
void calibrate(Archive *archive)
Calibrate the Pulsar::Archive.
Definition: FrontendCorrection.C:72
void set_standard(const Archive *data)
Set the standard to which pulsar profiles will be fit.
Definition: PulsarCalibrator.C:98
Array of Profiles integrated over the same time interval.
Definition: Integration.h:37
Instrumental gain, differential gain, and differential phase.
Definition: SingleAxis.h:38
A CoherencyMeasurement set and their coordinates.
Definition: CoherencyMeasurementSet.h:26
MEAL::Complex2 * new_transformation(unsigned ichan)
Return a pointer to a newly constructed/initialized transformation.
Definition: PulsarCalibrator.C:532
void share_phase()
Share a single phase estimate between all observations.
Definition: PulsarCalibrator.C:93
bool choose_maximum_harmonic
When set, the software will choose the maximum harmonic.
Definition: PulsarCalibrator.h:143
void set_cyclic(bool flag=true)
Set cyclical limits on the model parameters.
Definition: Instrument.C:166
MEAL::Rotation1 * get_orientation_transformation(unsigned receptor)
Get the orientation tranformation for the specified receptor.
Definition: Feed.C:182
Policy used to determine if two archives match.
Definition: ArchiveMatch.h:25
Computes statistics of full-polarization fluctuation spectra.
Definition: PolnSpectrumStats.h:26
Corrects the recorded properties of the frontend.
Definition: FrontendCorrection.h:31
Calibrators derived from reference source observations.
Definition: ReferenceCalibrator.h:31
MEAL::Rotation1 * get_ellipticity_transformation(unsigned receptor)
Get the ellipticity tranformation for the specified receptor.
Definition: Feed.C:189
Implements Measurement Equation Template Matching (van Straten 2013)
Definition: PulsarCalibrator.h:43
unsigned get_nstate_pulsar() const
Get the number of pulsar harmonics (input polarization states)
Definition: PulsarCalibrator.C:174
PulsarCalibrator(Calibrator::Type *=0)
Constructor.
Definition: PulsarCalibrator.C:46
std::vector< float > reduced_chisq
The reduced chi-squared as a function of frequency.
Definition: PulsarCalibrator.h:126
std::string get_reason() const
Get the mismatch messages from the last call to the match method.
Definition: ArchiveMatch.h:48
Definition: CalibratorType.h:30
void wait()
Ensure that all queued jobs have finished.
Definition: PulsarCalibrator.C:442
void set_check_nbin(bool flag=true)
Set to check the nbin attribute.
Definition: ArchiveMatch.C:261
virtual double get_bandwidth() const =0
Get the overall bandwidth of the observation.
void setup(const Integration *data, unsigned ichan)
Set things up for the model in the given channel.
Definition: PulsarCalibrator.C:558
virtual void add_pulsar(const Archive *data, unsigned isub)
Add data from the specified sub-integration.
Definition: PulsarCalibrator.C:448
A weighted mean of Instrument parameter estimates.
Definition: MeanInstrument.h:28
MEAL::Complex2 * new_transformation(const PolnCalibratorExtension *, unsigned ichan)
Create a new transformation instance described by the extension.
Definition: PolnCalibratorExt.C:126
unsigned get_last_harmonic() const
Return the last harmonic chosen in the on-pulse signal.
Definition: FluctSpectStats.h:53
Reference::Vector< MeanXform > solution
The array of transformation Model instances.
Definition: PulsarCalibrator.h:131
bool calibrator_match(const Archive *, std::string &reason_for_not_matching)
Return true if this calibrator can be applied to the data.
Definition: PulsarCalibrator.C:296
bool fixed_phase
Flag set when phase should be held fixed.
Definition: PulsarCalibrator.h:134
std::string get_filename() const
Get the name of the file to which the archive will be unloaded.
Definition: Archive.h:108
const VariableBackend * get_backend() const
Provide access to the backend model.
Definition: BackendFeed.C:60
unsigned get_transformation_index() const
Get the transformation through which the measurements are made.
Definition: CoherencyMeasurementSet.C:30
virtual unsigned get_nchan() const =0
Get the number of chans.
virtual Archive * clone() const =0
Return a new copy constructed instance equal to this.
void set_check_bandwidth(bool flag=true)
Set to check the bandwidth attribute.
Definition: ArchiveMatch.C:316
const std::string get_message() const
void set_unload_each(Unloader *)
Unload the solution from each sub-integration.
Definition: PulsarCalibrator.C:789
void set_maximum_harmonic(unsigned max)
Set the maximum number of harmonics to include in fit.
Definition: PulsarCalibrator.C:78
void set_solve_each(bool=true)
Solve each sub-integration (instead of global fit)
Definition: PulsarCalibrator.C:784
unsigned chosen_maximum_harmonic
The maximum harmonic chosen.
Definition: PulsarCalibrator.h:146
Defines the PSRCHIVE library.
Definition: CalSource.h:17
MEAL::Complex2 * get_transformation(const Archive *data, unsigned isub, unsigned ichan)
Return the transformation to be used for precalibration.
Definition: PulsarCalibrator.C:502
unsigned get_ichan() const
Get the channel index.
Definition: CoherencyMeasurementSet.h:82
unsigned get_nharmonic() const
Get the number of harmonics in use.
Definition: PulsarCalibrator.C:163
unsigned get_nchan() const
Get the number of frequency channels.
Definition: PulsarCalibrator.C:260
static Reference::To< Agent > current
void set_check_centre_frequency(bool flag=true)
Set to check the centre_frequency attribute.
Definition: ArchiveMatch.C:305
Britton (2000; ApJ 532:1240), equation 19.
Definition: CalibratorTypes.h:130
The matrix template matching algorithm.
Definition: PolnProfileFit.h:50
PolnProfile * new_PolnProfile(unsigned ichan)
Returns a pointer to a new PolnProfile instance.
Definition: Integration_new_PolnProfile.C:16
void update_solution()
Set the solution to the mean.
Definition: PulsarCalibrator.C:757
void set_check_nchan(bool flag=true)
Set to check the nchan attribute.
Definition: ArchiveMatch.C:272
PhaseWeight baseline
The baseline region.
Definition: PulsarCalibrator.h:152
void init_model(unsigned ichan)
Initialize the SignalPath of the specified channel.
Definition: PulsarCalibrator.C:271

Generated using doxygen 1.8.17