source: branches/casa-release-4_3/src/ScantableWrapper.h@ 3037

Last change on this file since 3037 was 2888, checked in by Kana Sugimoto, 11 years ago

New Development: Yes

JIRA Issue: Yes (CAS-5860)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Added scantable a method, asap.scantable.._get_root_row_idx(), and underlying c++ functions, ScantableWrapper:::getRootTableRowNumbers() and Scantable:::getRootTableRowNumbers()

Test Programs: TBD

Put in Release Notes: No

Module(s): asap.scantable and CASA task, tsdstat

Description:

Added a scantable method, asap.scantable._get_root_row_idx().
The method returns row indices (uint std::vecotr) in the root table for selected rows of scantable.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 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 void setTsys(const std::vector<float>& newvals, int whichrow=-1)
96 { return table_->setTsys(newvals, whichrow); }
97
98 //std::string getTime(int whichrow=0) const
99 // { return table_->getTime(whichrow); }
100 std::string getTime(int whichrow=0, int prec = 0) const
101 { return table_->getTime(whichrow, true, casa::uInt(prec)); }
102
103 double getIntTime(int whichrow=0) const
104 { return table_->getIntTime(whichrow); }
105
106 std::string getDirectionString(int whichrow=0) const
107 { return table_->getDirectionString(whichrow); }
108
109 std::string getFluxUnit() const { return table_->getFluxUnit(); }
110
111 void setFluxUnit(const std::string& unit) { table_->setFluxUnit(unit); }
112
113 void setInstrument(const std::string& name) {table_->setInstrument(name);}
114 void setFeedType(const std::string& ftype) {table_->setFeedType(ftype);}
115
116 std::vector<bool> getMask(int whichrow=0) const
117 { return table_->getMask(whichrow); }
118
119 /**
120 void flag(const std::vector<bool>& msk=std::vector<bool>())
121 { table_->flag(msk); }
122 **/
123 /**
124 void flag(const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
125 { table_->flag(msk, unflag); }
126 **/
127 void flag(int whichrow=-1, const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
128 { table_->flag(whichrow, msk, unflag); }
129
130 void flagRow(const std::vector<casa::uInt>& rows=std::vector<casa::uInt>(), bool unflag=false)
131 { table_->flagRow(rows, unflag); }
132
133 bool getFlagRow(int whichrow=0) const
134 { return table_->getFlagRow(whichrow); }
135
136 void clip(const casa::Float uthres, const casa::Float dthres, bool clipoutside=true, bool unflag=false)
137 { table_->clip(uthres, dthres, clipoutside, unflag); }
138
139 std::vector<bool> getClipMask(int whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag) const
140 { return table_->getClipMask(whichrow, uthres, dthres, clipoutside, unflag); }
141
142 std::string getSourceName(int whichrow=0) const
143 { return table_->getSourceName(whichrow); }
144
145 float getElevation(int whichrow=0) const
146 { return table_->getElevation(whichrow); }
147
148 float getAzimuth(int whichrow=0) const
149 { return table_->getAzimuth(whichrow); }
150
151 float getParAngle(int whichrow=0) const
152 { return table_->getParAngle(whichrow); }
153
154
155 void setSpectrum(std::vector<float> spectrum, int whichrow=0)
156 { table_->setSpectrum(spectrum, whichrow); }
157
158 std::vector<uint> getIFNos() { return table_->getIFNos(); }
159 int getIF(int whichrow) const {return table_->getIF(whichrow);}
160 std::vector<uint> getBeamNos() { return table_->getBeamNos(); }
161 int getBeam(int whichrow) const {return table_->getBeam(whichrow);}
162 std::vector<uint> getPolNos() { return table_->getPolNos(); }
163 int getPol(int whichrow) const {return table_->getPol(whichrow);}
164 std::vector<uint> getCycleNos() { return table_->getCycleNos(); }
165 int getCycle(int whichrow) const {return table_->getCycle(whichrow);}
166 std::vector<uint> getScanNos() { return table_->getScanNos(); }
167 int getScan(int whichrow) const {return table_->getScan(whichrow);}
168 std::vector<uint> getMolNos() { return table_->getMolNos();}
169
170 STSelector getSelection() const { return table_->getSelection(); }
171 void setSelection(const STSelector& sts)
172 { return table_->setSelection(sts);}
173
174 std::string getPolType() const { return table_->getPolType(); }
175
176 int nif(int scanno=-1) const {return table_->nif(scanno);}
177 int nbeam(int scanno=-1) const {return table_->nbeam(scanno);}
178 int npol(int scanno=-1) const {return table_->npol(scanno);}
179 int nchan(int ifno=-1) const {return table_->nchan(ifno);}
180 int nscan() const {return table_->nscan();}
181 int nrow() const {return table_->nrow();}
182 int ncycle(int scanno) const {return table_->ncycle(scanno);}
183
184 void makePersistent(const std::string& fname)
185 { table_->makePersistent(fname); }
186
187 void setSourceType(int stype)
188 { table_->setSourceType(stype); }
189
190 void setSourceName(const std::string& name)
191 { table_->setSourceName(name); }
192
193 void shift(int npix)
194 { table_->shift(npix); }
195
196/**
197 commented out by TT
198 void setRestFrequencies(double rf, const std::string& name,
199 const std::string& unit)
200 { table_->setRestFrequencies(rf, name, unit); }
201**/
202 void setRestFrequencies(vector<double> rf, const vector<std::string>& name,
203 const std::string& unit)
204 { table_->setRestFrequencies(rf, name, unit); }
205
206/*
207 void setRestFrequencies(const std::string& name) {
208 table_->setRestFrequencies(name);
209 }
210*/
211
212/*
213 std::vector<double> getRestFrequencies() const
214 { return table_->getRestFrequencies(); }
215*/
216 std::vector<double> getRestFrequency(int id) const
217 { return table_->getRestFrequency(id); }
218
219 void setCoordInfo(std::vector<string> theinfo) {
220 table_->setCoordInfo(theinfo);
221 }
222 std::vector<string> getCoordInfo() const {
223 return table_->getCoordInfo();
224 }
225
226 void setDirection(const std::string& refstr="")
227 { table_->setDirectionRefString(refstr); }
228
229 casa::CountedPtr<Scantable> getCP() const {return table_;}
230 Scantable* getPtr() {return &(*table_);}
231
232 // std::string summary() const {
233 // return table_->summary();
234 // }
235 void summary(const std::string& filename="") {
236 //std::string summary(const std::string& filename="") const {
237 table_->summary(filename);
238 }
239
240 std::string listHeader() const {
241 return table_->headerSummary();
242 }
243
244 std::vector<std::string> getHistory(int nrow=-1, int start=0) const
245 { return table_->getHistory(nrow, start); }
246
247 uint historyLength() {
248 return table_->historyLength();
249 }
250
251 void dropHistory() { table_->dropHistory(); }
252
253 void addHistory(const std::string& hist)
254 { table_->addHistory(hist); }
255
256 void addFit(const STFitEntry& fit, int row)
257 { table_->addFit(fit, row); }
258
259 STFitEntry getFit(int whichrow) const
260 { return table_->getFit(whichrow); }
261
262 void calculateAZEL() { table_->calculateAZEL(); }
263
264 std::vector<std::string> columnNames() const
265 { return table_->columnNames(); }
266
267 std::string getAntennaName() const
268 { return table_->getAntennaName(); }
269
270 int checkScanInfo(const vector<int>& scanlist) const
271 { return table_->checkScanInfo(scanlist); }
272
273 std::vector<double> getDirectionVector(int whichrow) const
274 { return table_->getDirectionVector(whichrow); }
275
276 void parallactify(bool flag)
277 { table_->parallactify(flag); }
278
279 STCoordinate getCoordinate(int row) {
280 return STCoordinate(table_->getSpectralCoordinate(row));
281 }
282
283 std::vector<float> getWeather(int whichrow) const
284 { return table_->getWeather(whichrow); }
285
286 void reshapeSpectrum( int nmin, int nmax )
287 { table_->reshapeSpectrum( nmin, nmax ); }
288
289 void regridSpecChannel( double dnu, int nchan )
290 { table_->regridSpecChannel( dnu, nchan ); }
291
292 std::vector<std::string> applyBaselineTable(const std::string& bltable, const bool returnfitresult, const std::string& outbltable, const bool outbltableexists, const bool overwrite)
293 { return table_->applyBaselineTable(bltable, returnfitresult, outbltable, outbltableexists, overwrite); }
294 std::vector<std::string> subBaseline(const std::vector<std::string>& blinfo, const bool returnfitresult, const std::string& outbltable, const bool outbltableexists, const bool overwrite)
295 { return table_->subBaseline(blinfo, returnfitresult, outbltable, outbltableexists, overwrite); }
296 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="")
297 { table_->polyBaseline(mask, order, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
298
299 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="")
300 { table_->autoPolyBaseline(mask, order, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
301
302 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="")
303 { table_->chebyshevBaseline(mask, order, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
304
305 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="")
306 { table_->autoChebyshevBaseline(mask, order, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
307
308 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="")
309 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
310
311 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="")
312 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
313
314 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="")
315 { table_->sinusoidBaseline(mask, fftinfo, addwn, rejwn, clipthresh, clipniter, getresidual, showprogress, outlog, blfile, bltable); }
316
317 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="")
318 { table_->autoSinusoidBaseline(mask, fftinfo, addwn, rejwn, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile, bltable); }
319
320 float getRms(const std::vector<bool>& mask, int whichrow)
321 { return table_->getRms(mask, whichrow); }
322
323 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)
324 { return table_->formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
325
326 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)
327 { return table_->formatPiecewiseBaselineParams(ranges, params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
328
329 bool isAllChannelsFlagged(int whichrow=0) const
330 { return table_->isAllChannelsFlagged(casa::uInt(whichrow)); }
331
332 std::vector<float> execFFT(int whichrow, const std::vector<bool>& mask, bool getRealImag=false, bool getAmplitudeOnly=false)
333 { return table_->execFFT(whichrow, mask, getRealImag, getAmplitudeOnly); }
334
335 std::vector<uint> getMoleculeIdColumnData() const
336 { return table_->getMoleculeIdColumnData(); }
337 void setMoleculeIdColumnData(const std::vector<uint>& molids)
338 { table_->setMoleculeIdColumnData(molids); }
339
340 std::vector<uint> getRootTableRowNumbers() const
341 { return table_->getRootTableRowNumbers(); }
342
343 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)
344 { return table_->calculateModelSelectionCriteria(valname, blfunc, order, inMask, whichrow, useLineFinder, edge, threshold, chanAvgLimit); }
345
346 void dropXPol() { table_->dropXPol(); }
347
348private:
349 casa::CountedPtr<Scantable> table_;
350};
351
352} // namespace
353#endif
Note: See TracBrowser for help on using the repository browser.