1 | // C++ Interface: STSideBandSep
|
---|
2 | //
|
---|
3 | // Description:
|
---|
4 | // A class to invoke sideband separation of Scantable
|
---|
5 | //
|
---|
6 | // Author: Kanako Sugimoto <kana.sugi@nao.ac.jp>, (C) 2012
|
---|
7 | //
|
---|
8 | // Copyright: See COPYING file that comes with this distribution
|
---|
9 | //
|
---|
10 | //
|
---|
11 | #ifndef ASAPSIDEBANDSEP_H
|
---|
12 | #define ASAPSIDEBANDSEP_H
|
---|
13 |
|
---|
14 | // STL
|
---|
15 | #include <iostream>
|
---|
16 | #include <string>
|
---|
17 | #include <vector>
|
---|
18 | // casacore
|
---|
19 | #include <casa/aips.h>
|
---|
20 | #include <casa/Utilities/CountedPtr.h>
|
---|
21 | #include <casa/Arrays/Vector.h>
|
---|
22 | #include <measures/Measures/MDirection.h>
|
---|
23 | #include <coordinates/Coordinates/DirectionCoordinate.h>
|
---|
24 | #include <coordinates/Coordinates/SpectralCoordinate.h>
|
---|
25 | #include <scimath/Mathematics/FFTServer.h>
|
---|
26 | // asap
|
---|
27 | #include "ScantableWrapper.h"
|
---|
28 | #include "Scantable.h"
|
---|
29 |
|
---|
30 | using namespace std;
|
---|
31 | using namespace casa;
|
---|
32 |
|
---|
33 | namespace asap {
|
---|
34 |
|
---|
35 | class STSideBandSep {
|
---|
36 | public:
|
---|
37 | /**
|
---|
38 | * constructors and a destructor
|
---|
39 | **/
|
---|
40 | STSideBandSep() { throw( AipsError("No data set to process") ); };
|
---|
41 | explicit STSideBandSep(const vector<string> &names);
|
---|
42 | explicit STSideBandSep(const vector<ScantableWrapper> &tables);
|
---|
43 | virtual ~STSideBandSep();
|
---|
44 |
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Separate side bands
|
---|
48 | **/
|
---|
49 | void separate(string outname);
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Set IFNO and frequency tolerance to select data to process
|
---|
53 | **/
|
---|
54 | void setFrequency(const unsigned int ifno, const string freqtol,
|
---|
55 | const string frame="");
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Set direction tolerance to group spectra.
|
---|
59 | * The spectra within this range will be averaged before procesing.
|
---|
60 | **/
|
---|
61 | void setDirTolerance(const vector<string> dirtol);
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Set the number of channels shifted in image side band
|
---|
65 | * of each of scantable.
|
---|
66 | **/
|
---|
67 | void setShift(const vector<double> &shift);
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Set rejection limit of solution.
|
---|
71 | **/
|
---|
72 | void setThreshold(const double limit);
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Resolve both image and signal sideband when true is set.
|
---|
76 | **/
|
---|
77 | void solveBoth(const bool flag) { doboth_ = flag; };
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Obtain spectra by subtracting the solution of the other sideband.
|
---|
81 | **/
|
---|
82 | void solvefromOther(const bool flag) { otherside_ = flag; };
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Set scantable to fill frequencies of image sideband (temporal)
|
---|
86 | **/
|
---|
87 | void setImageTable(const ScantableWrapper &s);
|
---|
88 | void setScanTb0(const ScantableWrapper &s);
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Set additional information to fill frequencies of image sideband
|
---|
92 | **/
|
---|
93 | void setLO1(const string lo1, const string frame="TOPO",
|
---|
94 | const double reftime=-1, string refdir="");
|
---|
95 | void setLO1Root(const string name);
|
---|
96 |
|
---|
97 | private:
|
---|
98 | /** Initialize member variables **/
|
---|
99 | void init();
|
---|
100 | void initshift();
|
---|
101 |
|
---|
102 | /** Return if the path exists (optionally, check file type) **/
|
---|
103 | Bool checkFile(const string name, string type="");
|
---|
104 |
|
---|
105 | /** **/
|
---|
106 | unsigned int setupShift();
|
---|
107 | bool getFreqInfo(const CountedPtr<Scantable> &stab, const unsigned int &ifno,
|
---|
108 | double &freq0, double &incr, unsigned int &nchan);
|
---|
109 |
|
---|
110 | /** Grid scantable **/
|
---|
111 | ScantableWrapper gridTable();
|
---|
112 | void mapExtent(vector< CountedPtr<Scantable> > &tablist,
|
---|
113 | Double &xmin, Double &xmax,
|
---|
114 | Double &ymin, Double &ymax);
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Actual calculation of frequencies of image sideband
|
---|
118 | **/
|
---|
119 | void solveImageFrequency();
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Get LO1 frequency to solve the frequencies of image side band
|
---|
123 | **/
|
---|
124 | bool getLo1FromAsdm(const string asdmname,
|
---|
125 | const double refval, const double refpix,
|
---|
126 | const double increment, const int nChan);
|
---|
127 | bool getLo1FromAsisTab(const string msname,
|
---|
128 | const double refval, const double refpix,
|
---|
129 | const double increment, const int nChan);
|
---|
130 | bool getLo1FromScanTab(casa::CountedPtr< Scantable > &scantab,
|
---|
131 | const double refval, const double refpix,
|
---|
132 | const double increment, const int nChan);
|
---|
133 | // bool getSpectraToSolve(const int polId, const int beamId,
|
---|
134 | // const double dirX, const double dirY,
|
---|
135 | // Matrix<float> &specmat, vector<uInt> &tabIdvec);
|
---|
136 | bool getSpectraToSolve(const int polId, const int beamId,
|
---|
137 | const double dirX, const double dirY,
|
---|
138 | Matrix<float> &specMat, Matrix<bool> &flagMat,
|
---|
139 | vector<uInt> &tabIdvec);
|
---|
140 |
|
---|
141 | vector<float> solve(const Matrix<float> &specMat,
|
---|
142 | const vector<uInt> &tabIdvec,
|
---|
143 | const bool signal = true);
|
---|
144 |
|
---|
145 | Vector<bool> collapseFlag(const Matrix<bool> &flagMat,
|
---|
146 | const vector<uInt> &tabIdvec,
|
---|
147 | const bool signal = true);
|
---|
148 |
|
---|
149 | void shiftSpectrum(const Vector<float> &invec, double shift,
|
---|
150 | Vector<float> &outvec);
|
---|
151 |
|
---|
152 | void shiftFlag(const Vector<bool> &invec, double shift,
|
---|
153 | Vector<bool> &outvec);
|
---|
154 |
|
---|
155 | void deconvolve(Matrix<float> &specmat, const vector<double> shiftvec,
|
---|
156 | const double threshold, Matrix<float> &outmat);
|
---|
157 |
|
---|
158 | void aggregateMat(Matrix<float> &inmat, vector<float> &outvec);
|
---|
159 |
|
---|
160 | void subtractFromOther(const Matrix<float> &shiftmat,
|
---|
161 | const vector<float> &invec,
|
---|
162 | const vector<double> &shift,
|
---|
163 | vector<float> &outvec);
|
---|
164 |
|
---|
165 |
|
---|
166 |
|
---|
167 | /** Member variables **/
|
---|
168 | // input tables
|
---|
169 | vector<string> infileList_;
|
---|
170 | vector< CountedPtr<Scantable> > intabList_;
|
---|
171 | unsigned int ntable_;
|
---|
172 | // frequency and direction setup to select data.
|
---|
173 | int sigIfno_;
|
---|
174 | Quantum<Double> ftol_;
|
---|
175 | MFrequency::Types solFrame_;
|
---|
176 | vector<double> sigShift_, imgShift_;
|
---|
177 | unsigned int nshift_, nchan_;
|
---|
178 | vector< CountedPtr<Scantable> > tableList_;
|
---|
179 | Double xtol_, ytol_;
|
---|
180 | // solution parameters
|
---|
181 | bool otherside_, doboth_;
|
---|
182 | double rejlimit_;
|
---|
183 | // LO1
|
---|
184 | double lo1Freq_; // in Hz
|
---|
185 | MFrequency::Types loFrame_;
|
---|
186 | double loTime_;
|
---|
187 | string loDir_;
|
---|
188 | string asdmName_, asisName_;
|
---|
189 |
|
---|
190 | //CountedPtr<Scantable> imgTab_p, sigTab_p;
|
---|
191 | CountedPtr<Scantable> imgTab_p, sigTab_p;
|
---|
192 | Table::TableType tp_;
|
---|
193 | FFTServer<Float, Complex> fftsf, fftsi;
|
---|
194 |
|
---|
195 | }; // class
|
---|
196 |
|
---|
197 | } // namespace
|
---|
198 |
|
---|
199 | #endif
|
---|