source: trunk/src/ScantableWrapper.h@ 2787

Last change on this file since 2787 was 2767, checked in by WataruKawasaki, 12 years ago

New Development: Yes

JIRA Issue: Yes CAS-4794

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: functions to apply/write STBaselineTable in which baseline parameters stored.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.4 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 <iostream>
16#include <string>
17#include <vector>
18
19#include <casa/Arrays/Vector.h>
20
21#include "MathUtils.h"
22#include "Scantable.h"
23#include "STCoordinate.h"
24#include "STFit.h"
25#include "STFitEntry.h"
26
27namespace asap {
28/**
29 * This class contains and wraps a CountedPtr<Scantable>, as the CountedPtr
30 * class does not provide the dor operator which is need for references
31 * in boost::python
32 * see Scantable for interfce description
33 *
34 * @brief The main ASAP data container wrapper
35 * @author Malte Marquarding
36 * @date 2006-02-23
37 * @version 2.0a
38*/
39class ScantableWrapper {
40
41public:
42 explicit ScantableWrapper( const std::string& name,
43 int type=0)
44 {
45 casa::Table::TableType tp = casa::Table::Memory;
46 if ( type == 1 ) tp = casa::Table::Plain;
47 table_ = new Scantable(name, tp);
48 }
49
50 explicit ScantableWrapper(int type=0)
51 {
52 casa::Table::TableType tp = casa::Table::Memory;
53 if ( type == 1) tp = casa::Table::Plain;
54 table_= new Scantable(tp);
55 }
56
57 explicit ScantableWrapper(casa::CountedPtr<Scantable> cp) : table_(cp) {;}
58
59 ScantableWrapper(const ScantableWrapper& mt) :
60 table_(mt.getCP()) {;}
61
62 ~ScantableWrapper()
63 {
64 }
65
66 void assign(const ScantableWrapper& mt)
67 { table_= mt.getCP(); }
68
69 ScantableWrapper copy() {
70 return ScantableWrapper(new Scantable(*(this->getCP()), false));
71 }
72
73 std::vector<float> getSpectrum( int whichrow=0,
74 const std::string& poltype="" ) const {
75 return table_->getSpectrum(whichrow, poltype);
76 }
77 // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const {
78 // Boost fails with 4 arguments.
79 std::string getPolarizationLabel(int index, const std::string& ptype) const {
80 return table_->getPolarizationLabel(index, ptype);
81 }
82
83 std::vector<double> getAbcissa(int whichrow=0) const
84 { return table_->getAbcissa(whichrow); }
85
86 std::string getAbcissaLabel(int whichrow=0) const
87 { return table_->getAbcissaLabel(whichrow); }
88
89 float getTsys(int whichrow=0) const
90 { return table_->getTsys(whichrow); }
91
92 std::vector<float> getTsysSpectrum(int whichrow=0) const
93 { return table_->getTsysSpectrum(whichrow); }
94
95 //std::string getTime(int whichrow=0) const
96 // { return table_->getTime(whichrow); }
97 std::string getTime(int whichrow=0, int prec = 0) const
98 { return table_->getTime(whichrow, true, casa::uInt(prec)); }
99
100 double getIntTime(int whichrow=0) const
101 { return table_->getIntTime(whichrow); }
102
103 std::string getDirectionString(int whichrow=0) const
104 { return table_->getDirectionString(whichrow); }
105
106 std::string getFluxUnit() const { return table_->getFluxUnit(); }
107
108 void setFluxUnit(const std::string& unit) { table_->setFluxUnit(unit); }
109
110 void setInstrument(const std::string& name) {table_->setInstrument(name);}
111 void setFeedType(const std::string& ftype) {table_->setFeedType(ftype);}
112
113 std::vector<bool> getMask(int whichrow=0) const
114 { return table_->getMask(whichrow); }
115
116 /**
117 void flag(const std::vector<bool>& msk=std::vector<bool>())
118 { table_->flag(msk); }
119 **/
120 /**
121 void flag(const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
122 { table_->flag(msk, unflag); }
123 **/
124 void flag(int whichrow=-1, const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
125 { table_->flag(whichrow, msk, unflag); }
126
127 void flagRow(const std::vector<casa::uInt>& rows=std::vector<casa::uInt>(), bool unflag=false)
128 { table_->flagRow(rows, unflag); }
129
130 bool getFlagRow(int whichrow=0) const
131 { return table_->getFlagRow(whichrow); }
132
133 void clip(const casa::Float uthres, const casa::Float dthres, bool clipoutside=true, bool unflag=false)
134 { table_->clip(uthres, dthres, clipoutside, unflag); }
135
136 std::vector<bool> getClipMask(int whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag) const
137 { return table_->getClipMask(whichrow, uthres, dthres, clipoutside, unflag); }
138
139 std::string getSourceName(int whichrow=0) const
140 { return table_->getSourceName(whichrow); }
141
142 float getElevation(int whichrow=0) const
143 { return table_->getElevation(whichrow); }
144
145 float getAzimuth(int whichrow=0) const
146 { return table_->getAzimuth(whichrow); }
147
148 float getParAngle(int whichrow=0) const
149 { return table_->getParAngle(whichrow); }
150
151
152 void setSpectrum(std::vector<float> spectrum, int whichrow=0)
153 { table_->setSpectrum(spectrum, whichrow); }
154
155 std::vector<uint> getIFNos() { return table_->getIFNos(); }
156 int getIF(int whichrow) const {return table_->getIF(whichrow);}
157 std::vector<uint> getBeamNos() { return table_->getBeamNos(); }
158 int getBeam(int whichrow) const {return table_->getBeam(whichrow);}
159 std::vector<uint> getPolNos() { return table_->getPolNos(); }
160 int getPol(int whichrow) const {return table_->getPol(whichrow);}
161 std::vector<uint> getCycleNos() { return table_->getCycleNos(); }
162 int getCycle(int whichrow) const {return table_->getCycle(whichrow);}
163 std::vector<uint> getScanNos() { return table_->getScanNos(); }
164 int getScan(int whichrow) const {return table_->getScan(whichrow);}
165 std::vector<uint> getMolNos() { return table_->getMolNos();}
166
167 STSelector getSelection() const { return table_->getSelection(); }
168 void setSelection(const STSelector& sts)
169 { return table_->setSelection(sts);}
170
171 std::string getPolType() const { return table_->getPolType(); }
172
173 int nif(int scanno=-1) const {return table_->nif(scanno);}
174 int nbeam(int scanno=-1) const {return table_->nbeam(scanno);}
175 int npol(int scanno=-1) const {return table_->npol(scanno);}
176 int nchan(int ifno=-1) const {return table_->nchan(ifno);}
177 int nscan() const {return table_->nscan();}
178 int nrow() const {return table_->nrow();}
179 int ncycle(int scanno) const {return table_->ncycle(scanno);}
180
181 void makePersistent(const std::string& fname)
182 { table_->makePersistent(fname); }
183
184 void setSourceType(int stype)
185 { table_->setSourceType(stype); }
186
187 void shift(int npix)
188 { table_->shift(npix); }
189
190/**
191 commented out by TT
192 void setRestFrequencies(double rf, const std::string& name,
193 const std::string& unit)
194 { table_->setRestFrequencies(rf, name, unit); }
195**/
196 void setRestFrequencies(vector<double> rf, const vector<std::string>& name,
197 const std::string& unit)
198 { table_->setRestFrequencies(rf, name, unit); }
199
200/*
201 void setRestFrequencies(const std::string& name) {
202 table_->setRestFrequencies(name);
203 }
204*/
205
206/*
207 std::vector<double> getRestFrequencies() const
208 { return table_->getRestFrequencies(); }
209*/
210 std::vector<double> getRestFrequency(int id) const
211 { return table_->getRestFrequency(id); }
212
213 void setCoordInfo(std::vector<string> theinfo) {
214 table_->setCoordInfo(theinfo);
215 }
216 std::vector<string> getCoordInfo() const {
217 return table_->getCoordInfo();
218 }
219
220 void setDirection(const std::string& refstr="")
221 { table_->setDirectionRefString(refstr); }
222
223 casa::CountedPtr<Scantable> getCP() const {return table_;}
224 Scantable* getPtr() {return &(*table_);}
225
226 // std::string summary() const {
227 // return table_->summary();
228 // }
229 void summary(const std::string& filename="") {
230 //std::string summary(const std::string& filename="") const {
231 table_->summary(filename);
232 }
233
234 std::string listHeader() const {
235 return table_->headerSummary();
236 }
237
238 std::vector<std::string> getHistory() const
239 { return table_->getHistory(); }
240
241 void addHistory(const std::string& hist)
242 { table_->addHistory(hist); }
243
244 void addFit(const STFitEntry& fit, int row)
245 { table_->addFit(fit, row); }
246
247 STFitEntry getFit(int whichrow) const
248 { return table_->getFit(whichrow); }
249
250 void calculateAZEL() { table_->calculateAZEL(); }
251
252 std::vector<std::string> columnNames() const
253 { return table_->columnNames(); }
254
255 std::string getAntennaName() const
256 { return table_->getAntennaName(); }
257
258 int checkScanInfo(const vector<int>& scanlist) const
259 { return table_->checkScanInfo(scanlist); }
260
261 std::vector<double> getDirectionVector(int whichrow) const
262 { return table_->getDirectionVector(whichrow); }
263
264 void parallactify(bool flag)
265 { table_->parallactify(flag); }
266
267 STCoordinate getCoordinate(int row) {
268 return STCoordinate(table_->getSpectralCoordinate(row));
269 }
270
271 std::vector<float> getWeather(int whichrow) const
272 { return table_->getWeather(whichrow); }
273
274 void reshapeSpectrum( int nmin, int nmax )
275 { table_->reshapeSpectrum( nmin, nmax ); }
276
277 void regridSpecChannel( double dnu, int nchan )
278 { table_->regridSpecChannel( dnu, nchan ); }
279
280 std::vector<std::string> applyBaselineTable(const std::string& bltable, const std::string& outbltable, const bool outbltableexists, const bool overwrite)
281 { return table_->applyBaselineTable(bltable, outbltable, outbltableexists, overwrite); }
282 std::vector<std::string> subBaseline(const std::vector<std::string>& blinfo, const std::string& outbltable, const bool outbltableexists, const bool overwrite)
283 { return table_->subBaseline(blinfo, outbltable, outbltableexists, overwrite); }
284 void polyBaseline(const std::vector<bool>& mask, int order, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
285 { table_->polyBaseline(mask, order, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
286
287 void autoPolyBaseline(const std::vector<bool>& mask, int order, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
288 { table_->autoPolyBaseline(mask, order, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
289
290 void chebyshevBaseline(const std::vector<bool>& mask, int order, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
291 { table_->chebyshevBaseline(mask, order, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
292
293 void autoChebyshevBaseline(const std::vector<bool>& mask, int order, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
294 { table_->autoChebyshevBaseline(mask, order, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
295
296 void cubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
297 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
298
299 void autoCubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
300 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
301
302 void sinusoidBaseline(const std::vector<bool>& mask, const std::string& fftinfo, const std::vector<int>& addwn, const std::vector<int>& rejwn, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
303 { table_->sinusoidBaseline(mask, fftinfo, addwn, rejwn, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
304
305 void autoSinusoidBaseline(const std::vector<bool>& mask, const std::string& fftinfo, const std::vector<int>& addwn, const std::vector<int>& rejwn, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="", const std::string& bltable="")
306 { table_->autoSinusoidBaseline(mask, fftinfo, addwn, rejwn, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
307
308 float getRms(const std::vector<bool>& mask, int whichrow)
309 { return table_->getRms(mask, whichrow); }
310
311 std::string formatBaselineParams(const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false, bool csvformat=false)
312 { return table_->formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
313
314 std::string formatPiecewiseBaselineParams(const std::vector<int>& ranges, const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false, bool csvformat=false)
315 { return table_->formatPiecewiseBaselineParams(ranges, params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
316
317 bool getFlagtraFast(int whichrow=0) const
318 { return table_->getFlagtraFast(casa::uInt(whichrow)); }
319
320 std::vector<float> execFFT(int whichrow, const std::vector<bool>& mask, bool getRealImag=false, bool getAmplitudeOnly=false)
321 { return table_->execFFT(whichrow, mask, getRealImag, getAmplitudeOnly); }
322
323 std::vector<uint> getMoleculeIdColumnData() const
324 { return table_->getMoleculeIdColumnData(); }
325 void setMoleculeIdColumnData(const std::vector<uint>& molids)
326 { table_->setMoleculeIdColumnData(molids); }
327 double calculateModelSelectionCriteria(const std::string& valname, const std::string& blfunc, int order, const std::vector<bool>& inMask, int whichrow, bool useLineFinder, const std::vector<int>& edge, float threshold, int chanAvgLimit)
328 { return table_->calculateModelSelectionCriteria(valname, blfunc, order, inMask, whichrow, useLineFinder, edge, threshold, chanAvgLimit); }
329
330private:
331 casa::CountedPtr<Scantable> table_;
332};
333
334} // namespace
335#endif
Note: See TracBrowser for help on using the repository browser.