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