source: trunk/src/STSideBandSep.h@ 3146

Last change on this file since 3146 was 3106, checked in by Takeshi Nakazato, 8 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes/No

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Check-in asap modifications from Jim regarding casacore namespace conversion.

File size: 7.0 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
30namespace asap {
31
32class STSideBandSep {
33public:
34 /**
35 * constructors and a destructor
36 **/
[3106]37 STSideBandSep() { throw( casacore::AipsError("No data set to process") ); };
38 explicit STSideBandSep(const std::vector<std::string> &names);
39 explicit STSideBandSep(const std::vector<ScantableWrapper> &tables);
[2707]40 virtual ~STSideBandSep();
41
[2794]42
[2707]43 /**
[2794]44 * Separate side bands
45 **/
[3106]46 void separate(std::string outname);
[2794]47
48 /**
[2726]49 * Set IFNO and frequency tolerance to select data to process
[2707]50 **/
[3106]51 void setFrequency(const int ifno, const std::string freqtol,
52 const std::string frame="");
[2707]53
54 /**
[2726]55 * Set direction tolerance to group spectra.
56 * The spectra within this range will be averaged before procesing.
57 **/
[3106]58 void setDirTolerance(const std::vector<std::string> dirtol);
[2726]59
60 /**
61 * Set the number of channels shifted in image side band
62 * of each of scantable.
63 **/
[3106]64 void setShift(const std::vector<double> &shift);
[2726]65
66 /**
67 * Set rejection limit of solution.
68 **/
69 void setThreshold(const double limit);
70
71 /**
72 * Resolve both image and signal sideband when true is set.
73 **/
74 void solveBoth(const bool flag) { doboth_ = flag; };
75
76 /**
77 * Obtain spectra by subtracting the solution of the other sideband.
78 **/
79 void solvefromOther(const bool flag) { otherside_ = flag; };
80
81 /**
[2712]82 * Set scantable to fill frequencies of image sideband (temporal)
[2707]83 **/
84 void setImageTable(const ScantableWrapper &s);
[2712]85 void setScanTb0(const ScantableWrapper &s);
[2726]86
[2707]87 /**
88 * Set additional information to fill frequencies of image sideband
89 **/
[3106]90 void setLO1(const std::string lo1, const std::string frame="TOPO",
91 const double reftime=-1, std::string refdir="");
92 void setLO1Root(const std::string name);
[2726]93
[2707]94private:
[2726]95 /** Initialize member variables **/
96 void init();
97 void initshift();
98
99 /** Return if the path exists (optionally, check file type) **/
[3106]100 casacore::Bool checkFile(const std::string name, std::string type="");
[2726]101
[2794]102 /** **/
103 unsigned int setupShift();
[3106]104 bool getFreqInfo(const casacore::CountedPtr<Scantable> &stab, const unsigned int &ifno,
[2794]105 double &freq0, double &incr, unsigned int &nchan);
106
107 /** Grid scantable **/
108 ScantableWrapper gridTable();
[3106]109 void mapExtent(std::vector< casacore::CountedPtr<Scantable> > &tablist,
110 casacore::Double &xmin, casacore::Double &xmax,
111 casacore::Double &ymin, casacore::Double &ymax);
[2794]112
[2865]113 /**
114 * Shift TIME in gridded scantable for future imaging
115 *
116 * STGrid sets the identical time for all rows in scantable
117 * which is reasonable thing to do in position based averaging.
118 * However, this prevents CASA from finding proper pointing
119 * per spectra once the gridded scantable is converted to
120 * measurement set (MS). It is because MS does not
121 * have ability to store per spectra pointing information.
122 * MS stores pointing information in a subtable, POINTING,
123 * with corresponding TIME when an antenna pointed the direction.
124 * The pointing direction corresponding to a spectra is resolved
125 * in MS by interpolating DIRECTION in POINTING subtable in TIME
126 * the spectra is observed. If there are multiple match,
127 * the first match is adopted. Therefore, gridded table (whose TIME
128 * is set to a single value) is misunderstood in MS that all data
129 * come from a single pointing.
130 * The function workarounds this defect by artificially shifting
131 * TIME by INTERVAL in each row.
132 **/
[3106]133 void shiftTimeInGriddedST(const casacore::CountedPtr<Scantable> &stab);
[2794]134 /**
135 * Actual calculation of frequencies of image sideband
136 **/
137 void solveImageFrequency();
138
[2726]139 /**
140 * Get LO1 frequency to solve the frequencies of image side band
141 **/
[3106]142 bool getLo1FromAsdm(const std::string asdmname,
[2711]143 const double refval, const double refpix,
144 const double increment, const int nChan);
[3106]145 bool getLo1FromAsisTab(const std::string msname,
[2711]146 const double refval, const double refpix,
147 const double increment, const int nChan);
[3106]148 bool getLo1FromScanTab(casacore::CountedPtr< Scantable > &scantab,
[2711]149 const double refval, const double refpix,
150 const double increment, const int nChan);
[2852]151 // bool getSpectraToSolve(const int polId, const int beamId,
152 // const double dirX, const double dirY,
[3106]153 // Matrix<float> &specmat, std::vector<casacore::uInt> &tabIdvec);
[2794]154 bool getSpectraToSolve(const int polId, const int beamId,
155 const double dirX, const double dirY,
[3106]156 casacore::Matrix<float> &specMat, casacore::Matrix<bool> &flagMat,
157 std::vector<casacore::uInt> &tabIdvec);
[2707]158
[3106]159 std::vector<float> solve(const casacore::Matrix<float> &specMat,
160 const std::vector<casacore::uInt> &tabIdvec,
[2794]161 const bool signal = true);
162
[3106]163 casacore::Vector<bool> collapseFlag(const casacore::Matrix<bool> &flagMat,
164 const std::vector<casacore::uInt> &tabIdvec,
[2852]165 const bool signal = true);
166
[3106]167 void shiftSpectrum(const casacore::Vector<float> &invec, double shift,
168 casacore::Vector<float> &outvec);
[2794]169
[3106]170 void shiftFlag(const casacore::Vector<bool> &invec, double shift,
171 casacore::Vector<bool> &outvec);
[2852]172
[3106]173 void deconvolve(casacore::Matrix<float> &specmat, const std::vector<double> shiftvec,
174 const double threshold, casacore::Matrix<float> &outmat);
[2794]175
[3106]176 void aggregateMat(casacore::Matrix<float> &inmat, std::vector<float> &outvec);
[2794]177
[3106]178 void subtractFromOther(const casacore::Matrix<float> &shiftmat,
179 const std::vector<float> &invec,
180 const std::vector<double> &shift,
181 std::vector<float> &outvec);
[2794]182
183
184
[2726]185 /** Member variables **/
186 // input tables
[3106]187 std::vector<std::string> infileList_;
188 std::vector< casacore::CountedPtr<Scantable> > intabList_;
[2726]189 unsigned int ntable_;
190 // frequency and direction setup to select data.
[2794]191 int sigIfno_;
[3106]192 casacore::Quantum<casacore::Double> ftol_;
193 casacore::MFrequency::Types solFrame_;
194 std::vector<double> sigShift_, imgShift_;
[2726]195 unsigned int nshift_, nchan_;
[3106]196 std::vector< casacore::CountedPtr<Scantable> > tableList_;
197 casacore::Double xtol_, ytol_;
[2726]198 // solution parameters
199 bool otherside_, doboth_;
200 double rejlimit_;
201 // LO1
[2794]202 double lo1Freq_; // in Hz
[3106]203 casacore::MFrequency::Types loFrame_;
[2707]204 double loTime_;
[3106]205 std::string loDir_;
206 std::string asdmName_, asisName_;
[2707]207
[2794]208 //CountedPtr<Scantable> imgTab_p, sigTab_p;
[3106]209 casacore::CountedPtr<Scantable> imgTab_p, sigTab_p;
210 casacore::Table::TableType tp_;
211 casacore::FFTServer<casacore::Float, casacore::Complex> fftsf, fftsi;
[2707]212
213}; // class
214
215} // namespace
216
217#endif
Note: See TracBrowser for help on using the repository browser.