Source
39
39
#include <ms/MeasurementSets/MSPointing.h>
40
40
#include <ms/MeasurementSets/MSPointingColumns.h>
41
41
#include <measures/Measures/MCDirection.h>
42
42
#include <measures/Measures/MDirection.h>
43
43
#include <measures/Measures/MPosition.h>
44
44
#include <measures/Measures/MEpoch.h>
45
45
#include <measures/Measures/MeasFrame.h>
46
46
#include <measures/TableMeasures/ScalarMeasColumn.h>
47
47
#include <measures/TableMeasures/ArrayMeasColumn.h>
48
48
#include <tables/Tables/ScalarColumn.h>
49
-
49
+
// CAS-8418 //
50
50
#include <synthesis/Utilities/SDPosInterpolator.h>
51
51
#include <memory> // for unique_ptr<>
52
52
#include <utility> // for std::pair
53
53
54
54
namespace casa {
55
55
56
56
///
57
57
// <summary>Calculates Pointing Direction Efficiently</summary>
58
58
//
59
59
//<use visibility=export>
120
120
// <thrown>
121
121
// </thrown>
122
122
//
123
123
// <todo asof="before2018/05/22">
124
124
// <li> Define unit test
125
125
// <li> Implement more sophisticated interpolation method such as cubic spline
126
126
// </todo>
127
127
///
128
128
129
129
class SplineInterpolation; // CAS-8418 Forward Reference //
130
-
// class DirectionColumnsAccessor; // CAS-8418 Forward Reference //
131
130
132
131
class PointingDirectionCalculator {
133
132
public:
134
133
135
134
//+
136
135
// CAS-8418: typedef of accessor_ and Direction column types.
137
136
//-
138
137
typedef
139
138
casacore::MDirection (*ACCESSOR)( casacore::ROMSPointingColumns &pointingColumns,
140
139
casacore::uInt rownr);
141
140
typedef
142
141
enum DC_ { DIRECTION, TARGET, POINTING_OFFSET, SOURCE_OFFSET, ENCODER, nItems} PtColID;
143
142
143
+
typedef casacore::Vector<casacore::Vector<casacore::Vector<casacore::Vector<casacore::Double> > > >
144
+
COEFF;
145
+
144
146
// Enumerations for memory layout of the output pointing direction array.
145
147
// User should select the layout according to an usercase of this class.
146
148
enum MatrixShape {
147
149
// Memory layout is "column major"
148
150
COLUMN_MAJOR,
149
151
// Memory layout is "row major"
150
152
ROW_MAJOR
151
153
};
152
154
153
155
//+
186
188
casacore::String const &observation = "",
187
189
casacore::String const &uvrange = "",
188
190
casacore::String const &msselect = "");
189
191
190
192
//+
191
193
// Select which POINTING column to use for pointing direction calculation.
192
194
// Possible values are "DIRECTION" (default), "TARGET", "POINTING_OFFSET",
193
195
// "SOURCE_OFFSET", and "ENCODER". These values are all case-sensitive.
194
196
//
195
197
// CAS-8418 Update
196
-
// Spline-Interpolation initialze is inserted for each POINTING Column.
197
-
// Once this initialization is done, the object will be reused.
198
+
// Spline-Interpolation initialization is inserted for each POINTING Column.
199
+
// Once this is done, the object will be reused.
198
200
//-
199
201
200
202
void setDirectionColumn(casacore::String const &columnName = "DIRECTION");
201
203
202
204
//+
203
205
// Set output direction reference frame. This accepts reference strings which
204
206
// <linkto class=MDirection>MDirection</linkto> can recognize.
205
207
// If given string is invalid, the frame will be set to "J2000".
206
208
//-
207
209
292
294
casacore::uInt getRowId(casacore::uInt irow);
293
295
294
296
//***************************************
295
297
// CAS-8418 Spline Interpolation API
296
298
//***************************************
297
299
298
300
// Spline interpolation Enable/Disable (true=ENABLE)
299
301
300
302
inline void setSplineInterpolation(bool mode) {useSplineInterpolation_ = mode;};
301
303
302
-
// Spline Object handle (on Debug)
303
-
304
-
inline casa::SplineInterpolation *getCurrentSplineObj() {return currSpline_; }
305
-
306
304
// Curret Direction column (=accessor in this source) (for UT)
307
305
308
306
inline PtColID getCurretAccessorId() { return accessorId_ ; };
309
307
310
-
private:
308
+
// Exporting COEFF table. //
309
+
310
+
bool isCoefficientReady(); // true if current COEFF is availabe
311
+
COEFF exportCoeff(); // returns copy of COEFF
312
+
313
+
private:
311
314
312
315
void init();
313
316
void initPointingTable(casacore::Int const antennaId);
314
317
void resetAntennaPosition(casacore::Int const antennaId);
315
318
void resetTime(casacore::Double const timestamp);
316
319
void inspectAntenna();
317
320
void configureMovingSourceCorrection();
318
321
319
322
casacore::Vector<casacore::Double> doGetDirection(casacore::uInt irow);
320
323
casacore::Vector<casacore::Double> doGetDirection(casacore::uInt irow, casacore::uInt antID);
375
378
// Spline Object for each Direction-Column
376
379
casacore::vector<std::unique_ptr<casa::SplineInterpolation> > splineObj_;
377
380
378
381
// Internal conditions to check limitted service.
379
382
casacore::Vector<bool> initializeReady_ ;
380
383
casacore::Vector<bool> coefficientReady_ ;
381
384
382
385
// Accessor ID (See typedef above. )
383
386
PtColID accessorId_ ;
384
387
385
-
// creating temporary Spline object (in construction)
388
+
// check specified Column when creating Spline-Object.
386
389
387
390
bool checkColumn(casacore::MeasurementSet const &ms,
388
391
casacore::String const &columnName );
389
392
390
-
// Initialize Coefficient and others
391
-
bool initializeSplinefromPointingColumn(casacore::MeasurementSet const &ms,
392
-
PtColID colNo );
393
+
// Initialize Coefficient table.
394
+
bool initializeSplinefromPointingColumn(casacore::MeasurementSet const &ms, PtColID colNo );
395
+
396
+
// Current Spline-Object handle. (only available SplineInterpolation class)
397
+
casa::SplineInterpolation *getCurrentSplineObj() {return currSpline_; }
393
398
394
399
};
395
400
396
401
//+
397
402
// CAS-8418
398
403
// Spline Interpolation Class
399
404
//-
400
405
401
406
class SplineInterpolation {
402
407
public:
403
408
// Coefficient table typedef //
404
409
typedef casacore::Vector<casacore::Vector<casacore::Vector<casacore::Vector<casacore::Double> > > >
405
410
COEFF;
406
411
407
412
// Constructor
408
413
SplineInterpolation(casacore::MeasurementSet const &ms, PointingDirectionCalculator::ACCESSOR acc );
409
414
410
415
~SplineInterpolation() { }
411
416
412
-
// Calculate function //
417
+
// Calculating Function //
413
418
414
419
casacore::Vector<casacore::Double> calculate(casacore::uInt row,
415
420
casacore::Double dt,
416
421
casacore::uInt AntennaID =0);
417
-
// Internal stauts (for inspection) //
422
+
// Spline-Obj coefficient status //
418
423
419
424
bool isCoefficientReady() {return stsCofficientReady; }
420
425
421
426
// Programmers API:: for Coefficient Table access //
422
427
423
-
casacore::Vector<casacore::Vector<casacore::Vector<casacore::Vector<casacore::Double> > > >
424
-
getCoeff() { return coeff_; }
428
+
COEFF getCoeff() { return coeff_; }
425
429
426
430
private:
427
431
// default constructor
428
432
429
433
SplineInterpolation();
430
434
431
435
// constructor sub.
432
436
433
437
void init( casacore::MeasurementSet const &ms,
434
438
PointingDirectionCalculator::ACCESSOR const my_accessor);
435
439
436
440
// Coefficient (set up by SDPosInterpolator)
437
-
casacore::Vector<casacore::Vector<casacore::Vector<casacore::Vector<casacore::Double> > > >
438
-
coeff_;
441
+
442
+
COEFF coeff_;
439
443
440
444
// Interal Staus (one Spline status)//
441
445
442
446
bool stsCofficientReady = false;
443
447
444
448
// Coeff debug in csv. //
445
449
void dumpCsvCoeff();
446
450
447
451
};
448
452