PolnCalibrator.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2003 - 2022 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/Polarimetry/Pulsar/PolnCalibrator.h
10
11#ifndef __Pulsar_PolnCalibrator_H
12#define __Pulsar_PolnCalibrator_H
13
14#include "Pulsar/Calibrator.h"
15#include "Pulsar/Index.h"
16
17#include "MEAL/LeastSquares.h"
18#include "MEAL/Complex2.h"
19
20#include "ReferenceVector.h"
21#include "Jones.h"
22
23namespace Pulsar {
24
26 class FeedExtension;
27 class Receiver;
28 class Integration;
29
31
37 {
38
39 public:
40
42
45
47 PolnCalibrator (const Archive* archive = 0);
48
50 PolnCalibrator (const PolnCalibrator& calibrator);
51
53 virtual ~PolnCalibrator ();
54
56 void set_calibrator (const Archive* archive);
57
59 void set_subint (const Index& isub);
60
61 // ///////////////////////////////////////////////////////////////////
62 //
63 // useful for calibrating
64 //
65
67 virtual void set_response_nchan (unsigned nchan);
69 virtual unsigned get_response_nchan () const;
70
72 virtual Jones<float> get_response (unsigned ichan) const;
73
75 bool has_Receiver () const;
76
78 const Receiver* get_Receiver () const;
79
81 void set_Receiver (const Archive*);
82 std::string get_receiver_basis_filename () const;
83
84 // ///////////////////////////////////////////////////////////////////
85 //
86 // useful for unloading
87 //
88
89 void transformation_resize (unsigned nchan);
90
92 bool get_transformation_valid (unsigned ch) const;
93
95 void set_transformation_invalid (unsigned ch, const std::string& reason);
96
98 const std::string& get_transformation_invalid_reason (unsigned ichan) const;
99
101 const MEAL::Complex2* get_transformation (unsigned ichan) const;
102
104 MEAL::Complex2* get_transformation (unsigned ichan);
105
107 void set_transformation (unsigned ichan, MEAL::Complex2*);
108
110 bool has_covariance () const;
111
113 void get_covariance (unsigned ichan, std::vector<double>&) const;
114
116 virtual bool has_solver () const;
117
119 virtual const MEAL::LeastSquares* get_solver (unsigned ichan) const;
120 MEAL::LeastSquares* get_solver (unsigned ichan);
121
122 // ///////////////////////////////////////////////////////////////////
123 //
124 // Pulsar::Calibrator implementation
125 //
126 // ///////////////////////////////////////////////////////////////////
127
130
132 virtual void calibrate (Archive* archive);
133
135 virtual const Type* get_type () const;
136
138 virtual unsigned get_nchan () const;
139
141 unsigned get_nchan (bool build_if_needed) const;
142
145
147 Calibrator::Info* get_Info () const;
148
150 class Info;
151
153 void calibration_setup (const Archive* arch);
154
155 private:
156
159
161 std::vector< std::string> invalid_reason;
162
163 protected:
164
166 std::vector< std::vector<double> > covariance;
167
169 void setup_transformation () const;
170
172 std::vector< Jones<float> > response;
173
176
179
181 bool built;
182
185
188
190 virtual void calculate_transformation ();
191
193 virtual bool get_valid (unsigned ichan) const;
194
196 float get_weight (unsigned ichan) const;
197
199 virtual unsigned get_maximum_nchan () const;
200
203
204 private:
205
207 void build (unsigned nchan = 0);
208
210 mutable Reference::Vector<MEAL::LeastSquares> tmp_solver;
211
213 std::vector<bool> bad;
214 unsigned bad_count;
215
216 void build_response();
217 void patch_response();
218
221 std::string receiver_basis_filename;
222
224 void init ();
225
226 };
227
230
232 MEAL::Complex2* transformation_factory (const std::string& name);
233
235 MEAL::Complex2* load_transformation (const std::string& filename);
236
239
240}
241
242#endif
243
The primary interface to pulsar observational data.
Definition Archive.h:46
Stores Calibrator parameters in an Archive.
Definition CalibratorExtension.h:23
Definition Calibrator.h:151
Definition CalibratorType.h:26
Calibrator()
Default constructor.
Definition Calibrator.C:64
Stores a known feed transformation.
Definition FeedExtension.h:25
Combines an index value and integrate flag.
Definition Index.h:19
Array of Profiles integrated over the same time interval.
Definition Integration.h:37
Configuration option.
Definition Config.h:69
Stores PolnCalibrator parameters in an Archive instance.
Definition PolnCalibratorExtension.h:23
Calibrator::Info * get_Info() const
Return plotting information.
Definition PolnCalibratorInfo.C:143
bool has_Receiver() const
Return true if the Receiver is set.
Definition PolnCalibrator.C:196
void set_transformation_invalid(unsigned ch, const std::string &reason)
Set the transformation invalid flag for the specified channel.
Definition PolnCalibrator.C:277
void setup_transformation() const
Set up to call calculate_transformation.
Definition PolnCalibrator.C:420
const Receiver * get_Receiver() const
Return the Receiver.
Definition PolnCalibrator.C:202
bool built
Flag set when response has been built.
Definition PolnCalibrator.h:181
virtual void calculate_transformation()
Derived classes can create and fill the transformation array.
Definition PolnCalibrator.C:431
static Option< double > minimum_determinant
Minimum allowable determinant of Jones matrices.
Definition PolnCalibrator.h:44
virtual bool get_valid(unsigned ichan) const
Derived classes can add conditions for channel validity.
Definition PolnCalibrator.C:834
virtual Jones< float > get_response(unsigned ichan) const
Return the system response for the specified channel.
Definition PolnCalibrator.C:182
void set_transformation(unsigned ichan, MEAL::Complex2 *)
Set the transformation for the secified channel.
Definition PolnCalibrator.C:344
void set_Receiver(const Archive *)
Set the Receiver extension to that of the input Archive.
Definition PolnCalibrator.C:106
std::vector< Jones< float > > response
The array of Jones matrices derived from the transformation array.
Definition PolnCalibrator.h:172
std::vector< std::vector< double > > covariance
The array of covariance matrix vectors.
Definition PolnCalibrator.h:166
CalibratorExtension * new_Extension() const
Return a new PolnCalibratorExtension.
Definition PolnCalibrator.C:984
const MEAL::Complex2 * get_transformation(unsigned ichan) const
Return the transformation for the specified channel.
Definition PolnCalibrator.C:310
float get_weight(unsigned ichan) const
Return the weight (0 or 1) of the specified channel.
Definition PolnCalibrator.C:828
void calibration_setup(const Archive *arch)
Set up done before calibrating an archive.
Definition PolnCalibrator.C:843
unsigned observation_nchan
The number of frequency channels in the observation to be calibrated.
Definition PolnCalibrator.h:184
virtual void calibrate(Archive *archive)
Calibrate the polarization of the given archive.
Definition PolnCalibrator.C:871
virtual unsigned get_response_nchan() const
Get the number of frequency channels in the response array.
Definition PolnCalibrator.C:174
void set_calibrator(const Archive *archive)
Set the calibrator archive used to define basic attributes.
Definition PolnCalibrator.C:128
Index subint
The sub-integration from which to construct a solution.
Definition PolnCalibrator.h:202
bool do_backend_correction
Perform backend corrections before inverting.
Definition PolnCalibrator.h:187
virtual unsigned get_maximum_nchan() const
Derived classes may be able to shrink the transformation array.
Definition PolnCalibrator.C:231
const std::string & get_transformation_invalid_reason(unsigned ichan) const
Get the reason that the transformation in the specified channel is invalid.
Definition PolnCalibrator.C:298
Reference::To< const PolnCalibratorExtension > poln_extension
The PolnCalibratorExtension of the Archive passed during construction.
Definition PolnCalibrator.h:175
void set_subint(const Index &isub)
Set the sub-integration index.
Definition PolnCalibrator.C:147
virtual void set_response_nchan(unsigned nchan)
Set the number of frequency channels in the response array.
Definition PolnCalibrator.C:165
bool has_covariance() const
Return true if parameter covariances are stored.
Definition PolnCalibrator.C:355
bool get_transformation_valid(unsigned ch) const
Return true if the transformation for the specified channel is valid.
Definition PolnCalibrator.C:259
void set_backend_correction(bool f)
Perform backend corrections before inverting response.
Definition PolnCalibrator.h:129
virtual ~PolnCalibrator()
Destructor.
Definition PolnCalibrator.C:160
virtual bool has_solver() const
Return true if least squares minimization solvers are available.
Definition PolnCalibrator.C:376
PolnCalibrator(const Archive *archive=0)
Construct with optional processed calibrator Archive.
Definition PolnCalibrator.C:76
Reference::To< const FeedExtension > feed
The FeedExtension of the Archive passed during construction.
Definition PolnCalibrator.h:178
virtual const Type * get_type() const
Return the Calibrator::Type of derived class.
Definition PolnCalibrator.C:969
virtual const MEAL::LeastSquares * get_solver(unsigned ichan) const
Return the transformation for the specified channel.
Definition PolnCalibrator.C:393
void get_covariance(unsigned ichan, std::vector< double > &) const
Return the covariance matrix vector for the specified channel.
Definition PolnCalibrator.C:368
virtual unsigned get_nchan() const
Get the number of frequency channels in the calibrator.
Definition PolnCalibrator.C:238
Contains information about the receiver and receiver platform.
Definition Receiver.h:23
Defines the PSRCHIVE library.
Definition CalSource.h:17
MEAL::Complex2 * transformation_factory(const std::string &name)
Create a new transformation instance based on the Calibrator::Type name.
Definition CalibratorType_factory.C:89
Calibrator::Type * new_CalibratorType(const MEAL::Complex2 *xform)
Create a new Calibrator::Type instance according to the transformation.
Definition CalibratorType_factory.C:61
MEAL::Complex2 * load_transformation(const std::string &filename)
Load a new transformation instance from file.
Definition CalibratorType_factory.C:94
MEAL::Complex2 * new_transformation(const Calibrator::Type *type)
Create a new transformation instance described by the type.
Definition CalibratorType_factory.C:32

Generated using doxygen 1.14.0