[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 |
|
---|
| 30 | using namespace std;
|
---|
| 31 | using namespace casa;
|
---|
| 32 |
|
---|
| 33 | namespace asap {
|
---|
| 34 |
|
---|
| 35 | class STSideBandSep {
|
---|
| 36 | public:
|
---|
| 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] | 97 | private:
|
---|
[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 |
|
---|
| 116 | /**
|
---|
| 117 | * Actual calculation of frequencies of image sideband
|
---|
| 118 | **/
|
---|
| 119 | void solveImageFrequency();
|
---|
| 120 |
|
---|
[2726] | 121 | /**
|
---|
| 122 | * Get LO1 frequency to solve the frequencies of image side band
|
---|
| 123 | **/
|
---|
[2711] | 124 | bool getLo1FromAsdm(const string asdmname,
|
---|
| 125 | const double refval, const double refpix,
|
---|
| 126 | const double increment, const int nChan);
|
---|
| 127 | bool getLo1FromAsisTab(const string msname,
|
---|
| 128 | const double refval, const double refpix,
|
---|
| 129 | const double increment, const int nChan);
|
---|
| 130 | bool getLo1FromScanTab(casa::CountedPtr< Scantable > &scantab,
|
---|
| 131 | const double refval, const double refpix,
|
---|
| 132 | const double increment, const int nChan);
|
---|
[2852] | 133 | // bool getSpectraToSolve(const int polId, const int beamId,
|
---|
| 134 | // const double dirX, const double dirY,
|
---|
| 135 | // Matrix<float> &specmat, vector<uInt> &tabIdvec);
|
---|
[2794] | 136 | bool getSpectraToSolve(const int polId, const int beamId,
|
---|
| 137 | const double dirX, const double dirY,
|
---|
[2852] | 138 | Matrix<float> &specMat, Matrix<bool> &flagMat,
|
---|
| 139 | vector<uInt> &tabIdvec);
|
---|
[2707] | 140 |
|
---|
[2852] | 141 | vector<float> solve(const Matrix<float> &specMat,
|
---|
[2794] | 142 | const vector<uInt> &tabIdvec,
|
---|
| 143 | const bool signal = true);
|
---|
| 144 |
|
---|
[2852] | 145 | Vector<bool> collapseFlag(const Matrix<bool> &flagMat,
|
---|
| 146 | const vector<uInt> &tabIdvec,
|
---|
| 147 | const bool signal = true);
|
---|
| 148 |
|
---|
[2794] | 149 | void shiftSpectrum(const Vector<float> &invec, double shift,
|
---|
| 150 | Vector<float> &outvec);
|
---|
| 151 |
|
---|
[2852] | 152 | void shiftFlag(const Vector<bool> &invec, double shift,
|
---|
| 153 | Vector<bool> &outvec);
|
---|
| 154 |
|
---|
[2794] | 155 | void deconvolve(Matrix<float> &specmat, const vector<double> shiftvec,
|
---|
| 156 | const double threshold, Matrix<float> &outmat);
|
---|
| 157 |
|
---|
| 158 | void aggregateMat(Matrix<float> &inmat, vector<float> &outvec);
|
---|
| 159 |
|
---|
| 160 | void subtractFromOther(const Matrix<float> &shiftmat,
|
---|
| 161 | const vector<float> &invec,
|
---|
| 162 | const vector<double> &shift,
|
---|
| 163 | vector<float> &outvec);
|
---|
| 164 |
|
---|
| 165 |
|
---|
| 166 |
|
---|
[2726] | 167 | /** Member variables **/
|
---|
| 168 | // input tables
|
---|
| 169 | vector<string> infileList_;
|
---|
| 170 | vector< CountedPtr<Scantable> > intabList_;
|
---|
| 171 | unsigned int ntable_;
|
---|
| 172 | // frequency and direction setup to select data.
|
---|
[2794] | 173 | int sigIfno_;
|
---|
[2726] | 174 | Quantum<Double> ftol_;
|
---|
| 175 | MFrequency::Types solFrame_;
|
---|
| 176 | vector<double> sigShift_, imgShift_;
|
---|
| 177 | unsigned int nshift_, nchan_;
|
---|
| 178 | vector< CountedPtr<Scantable> > tableList_;
|
---|
| 179 | Double xtol_, ytol_;
|
---|
| 180 | // solution parameters
|
---|
| 181 | bool otherside_, doboth_;
|
---|
| 182 | double rejlimit_;
|
---|
| 183 | // LO1
|
---|
[2794] | 184 | double lo1Freq_; // in Hz
|
---|
[2707] | 185 | MFrequency::Types loFrame_;
|
---|
| 186 | double loTime_;
|
---|
| 187 | string loDir_;
|
---|
[2711] | 188 | string asdmName_, asisName_;
|
---|
[2707] | 189 |
|
---|
[2794] | 190 | //CountedPtr<Scantable> imgTab_p, sigTab_p;
|
---|
[2712] | 191 | CountedPtr<Scantable> imgTab_p, sigTab_p;
|
---|
[2794] | 192 | Table::TableType tp_;
|
---|
| 193 | FFTServer<Float, Complex> fftsf, fftsi;
|
---|
[2707] | 194 |
|
---|
| 195 | }; // class
|
---|
| 196 |
|
---|
| 197 | } // namespace
|
---|
| 198 |
|
---|
| 199 | #endif
|
---|