Line data Source code
1 : /**
2 : Bojan Nikolic <b.nikolic@mrao.cam.ac.uk>, <bojan@bnikolic.co.uk>
3 : Initial version January 2010.
4 : Maintained by ESO since 2013.
5 :
6 : This file is part of LibAIR and is licensed under GNU Public
7 : License Version 2
8 :
9 : \file dtdlcoeffs.hpp
10 : Renamed dtdlcoeffs.h 2023
11 :
12 : Class hirerachy defining computed dT/dL coefficients for an ALMA
13 : observation
14 : */
15 : #ifndef _LIBAIR_DTDLCOEFFS_HPP__
16 : #define _LIBAIR_DTDLCOEFFS_HPP__
17 :
18 : #include <vector>
19 : #include <set>
20 : #include <iosfwd>
21 : #include <array>
22 :
23 : #include <casacore/casa/Arrays/Cube.h>
24 :
25 : namespace LibAIR2 {
26 :
27 : // Forward declarations
28 : struct ALMAResBase;
29 :
30 : /** \brief Base class representing dTdL coefficients that can be
31 : applied to observed interferometer data to correct the phase
32 : */
33 : class dTdLCoeffsBase
34 : {
35 :
36 : public:
37 :
38 : // ---------------------- Public data -------------------------
39 :
40 : /// Allows masking or scaling of channels
41 : std::array<double, 4> chmask;
42 :
43 : // ----------------------- Construction/Destruction -------------
44 :
45 : dTdLCoeffsBase();
46 :
47 : /** Virtual destructor requried in this calls
48 : */
49 : virtual ~dTdLCoeffsBase();
50 :
51 : // ----------------------- Public Interface ---------------------
52 :
53 :
54 : /** Get the coefficients
55 :
56 : \param i WVR or antenna number
57 : \param time Time
58 : \param el elevation
59 :
60 : \param res Vector to store the result in
61 :
62 : \param c2 Vector to stre the second order differentials (store
63 : zeros here if these have not been estimated)
64 : */
65 : virtual void get(size_t i,
66 : double time,
67 : double el,
68 : std::vector<double> &res,
69 : std::vector<double> &c2) const =0;
70 :
71 : //virtual void print(std::ostream &os)
72 : //{
73 : //};
74 :
75 : /** \brief Return a representative set of coefficients
76 :
77 : These can be used for error estimates, printing to the user,
78 : etc.
79 : */
80 : virtual void repr(std::vector<double> &res,
81 : std::vector<double> &err) const =0;
82 :
83 : /** \brief Are all coefficients in this object finite?
84 : Useful to check for errors
85 : */
86 : virtual bool isnan(void) const =0;
87 :
88 : };
89 :
90 : /** \brief The trivial implementation in which alsways a single set
91 : of coefficients is returned
92 : */
93 : class dTdLCoeffsSingle:
94 : public dTdLCoeffsBase
95 : {
96 :
97 : std::vector<double> c, c2, e;
98 :
99 : public:
100 :
101 : // ----------------------- Construction/Destruction -------------
102 :
103 : /**
104 : \param c The phase correction coefficients
105 :
106 : \param e The errors on the coefficients
107 : */
108 : dTdLCoeffsSingle(const std::vector<double> &c,
109 : const std::vector<double> &e);
110 :
111 : /// Construct from a single retrieval, assuming that the values
112 : /// are valid for all WVRs
113 : dTdLCoeffsSingle(const ALMAResBase &r);
114 :
115 : // ----------------------- Public Interface ---------------------
116 :
117 : // ----------------------- Inherited from dTdLCoeffsBase --------
118 : virtual void get(size_t i,
119 : double time,
120 : double el,
121 : std::vector<double> &res,
122 : std::vector<double> &res2) const;
123 :
124 : virtual void print(std::ostream &os);
125 :
126 : virtual void repr(std::vector<double> &res,
127 : std::vector<double> &err) const;
128 :
129 : virtual bool isnan(void) const;
130 :
131 : };
132 :
133 :
134 : /** \brief Separate coefficents for each WVR
135 : */
136 : class dTdLCoeffsIndiv:
137 : public dTdLCoeffsBase
138 : {
139 : public:
140 :
141 : /// First dimension is channel number, second is antenna number, third
142 : /// is (coefficent, error, second order coefficient)
143 : typedef casacore::Cube<double> coeff_t;
144 :
145 : private:
146 :
147 : coeff_t coeff;
148 :
149 : public:
150 :
151 : // ----------------------- Construction/Destruction -------------
152 :
153 : /**
154 : \param c The phase correction coefficients
155 :
156 : \param e The errors on the coefficients
157 : */
158 : dTdLCoeffsIndiv(const coeff_t &c);
159 :
160 : dTdLCoeffsIndiv(size_t nAnts);
161 :
162 : // ----------------------- Public Interface ---------------------
163 :
164 : /// Set the coefficients for antenna i
165 : void set(size_t i,
166 : const std::vector<double> &c,
167 : const std::vector<double> &e);
168 :
169 : // ----------------------- Inherited from dTdLCoeffsBase --------
170 : virtual void get(size_t i,
171 : double time,
172 : double el,
173 : std::vector<double> &res,
174 : std::vector<double> &c2) const;
175 :
176 : virtual void print(std::ostream &os);
177 :
178 : virtual void repr(std::vector<double> &res,
179 : std::vector<double> &err) const;
180 :
181 : virtual bool isnan(void) const;
182 :
183 : };
184 :
185 : /** \brief Implementation in which the coefficients are interpolated
186 : in time
187 :
188 : */
189 : class dTdLCoeffsSingleInterpolated:
190 : public dTdLCoeffsBase
191 : {
192 :
193 : struct ret_t {
194 :
195 : /// The time to which the retrieval applies
196 : double time;
197 :
198 : /// The coefficients
199 : std::array<double, 4> coeffs;
200 :
201 : /// Second order coefficients
202 : std::array<double, 4> c2;
203 :
204 : std::array<double, 4> err;
205 :
206 : /// Defines the ordering of retrievals so that they can be
207 : /// sorted in a set
208 0 : bool operator<(const ret_t &other) const{
209 0 : return time<other.time;
210 : }
211 :
212 : };
213 :
214 : std::set<ret_t> retrievals;
215 :
216 : public:
217 :
218 : // ----------------------- Construction/Destruction -------------
219 :
220 : dTdLCoeffsSingleInterpolated();
221 :
222 : // ----------------------- Public Interface ---------------------
223 :
224 : /** Add a new solution to the sequence
225 : */
226 : void insert(double time,
227 : const std::array<double, 4> &coeffs,
228 : const std::array<double, 4> &err);
229 :
230 :
231 : // ----------------------- Inherited from dTdLCoeffsBase --------
232 : virtual void get(size_t i,
233 : double time,
234 : double el,
235 : std::vector<double> &res,
236 : std::vector<double> &c2) const;
237 : virtual void print(std::ostream &os);
238 : virtual void repr(std::vector<double> &res,
239 : std::vector<double> &err) const;
240 : virtual bool isnan() const;
241 :
242 : };
243 :
244 :
245 : }
246 :
247 : #endif
|