[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> |
---|
| 21 | #include <measures/Measures/MDirection.h> |
---|
| 22 | #include <coordinates/Coordinates/DirectionCoordinate.h> |
---|
| 23 | #include <coordinates/Coordinates/SpectralCoordinate.h> |
---|
[2794] | 24 | #include <scimath/Mathematics/FFTServer.h> |
---|
[2707] | 25 | // asap |
---|
| 26 | #include "ScantableWrapper.h" |
---|
| 27 | #include "Scantable.h" |
---|
| 28 | |
---|
| 29 | using namespace std; |
---|
| 30 | using namespace casa; |
---|
| 31 | |
---|
| 32 | namespace asap { |
---|
| 33 | |
---|
| 34 | class STSideBandSep { |
---|
| 35 | public: |
---|
| 36 | /** |
---|
| 37 | * constructors and a destructor |
---|
| 38 | **/ |
---|
[2726] | 39 | STSideBandSep() { throw( AipsError("No data set to process") ); }; |
---|
| 40 | explicit STSideBandSep(const vector<string> &names); |
---|
| 41 | explicit STSideBandSep(const vector<ScantableWrapper> &tables); |
---|
[2707] | 42 | virtual ~STSideBandSep(); |
---|
| 43 | |
---|
[2794] | 44 | ///////////// temp functions ////////////////////// |
---|
| 45 | //void cpprfft(std::vector<float> invec); |
---|
| 46 | ////////////////////////////////////////////////// |
---|
| 47 | |
---|
[2707] | 48 | /** |
---|
[2794] | 49 | * Separate side bands |
---|
| 50 | **/ |
---|
| 51 | void separate(string outname); |
---|
| 52 | |
---|
| 53 | /** |
---|
[2726] | 54 | * Set IFNO and frequency tolerance to select data to process |
---|
[2707] | 55 | **/ |
---|
[2726] | 56 | void setFrequency(const unsigned int ifno, const string freqtol, |
---|
| 57 | const string frame=""); |
---|
[2707] | 58 | |
---|
| 59 | /** |
---|
[2726] | 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 | /** |
---|
[2712] | 87 | * Set scantable to fill frequencies of image sideband (temporal) |
---|
[2707] | 88 | **/ |
---|
| 89 | void setImageTable(const ScantableWrapper &s); |
---|
[2712] | 90 | void setScanTb0(const ScantableWrapper &s); |
---|
[2726] | 91 | |
---|
[2707] | 92 | /** |
---|
| 93 | * Set additional information to fill frequencies of image sideband |
---|
| 94 | **/ |
---|
[2794] | 95 | void setLO1(const string lo1, const string frame="TOPO", |
---|
[2726] | 96 | const double reftime=-1, string refdir=""); |
---|
[2711] | 97 | void setLO1Root(const string name); |
---|
[2726] | 98 | |
---|
[2707] | 99 | private: |
---|
[2726] | 100 | /** Initialize member variables **/ |
---|
| 101 | void init(); |
---|
| 102 | void initshift(); |
---|
| 103 | |
---|
| 104 | /** Return if the path exists (optionally, check file type) **/ |
---|
[2707] | 105 | Bool checkFile(const string name, string type=""); |
---|
[2726] | 106 | |
---|
[2794] | 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 | |
---|
[2726] | 123 | /** |
---|
| 124 | * Get LO1 frequency to solve the frequencies of image side band |
---|
| 125 | **/ |
---|
[2711] | 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); |
---|
[2794] | 135 | bool getSpectraToSolve(const int polId, const int beamId, |
---|
| 136 | const double dirX, const double dirY, |
---|
| 137 | Matrix<float> &specmat, vector<uInt> &tabIdvec); |
---|
[2707] | 138 | |
---|
[2794] | 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 | |
---|
[2726] | 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. |
---|
[2794] | 164 | int sigIfno_; |
---|
[2726] | 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 |
---|
[2794] | 175 | double lo1Freq_; // in Hz |
---|
[2707] | 176 | MFrequency::Types loFrame_; |
---|
| 177 | double loTime_; |
---|
| 178 | string loDir_; |
---|
[2711] | 179 | string asdmName_, asisName_; |
---|
[2707] | 180 | |
---|
[2794] | 181 | //CountedPtr<Scantable> imgTab_p, sigTab_p; |
---|
[2712] | 182 | CountedPtr<Scantable> imgTab_p, sigTab_p; |
---|
[2794] | 183 | Table::TableType tp_; |
---|
| 184 | FFTServer<Float, Complex> fftsf, fftsi; |
---|
[2712] | 185 | // TEMPORAL member |
---|
| 186 | CountedPtr<Scantable> st0_; |
---|
[2707] | 187 | |
---|
| 188 | }; // class |
---|
| 189 | |
---|
| 190 | } // namespace |
---|
| 191 | |
---|
| 192 | #endif |
---|