source: branches/plotter2/src/STSideBandSep.h@ 2884

Last change on this file since 2884 was 2794, checked in by Kana Sugimoto, 12 years ago

New Development: Yes

JIRA Issue: Yes (CAS-4141/TRAC-290)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sbseparator module

Description: Pushed python codes down to cpp.


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