[2] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# SDMemTableWrapper.h: Wrapper classes to use CountedPtr
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2004
|
---|
[125] | 5 | //# ATNF
|
---|
[2] | 6 | //#
|
---|
| 7 | //# This program is free software; you can redistribute it and/or modify it
|
---|
| 8 | //# under the terms of the GNU General Public License as published by the Free
|
---|
| 9 | //# Software Foundation; either version 2 of the License, or (at your option)
|
---|
| 10 | //# any later version.
|
---|
| 11 | //#
|
---|
| 12 | //# This program is distributed in the hope that it will be useful, but
|
---|
| 13 | //# WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
---|
| 15 | //# Public License for more details.
|
---|
| 16 | //#
|
---|
| 17 | //# You should have received a copy of the GNU General Public License along
|
---|
| 18 | //# with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
| 19 | //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
|
---|
| 20 | //#
|
---|
| 21 | //# Correspondence concerning this software should be addressed as follows:
|
---|
| 22 | //# Internet email: Malte.Marquarding@csiro.au
|
---|
| 23 | //# Postal address: Malte Marquarding,
|
---|
| 24 | //# Australia Telescope National Facility,
|
---|
| 25 | //# P.O. Box 76,
|
---|
| 26 | //# Epping, NSW, 2121,
|
---|
| 27 | //# AUSTRALIA
|
---|
| 28 | //#
|
---|
| 29 | //# $Id:
|
---|
| 30 | //#---------------------------------------------------------------------------
|
---|
[125] | 31 | #ifndef SDMEMTABLEWRAPPER_H
|
---|
| 32 | #define SDMEMTABLEWRAPPER_H
|
---|
[2] | 33 |
|
---|
| 34 | #include <vector>
|
---|
| 35 | #include <string>
|
---|
[380] | 36 | #include <casa/Arrays/Vector.h>
|
---|
[2] | 37 |
|
---|
| 38 | #include "SDMemTable.h"
|
---|
| 39 |
|
---|
[83] | 40 | namespace asap {
|
---|
[2] | 41 |
|
---|
| 42 | class SDMemTableWrapper {
|
---|
| 43 |
|
---|
| 44 | public:
|
---|
[90] | 45 | SDMemTableWrapper(const std::string& name) :
|
---|
[2] | 46 | table_(new SDMemTable(name)) {;}
|
---|
[90] | 47 | SDMemTableWrapper() :
|
---|
[18] | 48 | table_(new SDMemTable()) {;}
|
---|
[90] | 49 |
|
---|
[125] | 50 | SDMemTableWrapper(casa::CountedPtr<SDMemTable> cp) : table_(cp) {;}
|
---|
[90] | 51 | //SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
|
---|
| 52 | SDMemTableWrapper(const SDMemTableWrapper& mt) :
|
---|
| 53 | table_(mt.getCP()) {;}
|
---|
| 54 |
|
---|
[80] | 55 | SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) :
|
---|
| 56 | table_(new SDMemTable(mt.getCP()->table(), expr)) {;}
|
---|
[90] | 57 |
|
---|
| 58 | SDMemTableWrapper copy() {
|
---|
| 59 | //CountedPtr<SDMemTable> cp = new SDMemTable(*this, False);
|
---|
[125] | 60 | return SDMemTableWrapper(new SDMemTable(*(this->getCP()), casa::False));
|
---|
[90] | 61 | }
|
---|
| 62 |
|
---|
[380] | 63 | //SDMemTableWrapper getScan(int scan) {
|
---|
| 64 | SDMemTableWrapper getScan(std::vector<int> scan) {
|
---|
| 65 | casa::String cond("SELECT FROM $1 WHERE SCANID IN ");
|
---|
| 66 | casa::Vector<casa::Int> v(scan);
|
---|
| 67 | casa::ostringstream oss;
|
---|
| 68 | oss << v;
|
---|
| 69 | cond += casa::String(oss);
|
---|
[80] | 70 | return SDMemTableWrapper(*this, cond);
|
---|
[2] | 71 | }
|
---|
[80] | 72 |
|
---|
| 73 | SDMemTableWrapper getSource(const std::string& source) {
|
---|
[186] | 74 | casa::String cond("SELECT * from $1 WHERE SRCNAME == pattern('");
|
---|
| 75 | cond += source;cond += "')";
|
---|
[80] | 76 | return SDMemTableWrapper(*this, cond);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[51] | 79 | std::vector<float> getSpectrum(int whichRow=0) const {
|
---|
[2] | 80 | return table_->getSpectrum(whichRow);
|
---|
| 81 | }
|
---|
[41] | 82 |
|
---|
[426] | 83 | std::vector<float> getStokesSpectrum(int whichRow=0, bool doPol=false, float paOff=0.0) const {
|
---|
| 84 | return table_->getStokesSpectrum(whichRow, doPol, paOff);
|
---|
[421] | 85 | }
|
---|
| 86 |
|
---|
[431] | 87 | std::vector<float> getCircularSpectrum(int whichRow=0, bool doRR=true) const {
|
---|
| 88 | return table_->getCircularSpectrum(whichRow, doRR);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[158] | 91 | std::vector<double> getAbcissa(int whichRow=0) const {
|
---|
| 92 | return table_->getAbcissa(whichRow);
|
---|
[41] | 93 | }
|
---|
[158] | 94 | std::string getAbcissaString(int whichRow=0) const {
|
---|
| 95 | return table_->getAbcissaString(whichRow);
|
---|
[105] | 96 | }
|
---|
[41] | 97 |
|
---|
[157] | 98 | std::vector<float> getTsys() {
|
---|
| 99 | int nRow = table_->nRow();
|
---|
| 100 | std::vector<float> result(nRow);
|
---|
| 101 | for (uint i=0; i<nRow; i++) {
|
---|
| 102 | result[i] = table_->getTsys(i);
|
---|
| 103 | }
|
---|
| 104 | return result;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[51] | 107 | std::string getTime(int whichRow=0) {return table_->getTime(whichRow);}
|
---|
[2] | 108 |
|
---|
[207] | 109 | std::string getFluxUnit() const {return table_->getFluxUnit();}
|
---|
[220] | 110 | void setFluxUnit(const std::string& unit) {table_->setFluxUnit(unit);}
|
---|
[207] | 111 |
|
---|
[238] | 112 | void setInstrument(const std::string& name) {table_->setInstrument(name);}
|
---|
| 113 |
|
---|
[90] | 114 | std::vector<bool> getMask(int whichRow=0) const {
|
---|
| 115 | return table_->getMask(whichRow);
|
---|
[16] | 116 | }
|
---|
[90] | 117 | bool setMask(const std::vector<int> mvals) const {
|
---|
| 118 | return table_->setMask(mvals);
|
---|
| 119 | }
|
---|
[2] | 120 |
|
---|
[90] | 121 | void flag(int whichRow=-1) {
|
---|
| 122 | table_->flag(whichRow);
|
---|
| 123 | }
|
---|
[51] | 124 | std::string getSourceName(int whichRow=0) {
|
---|
[2] | 125 | return table_->getSourceName(whichRow);
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[90] | 128 | void setSpectrum(std::vector<float> spectrum, int whichRow=0) {
|
---|
| 129 | table_->setSpectrum(spectrum, whichRow);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[2] | 132 | bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
|
---|
| 133 | bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
|
---|
[90] | 134 | bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
|
---|
[2] | 135 |
|
---|
| 136 | int getIF() {return table_->getIF();}
|
---|
| 137 | int getBeam() {return table_->getBeam();}
|
---|
[90] | 138 | int getPol() {return table_->getPol();}
|
---|
[2] | 139 |
|
---|
[18] | 140 | int nIF() {return table_->nIF();}
|
---|
| 141 | int nBeam() {return table_->nBeam();}
|
---|
[90] | 142 | int nPol() {return table_->nPol();}
|
---|
| 143 | int nChan() {return table_->nChan();}
|
---|
| 144 | int nScan() {return table_->nScan();}
|
---|
| 145 | int nRow() {return table_->nRow();}
|
---|
[2] | 146 |
|
---|
| 147 | //sets the mask
|
---|
| 148 | bool setChannels(const std::vector<int>& whichChans) {
|
---|
[90] | 149 | return setChannels(whichChans);
|
---|
[2] | 150 | }
|
---|
| 151 | void makePersistent(const std::string& fname) {
|
---|
| 152 | table_->makePersistent(fname);
|
---|
| 153 | }
|
---|
[90] | 154 |
|
---|
[401] | 155 | bool setRestFreqs(const std::vector<double>& restfreqs,
|
---|
| 156 | const std::string& unit,
|
---|
| 157 | const std::vector<std::string>& lines,
|
---|
| 158 | const std::string& source, int whichIF) {
|
---|
[392] | 159 | casa::Vector<casa::Double> restFreqs2(restfreqs);
|
---|
| 160 | return table_->setRestFreqs(restFreqs2, casa::String(unit),
|
---|
[401] | 161 | lines, casa::String(source),
|
---|
[392] | 162 | casa::Int(whichIF));
|
---|
[90] | 163 | }
|
---|
[251] | 164 |
|
---|
[401] | 165 | void spectralLines() const {table_->spectralLines();}
|
---|
| 166 |
|
---|
[251] | 167 | std::vector<double> getRestFreqs() {
|
---|
| 168 | return table_->getRestFreqs();
|
---|
| 169 | }
|
---|
| 170 |
|
---|
[105] | 171 | void setCoordInfo(std::vector<string> theinfo) {
|
---|
| 172 | table_->setCoordInfo(theinfo);
|
---|
| 173 | }
|
---|
| 174 | std::vector<string> getCoordInfo() const {
|
---|
| 175 | return table_->getCoordInfo();
|
---|
| 176 | }
|
---|
[90] | 177 |
|
---|
[125] | 178 | casa::CountedPtr<SDMemTable> getCP() const {return table_;}
|
---|
[138] | 179 | SDMemTable* getPtr() {return &(*table_);}
|
---|
[380] | 180 |
|
---|
| 181 | std::string summary(bool verbose=false) const {
|
---|
| 182 | return table_->summary(verbose);
|
---|
| 183 | }
|
---|
[186] | 184 |
|
---|
[207] | 185 | std::vector<std::string> history(int whichRow=0) {
|
---|
| 186 | return table_->history(whichRow);
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[433] | 189 | void rotateXYPhase (float value, bool doAll) {
|
---|
| 190 | table_->rotateXYPhase(value, doAll);
|
---|
[421] | 191 | }
|
---|
| 192 |
|
---|
[2] | 193 | private:
|
---|
[125] | 194 | casa::CountedPtr<SDMemTable> table_;
|
---|
[2] | 195 | };
|
---|
| 196 |
|
---|
| 197 | } // namespace
|
---|
| 198 | #endif
|
---|
[421] | 199 |
|
---|