source: trunk/src/SDMemTableWrapper.h @ 426

Last change on this file since 426 was 426, checked in by kil064, 19 years ago

add paOffset to function SDmemTable::getSTokesSpectrum

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDMemTableWrapper.h: Wrapper classes to use CountedPtr
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
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//#---------------------------------------------------------------------------
31#ifndef SDMEMTABLEWRAPPER_H
32#define SDMEMTABLEWRAPPER_H
33
34#include <vector>
35#include <string>
36#include <casa/Arrays/Vector.h>
37
38#include "SDMemTable.h"
39
40namespace asap {
41
42class SDMemTableWrapper {
43
44public:
45  SDMemTableWrapper(const std::string& name) :
46    table_(new SDMemTable(name)) {;}
47  SDMemTableWrapper() :
48    table_(new SDMemTable()) {;}
49
50  SDMemTableWrapper(casa::CountedPtr<SDMemTable> cp) : table_(cp) {;}
51  //SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
52  SDMemTableWrapper(const SDMemTableWrapper& mt) :
53    table_(mt.getCP()) {;}
54
55  SDMemTableWrapper(const SDMemTableWrapper& mt, const std::string& expr) :
56    table_(new SDMemTable(mt.getCP()->table(), expr)) {;}
57
58  SDMemTableWrapper copy() {
59    //CountedPtr<SDMemTable> cp = new SDMemTable(*this, False);
60    return SDMemTableWrapper(new SDMemTable(*(this->getCP()), casa::False));
61  }
62
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);
70    return SDMemTableWrapper(*this, cond);
71  }
72
73  SDMemTableWrapper getSource(const std::string& source) {
74    casa::String cond("SELECT * from $1 WHERE SRCNAME == pattern('");
75    cond += source;cond += "')";
76    return SDMemTableWrapper(*this, cond);
77  }
78
79  std::vector<float> getSpectrum(int whichRow=0) const {
80    return table_->getSpectrum(whichRow);
81  }
82
83  std::vector<float> getStokesSpectrum(int whichRow=0, bool doPol=false, float paOff=0.0) const {
84    return table_->getStokesSpectrum(whichRow, doPol, paOff);
85  }
86
87  std::vector<double> getAbcissa(int whichRow=0) const {
88    return table_->getAbcissa(whichRow);
89  }
90  std::string getAbcissaString(int whichRow=0) const {
91    return table_->getAbcissaString(whichRow);
92  }
93
94  std::vector<float> getTsys() {
95     int nRow = table_->nRow();
96     std::vector<float> result(nRow);
97     for (uint i=0; i<nRow; i++) {
98        result[i] = table_->getTsys(i);
99     }
100     return result;
101  }
102
103  std::string getTime(int whichRow=0) {return table_->getTime(whichRow);}
104
105  std::string getFluxUnit() const {return table_->getFluxUnit();}
106  void setFluxUnit(const std::string& unit) {table_->setFluxUnit(unit);}
107
108  void setInstrument(const std::string& name) {table_->setInstrument(name);}
109
110  std::vector<bool> getMask(int whichRow=0) const {
111    return table_->getMask(whichRow);
112  }
113  bool setMask(const std::vector<int> mvals) const {
114    return table_->setMask(mvals);
115  }
116
117  void flag(int whichRow=-1) {
118    table_->flag(whichRow);
119  }
120  std::string getSourceName(int whichRow=0) {
121    return table_->getSourceName(whichRow);
122  }
123
124  void setSpectrum(std::vector<float> spectrum, int whichRow=0) {
125      table_->setSpectrum(spectrum, whichRow);
126  }
127
128  bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
129  bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
130  bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
131
132  int getIF() {return table_->getIF();}
133  int getBeam() {return table_->getBeam();}
134  int getPol() {return table_->getPol();}
135
136  int nIF() {return table_->nIF();}
137  int nBeam() {return table_->nBeam();}
138  int nPol() {return table_->nPol();}
139  int nChan() {return table_->nChan();}
140  int nScan() {return table_->nScan();}
141  int nRow() {return table_->nRow();}
142
143  //sets the mask
144  bool setChannels(const std::vector<int>& whichChans) {
145    return setChannels(whichChans);
146  }
147  void makePersistent(const std::string& fname) {
148    table_->makePersistent(fname);
149  }
150
151  bool setRestFreqs(const std::vector<double>& restfreqs,
152                    const std::string& unit,
153                    const std::vector<std::string>& lines,
154                    const std::string& source, int whichIF) {
155    casa::Vector<casa::Double> restFreqs2(restfreqs);
156    return table_->setRestFreqs(restFreqs2, casa::String(unit),
157                                lines, casa::String(source),
158                                casa::Int(whichIF));
159  }
160
161  void spectralLines() const {table_->spectralLines();}
162
163  std::vector<double> getRestFreqs() {
164    return table_->getRestFreqs();
165  }
166
167  void setCoordInfo(std::vector<string> theinfo) {
168    table_->setCoordInfo(theinfo);
169  }
170  std::vector<string> getCoordInfo() const {
171    return table_->getCoordInfo();
172  }
173
174  casa::CountedPtr<SDMemTable> getCP() const {return table_;}
175  SDMemTable* getPtr() {return &(*table_);}
176
177  std::string summary(bool verbose=false) const {
178    return table_->summary(verbose);
179  }
180 
181  std::vector<std::string> history(int whichRow=0) {
182    return table_->history(whichRow);
183  }
184
185  void rotateXYPhase (float value) {
186      table_->rotateXYPhase(value);
187  }
188
189private:
190  casa::CountedPtr<SDMemTable> table_;
191};
192
193} // namespace
194#endif
195
Note: See TracBrowser for help on using the repository browser.