source: trunk/src/ScantableWrapper.h@ 893

Last change on this file since 893 was 884, checked in by mar637, 19 years ago

added setSpectrum

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
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
14
15#include <vector>
16#include <string>
17#include <casa/Arrays/Vector.h>
18
19#include "MathUtils.h"
20#include "SDFitTable.h"
21#include "Scantable.h"
22
23namespace asap {
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*/
35class ScantableWrapper {
36
37public:
38 ScantableWrapper( const std::string& name,
39 const std::string& type="")
40 {
41 casa::Table::TableType tp = casa::Table::Memory;
42 if ( type == "disk") tp = casa::Table::Plain;
43 table_ = new Scantable(name, tp);
44 }
45
46 ScantableWrapper(const std::string& type="")
47 {
48 casa::Table::TableType tp = casa::Table::Memory;
49 if ( type == "disk") tp = casa::Table::Plain;
50 table_= new Scantable(tp);
51 }
52
53 ScantableWrapper(casa::CountedPtr<Scantable> cp) : table_(cp) {;}
54
55 ScantableWrapper(const ScantableWrapper& mt) :
56 table_(mt.getCP()) {;}
57
58 void assign(const ScantableWrapper& mt)
59 { table_= mt.getCP(); }
60
61 ScantableWrapper copy() {
62 return ScantableWrapper(new Scantable(*(this->getCP()), false));
63 }
64
65 std::vector<float> getSpectrum(int whichRow=0) const {
66 return table_->getSpectrum(whichRow);
67 }
68 /*
69 std::vector<float> getStokesSpectrum(int whichRow=0,
70 bool linPol=false) const {
71 return table_->getStokesSpectrum(whichRow, linPol);
72 }
73
74 std::vector<float> stokesToPolSpectrum(int whichRow=0, bool linear=false,
75 int polIdx=-1) const {
76 return table_->stokesToPolSpectrum(whichRow, linear, polIdx);
77 }
78 */
79 // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const {
80 // Boost fails with 4 arguments.
81 std::string getPolarizationLabel(bool linear, bool stokes,
82 bool linPol) const {
83 int polIdx = -1;
84 return table_->getPolarizationLabel(linear, stokes, linPol, polIdx);
85 }
86
87 std::vector<double> getAbcissa(int whichRow=0) const
88 { return table_->getAbcissa(whichRow); }
89
90 std::string getAbcissaLabel(int whichRow=0) const
91 { return table_->getAbcissaLabel(whichRow); }
92
93 float getTsys(int whichRow=0) const
94 { return table_->getTsys(whichRow); }
95
96 std::string getTime(int whichRow=0) const
97 { return table_->getTime(whichRow); }
98
99 std::string getFluxUnit() const { return table_->getFluxUnit(); }
100
101 void setFluxUnit(const std::string& unit) { table_->setFluxUnit(unit); }
102
103 void setInstrument(const std::string& name) {table_->setInstrument(name);}
104
105 std::vector<bool> getMask(int whichRow=0) const
106 { return table_->getMask(whichRow); }
107
108 void flag() { table_->flag(); }
109
110 std::string getSourceName(int whichRow=0) const
111 { return table_->getSourceName(whichRow); }
112
113 float getElevation(int whichRow=0) const
114 { return table_->getElevation(whichRow); }
115
116 float getAzimuth(int whichRow=0) const
117 { return table_->getAzimuth(whichRow); }
118
119 float getParAngle(int whichRow=0) const
120 { return table_->getParAngle(whichRow); }
121
122
123 void setSpectrum(std::vector<float> spectrum, int whichrow=0)
124 { table_->setSpectrum(spectrum, whichrow); }
125
126 int getIF(int whichrow) const {return table_->getIF(whichrow);}
127 int getBeam(int whichrow) const {return table_->getBeam(whichrow);}
128 int getPol(int whichrow) const {return table_->getPol(whichrow);}
129 int getCycle(int whichrow) const {return table_->getCycle(whichrow);}
130 int getScan(int whichrow) const {return table_->getScan(whichrow);}
131
132 STSelector getSelection() const { return table_->getSelection(); }
133 void setSelection(const STSelector& sts)
134 { return table_->setSelection(sts);}
135
136 int nif(int scanno=-1) const {return table_->nif(scanno);}
137 int nbeam(int scanno=-1) const {return table_->nbeam(scanno);}
138 int npol(int scanno=-1) const {return table_->npol(scanno);}
139 int nchan(int ifno=-1) const {return table_->nchan(ifno);}
140 int nscan() const {return table_->nscan();}
141 int nrow() const {return table_->nrow();}
142 ///@todo int nstokes() {return table_->nStokes();}
143
144 void makePersistent(const std::string& fname)
145 { table_->makePersistent(fname); }
146
147 void setRestFrequencies(double rf, const std::string& unit)
148 { table_->setRestFrequencies(rf, unit); }
149
150 void setRestFrequencies(const std::string& name) {
151 table_->setRestFrequencies(name);
152 }
153
154 std::vector<double> getRestFrequencies() const
155 { return table_->getRestFrequencies(); }
156
157 void setCoordInfo(std::vector<string> theinfo) {
158 table_->setCoordInfo(theinfo);
159 }
160 std::vector<string> getCoordInfo() const {
161 return table_->getCoordInfo();
162 }
163
164 casa::CountedPtr<Scantable> getCP() const {return table_;}
165 Scantable* getPtr() {return &(*table_);}
166
167 std::string summary(bool verbose=false) const {
168 return table_->summary(verbose);
169 }
170
171 std::vector<std::string> getHistory()const
172 { return table_->getHistory(); }
173
174 void addHistory(const std::string& hist)
175 { table_->addHistory(hist); }
176 /*
177 void addFit(int whichRow, const std::vector<double>& p,
178 const std::vector<bool>& m, const std::vector<string>& f,
179 const std::vector<int>& c) {
180
181 casa::Vector<casa::Double> p2(p);
182 casa::Vector<casa::Bool> m2(m);
183 casa::Vector<casa::String> f2 = mathutil::toVectorString(f);
184 casa::Vector<casa::Int> c2(c);
185 table_->addFit(casa::uInt(whichRow), p2,m2,f2,c2);
186 }
187 SDFitTable getSDFitTable(int whichRow) {
188 return table_->getSDFitTable(casa::uInt(whichRow));
189 }
190 */
191 void calculateAZEL() { table_->calculateAZEL(); };
192
193private:
194 casa::CountedPtr<Scantable> table_;
195};
196
197} // namespace
198#endif
199
Note: See TracBrowser for help on using the repository browser.