[847] | 1 | // |
---|
| 2 | // C++ Interface: Scantable |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | #ifndef ASAPSCANTABLEWRAPPER_H |
---|
| 13 | #define ASAPSCANTABLEWRAPPER_H |
---|
[2] | 14 | |
---|
| 15 | #include <vector> |
---|
| 16 | #include <string> |
---|
[380] | 17 | #include <casa/Arrays/Vector.h> |
---|
[2] | 18 | |
---|
[465] | 19 | #include "MathUtils.h" |
---|
| 20 | #include "SDFitTable.h" |
---|
[847] | 21 | #include "Scantable.h" |
---|
[2] | 22 | |
---|
[83] | 23 | namespace asap { |
---|
[847] | 24 | /** |
---|
| 25 | * This class contains and wraps a CountedPtr<Scantable>, as the CountedPtr |
---|
| 26 | * class does not provide the dor operator which is need for references |
---|
| 27 | * in boost::python |
---|
| 28 | * see Scantable for interfce description |
---|
| 29 | * |
---|
| 30 | * @brief The main ASAP data container wrapper |
---|
| 31 | * @author Malte Marquarding |
---|
| 32 | * @date 2006-02-23 |
---|
| 33 | * @version 2.0a |
---|
| 34 | */ |
---|
| 35 | class ScantableWrapper { |
---|
[2] | 36 | |
---|
| 37 | public: |
---|
[847] | 38 | ScantableWrapper(const std::string& name) : |
---|
| 39 | table_(new Scantable(name)) {;} |
---|
[90] | 40 | |
---|
[847] | 41 | ScantableWrapper() : |
---|
| 42 | table_(new Scantable()) {;} |
---|
[90] | 43 | |
---|
[847] | 44 | ScantableWrapper(casa::CountedPtr<Scantable> cp) : table_(cp) {;} |
---|
[90] | 45 | |
---|
[847] | 46 | ScantableWrapper(const ScantableWrapper& mt) : |
---|
| 47 | table_(mt.getCP()) {;} |
---|
[90] | 48 | |
---|
[847] | 49 | ScantableWrapper(const ScantableWrapper& mt, const std::string& expr) : |
---|
| 50 | table_(new Scantable(mt.getCP()->table(), expr)) {;} |
---|
[80] | 51 | |
---|
[847] | 52 | ScantableWrapper copy() { |
---|
| 53 | return ScantableWrapper(new Scantable(*(this->getCP()), false)); |
---|
[80] | 54 | } |
---|
| 55 | |
---|
[483] | 56 | |
---|
[51] | 57 | std::vector<float> getSpectrum(int whichRow=0) const { |
---|
[2] | 58 | return table_->getSpectrum(whichRow); |
---|
| 59 | } |
---|
[527] | 60 | |
---|
[745] | 61 | std::vector<float> getStokesSpectrum(int whichRow=0, |
---|
| 62 | bool linPol=false) const { |
---|
[505] | 63 | return table_->getStokesSpectrum(whichRow, linPol); |
---|
[421] | 64 | } |
---|
| 65 | |
---|
[539] | 66 | std::vector<float> stokesToPolSpectrum(int whichRow=0, bool linear=false, |
---|
[745] | 67 | int polIdx=-1) const { |
---|
[494] | 68 | return table_->stokesToPolSpectrum(whichRow, linear, polIdx); |
---|
[431] | 69 | } |
---|
| 70 | |
---|
[527] | 71 | // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const { |
---|
| 72 | // Boost fails with 4 arguments. |
---|
[745] | 73 | std::string getPolarizationLabel(bool linear, bool stokes, |
---|
| 74 | bool linPol) const { |
---|
[527] | 75 | int polIdx = -1; |
---|
| 76 | return table_->getPolarizationLabel(linear, stokes, linPol, polIdx); |
---|
[494] | 77 | } |
---|
[527] | 78 | |
---|
[158] | 79 | std::vector<double> getAbcissa(int whichRow=0) const { |
---|
| 80 | return table_->getAbcissa(whichRow); |
---|
[41] | 81 | } |
---|
[158] | 82 | std::string getAbcissaString(int whichRow=0) const { |
---|
| 83 | return table_->getAbcissaString(whichRow); |
---|
[105] | 84 | } |
---|
[41] | 85 | |
---|
[157] | 86 | std::vector<float> getTsys() { |
---|
| 87 | int nRow = table_->nRow(); |
---|
| 88 | std::vector<float> result(nRow); |
---|
| 89 | for (uint i=0; i<nRow; i++) { |
---|
| 90 | result[i] = table_->getTsys(i); |
---|
| 91 | } |
---|
| 92 | return result; |
---|
| 93 | } |
---|
| 94 | |
---|
[51] | 95 | std::string getTime(int whichRow=0) {return table_->getTime(whichRow);} |
---|
[2] | 96 | |
---|
[207] | 97 | std::string getFluxUnit() const {return table_->getFluxUnit();} |
---|
[220] | 98 | void setFluxUnit(const std::string& unit) {table_->setFluxUnit(unit);} |
---|
[207] | 99 | |
---|
[238] | 100 | void setInstrument(const std::string& name) {table_->setInstrument(name);} |
---|
| 101 | |
---|
[90] | 102 | std::vector<bool> getMask(int whichRow=0) const { |
---|
| 103 | return table_->getMask(whichRow); |
---|
[16] | 104 | } |
---|
[2] | 105 | |
---|
[90] | 106 | void flag(int whichRow=-1) { |
---|
| 107 | table_->flag(whichRow); |
---|
| 108 | } |
---|
[51] | 109 | std::string getSourceName(int whichRow=0) { |
---|
[2] | 110 | return table_->getSourceName(whichRow); |
---|
| 111 | } |
---|
| 112 | |
---|
[794] | 113 | float getElevation(int whichRow=0) { |
---|
| 114 | return table_->getElevation(whichRow); |
---|
| 115 | } |
---|
| 116 | float getAzimuth(int whichRow=0) { |
---|
| 117 | return table_->getAzimuth(whichRow); |
---|
| 118 | } |
---|
| 119 | float getParAngle(int whichRow=0) { |
---|
| 120 | return table_->getParAngle(whichRow); |
---|
| 121 | } |
---|
| 122 | |
---|
[847] | 123 | void setSpectrum(std::vector<float> spectrum, int whichrow=0) { |
---|
| 124 | table_->setSpectrum(spectrum, whichrow); |
---|
[90] | 125 | } |
---|
| 126 | |
---|
[847] | 127 | int getIF(int whichrow) {return table_->getIF(whichrow);} |
---|
| 128 | int getBeam(int whichrow) {return table_->getBeam(whichrow);} |
---|
| 129 | int getPol(int whichrow) {return table_->getPol(whichrow);} |
---|
[2] | 130 | |
---|
[847] | 131 | STSelector getSelection() { return table_->getSelection(); } |
---|
[2] | 132 | |
---|
[847] | 133 | int nif(int scanno=-1) {return table_->nif(scanno);} |
---|
| 134 | int nbeam(int scanno=-1) {return table_->nbeam(scanno);} |
---|
| 135 | int npol(int scanno=-1) {return table_->npol(scanno);} |
---|
| 136 | int nchan(int ifno=-1) {return table_->nchan(ifno);} |
---|
| 137 | int nscan() {return table_->nscan();} |
---|
| 138 | int nrow() {return table_->nrow();} |
---|
| 139 | ///@todo int nstokes() {return table_->nStokes();} |
---|
[2] | 140 | |
---|
| 141 | void makePersistent(const std::string& fname) { |
---|
| 142 | table_->makePersistent(fname); |
---|
| 143 | } |
---|
[90] | 144 | |
---|
[847] | 145 | void setRestFreqs(double rf, const std::string& unit) { |
---|
| 146 | table_->setRestFreqs(rf, unit); |
---|
[90] | 147 | } |
---|
[401] | 148 | |
---|
[847] | 149 | void setRestFreqs(const std::string& name) { |
---|
| 150 | table_->setRestFreqs(name); |
---|
| 151 | } |
---|
[745] | 152 | |
---|
[847] | 153 | std::vector<double> getRestFrequencies() { |
---|
| 154 | return table_->getRestFrequencies(); |
---|
[251] | 155 | } |
---|
| 156 | |
---|
[105] | 157 | void setCoordInfo(std::vector<string> theinfo) { |
---|
| 158 | table_->setCoordInfo(theinfo); |
---|
| 159 | } |
---|
| 160 | std::vector<string> getCoordInfo() const { |
---|
| 161 | return table_->getCoordInfo(); |
---|
| 162 | } |
---|
[90] | 163 | |
---|
[847] | 164 | casa::CountedPtr<Scantable> getCP() const {return table_;} |
---|
| 165 | Scantable* getPtr() {return &(*table_);} |
---|
[380] | 166 | |
---|
[745] | 167 | std::string summary(bool verbose=false) const { |
---|
| 168 | return table_->summary(verbose); |
---|
[380] | 169 | } |
---|
[745] | 170 | |
---|
| 171 | std::vector<std::string> getHistory() { |
---|
| 172 | return table_->getHistory(); |
---|
[207] | 173 | } |
---|
[745] | 174 | void addHistory(const std::string& hist) { |
---|
| 175 | table_->addHistory(hist); |
---|
[483] | 176 | } |
---|
[207] | 177 | |
---|
[455] | 178 | void addFit(int whichRow, const std::vector<double>& p, |
---|
[745] | 179 | const std::vector<bool>& m, const std::vector<string>& f, |
---|
| 180 | const std::vector<int>& c) { |
---|
| 181 | |
---|
[455] | 182 | casa::Vector<casa::Double> p2(p); |
---|
[745] | 183 | casa::Vector<casa::Bool> m2(m); |
---|
[465] | 184 | casa::Vector<casa::String> f2 = mathutil::toVectorString(f); |
---|
[455] | 185 | casa::Vector<casa::Int> c2(c); |
---|
| 186 | table_->addFit(casa::uInt(whichRow), p2,m2,f2,c2); |
---|
| 187 | } |
---|
[465] | 188 | SDFitTable getSDFitTable(int whichRow) { |
---|
| 189 | return table_->getSDFitTable(casa::uInt(whichRow)); |
---|
| 190 | } |
---|
[455] | 191 | |
---|
[777] | 192 | void calculateAZEL() { table_->calculateAZEL(); }; |
---|
[465] | 193 | |
---|
[2] | 194 | private: |
---|
[847] | 195 | casa::CountedPtr<Scantable> table_; |
---|
[2] | 196 | }; |
---|
| 197 | |
---|
| 198 | } // namespace |
---|
| 199 | #endif |
---|
[421] | 200 | |
---|