source: trunk/src/STSideBandSep.h@ 2972

Last change on this file since 2972 was 2865, checked in by Kana Sugimoto, 11 years ago

New Development: No

JIRA Issue: Yes (CAS-4141)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Added a private function, STSideBandSep::shiftTimeInGriddedST()

Test Programs:

Put in Release Notes: No

Module(s): asap.sbseparator

Description: STSideBandSep::shiftTimeInGriddedST() an issue, direction of spectra are not properly resolved in gridded MS by shifting TIME value in scantable by direction.


File size: 6.5 KB
RevLine 
[2707]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>
[2853]21#include <casa/Arrays/Vector.h>
[2707]22#include <measures/Measures/MDirection.h>
23#include <coordinates/Coordinates/DirectionCoordinate.h>
24#include <coordinates/Coordinates/SpectralCoordinate.h>
[2794]25#include <scimath/Mathematics/FFTServer.h>
[2707]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 **/
[2726]40 STSideBandSep() { throw( AipsError("No data set to process") ); };
41 explicit STSideBandSep(const vector<string> &names);
42 explicit STSideBandSep(const vector<ScantableWrapper> &tables);
[2707]43 virtual ~STSideBandSep();
44
[2794]45
[2707]46 /**
[2794]47 * Separate side bands
48 **/
49 void separate(string outname);
50
51 /**
[2726]52 * Set IFNO and frequency tolerance to select data to process
[2707]53 **/
[2726]54 void setFrequency(const unsigned int ifno, const string freqtol,
55 const string frame="");
[2707]56
57 /**
[2726]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 /**
[2712]85 * Set scantable to fill frequencies of image sideband (temporal)
[2707]86 **/
87 void setImageTable(const ScantableWrapper &s);
[2712]88 void setScanTb0(const ScantableWrapper &s);
[2726]89
[2707]90 /**
91 * Set additional information to fill frequencies of image sideband
92 **/
[2794]93 void setLO1(const string lo1, const string frame="TOPO",
[2726]94 const double reftime=-1, string refdir="");
[2711]95 void setLO1Root(const string name);
[2726]96
[2707]97private:
[2726]98 /** Initialize member variables **/
99 void init();
100 void initshift();
101
102 /** Return if the path exists (optionally, check file type) **/
[2707]103 Bool checkFile(const string name, string type="");
[2726]104
[2794]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
[2865]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);
[2794]137 /**
138 * Actual calculation of frequencies of image sideband
139 **/
140 void solveImageFrequency();
141
[2726]142 /**
143 * Get LO1 frequency to solve the frequencies of image side band
144 **/
[2711]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);
[2852]154 // bool getSpectraToSolve(const int polId, const int beamId,
155 // const double dirX, const double dirY,
156 // Matrix<float> &specmat, vector<uInt> &tabIdvec);
[2794]157 bool getSpectraToSolve(const int polId, const int beamId,
158 const double dirX, const double dirY,
[2852]159 Matrix<float> &specMat, Matrix<bool> &flagMat,
160 vector<uInt> &tabIdvec);
[2707]161
[2852]162 vector<float> solve(const Matrix<float> &specMat,
[2794]163 const vector<uInt> &tabIdvec,
164 const bool signal = true);
165
[2852]166 Vector<bool> collapseFlag(const Matrix<bool> &flagMat,
167 const vector<uInt> &tabIdvec,
168 const bool signal = true);
169
[2794]170 void shiftSpectrum(const Vector<float> &invec, double shift,
171 Vector<float> &outvec);
172
[2852]173 void shiftFlag(const Vector<bool> &invec, double shift,
174 Vector<bool> &outvec);
175
[2794]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
[2726]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.
[2794]194 int sigIfno_;
[2726]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
[2794]205 double lo1Freq_; // in Hz
[2707]206 MFrequency::Types loFrame_;
207 double loTime_;
208 string loDir_;
[2711]209 string asdmName_, asisName_;
[2707]210
[2794]211 //CountedPtr<Scantable> imgTab_p, sigTab_p;
[2712]212 CountedPtr<Scantable> imgTab_p, sigTab_p;
[2794]213 Table::TableType tp_;
214 FFTServer<Float, Complex> fftsf, fftsi;
[2707]215
216}; // class
217
218} // namespace
219
220#endif
Note: See TracBrowser for help on using the repository browser.