source: branches/casa-release-4_3/src/STSideBandSep.h@ 3037

Last change on this file since 3037 was 2976, checked in by Kana Sugimoto, 10 years ago

New Development: No

JIRA Issue: Yes (CAS-5139)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asap.sbseparator

Description: Fixed a bug for ifno=-1.


File size: 6.5 KB
Line 
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
30using namespace std;
31using namespace casa;
32
33namespace asap {
34
35class STSideBandSep {
36public:
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 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
97private:
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 * Shift TIME in gridded scantable for future imaging
118 *
119 * STGrid sets the identical time for all rows in scantable
120 * which is reasonable thing to do in position based averaging.
121 * However, this prevents CASA from finding proper pointing
122 * per spectra once the gridded scantable is converted to
123 * measurement set (MS). It is because MS does not
124 * have ability to store per spectra pointing information.
125 * MS stores pointing information in a subtable, POINTING,
126 * with corresponding TIME when an antenna pointed the direction.
127 * The pointing direction corresponding to a spectra is resolved
128 * in MS by interpolating DIRECTION in POINTING subtable in TIME
129 * the spectra is observed. If there are multiple match,
130 * the first match is adopted. Therefore, gridded table (whose TIME
131 * is set to a single value) is misunderstood in MS that all data
132 * come from a single pointing.
133 * The function workarounds this defect by artificially shifting
134 * TIME by INTERVAL in each row.
135 **/
136 void shiftTimeInGriddedST(const CountedPtr<Scantable> &stab);
137 /**
138 * Actual calculation of frequencies of image sideband
139 **/
140 void solveImageFrequency();
141
142 /**
143 * Get LO1 frequency to solve the frequencies of image side band
144 **/
145 bool getLo1FromAsdm(const string asdmname,
146 const double refval, const double refpix,
147 const double increment, const int nChan);
148 bool getLo1FromAsisTab(const string msname,
149 const double refval, const double refpix,
150 const double increment, const int nChan);
151 bool getLo1FromScanTab(casa::CountedPtr< Scantable > &scantab,
152 const double refval, const double refpix,
153 const double increment, const int nChan);
154 // bool getSpectraToSolve(const int polId, const int beamId,
155 // const double dirX, const double dirY,
156 // Matrix<float> &specmat, vector<uInt> &tabIdvec);
157 bool getSpectraToSolve(const int polId, const int beamId,
158 const double dirX, const double dirY,
159 Matrix<float> &specMat, Matrix<bool> &flagMat,
160 vector<uInt> &tabIdvec);
161
162 vector<float> solve(const Matrix<float> &specMat,
163 const vector<uInt> &tabIdvec,
164 const bool signal = true);
165
166 Vector<bool> collapseFlag(const Matrix<bool> &flagMat,
167 const vector<uInt> &tabIdvec,
168 const bool signal = true);
169
170 void shiftSpectrum(const Vector<float> &invec, double shift,
171 Vector<float> &outvec);
172
173 void shiftFlag(const Vector<bool> &invec, double shift,
174 Vector<bool> &outvec);
175
176 void deconvolve(Matrix<float> &specmat, const vector<double> shiftvec,
177 const double threshold, Matrix<float> &outmat);
178
179 void aggregateMat(Matrix<float> &inmat, vector<float> &outvec);
180
181 void subtractFromOther(const Matrix<float> &shiftmat,
182 const vector<float> &invec,
183 const vector<double> &shift,
184 vector<float> &outvec);
185
186
187
188 /** Member variables **/
189 // input tables
190 vector<string> infileList_;
191 vector< CountedPtr<Scantable> > intabList_;
192 unsigned int ntable_;
193 // frequency and direction setup to select data.
194 int sigIfno_;
195 Quantum<Double> ftol_;
196 MFrequency::Types solFrame_;
197 vector<double> sigShift_, imgShift_;
198 unsigned int nshift_, nchan_;
199 vector< CountedPtr<Scantable> > tableList_;
200 Double xtol_, ytol_;
201 // solution parameters
202 bool otherside_, doboth_;
203 double rejlimit_;
204 // LO1
205 double lo1Freq_; // in Hz
206 MFrequency::Types loFrame_;
207 double loTime_;
208 string loDir_;
209 string asdmName_, asisName_;
210
211 //CountedPtr<Scantable> imgTab_p, sigTab_p;
212 CountedPtr<Scantable> imgTab_p, sigTab_p;
213 Table::TableType tp_;
214 FFTServer<Float, Complex> fftsf, fftsi;
215
216}; // class
217
218} // namespace
219
220#endif
Note: See TracBrowser for help on using the repository browser.