source: trunk/src/ScantableWrapper.h@ 2608

Last change on this file since 2608 was 2591, checked in by WataruKawasaki, 12 years ago

New Development: Yes

JIRA Issue: Yes CSV-1869

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asap

Description: added a scantable function to get/set moleculesID columns data.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.4 KB
RevLine 
[847]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
[2]14
[2587]15#include <iostream>
16#include <string>
[2]17#include <vector>
[2587]18
[380]19#include <casa/Arrays/Vector.h>
[2]20
[465]21#include "MathUtils.h"
[2587]22#include "Scantable.h"
23#include "STCoordinate.h"
[901]24#include "STFit.h"
[1931]25#include "STFitEntry.h"
[2]26
[83]27namespace asap {
[847]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 {
[2]40
41public:
[1385]42 explicit ScantableWrapper( const std::string& name,
[1077]43 int type=0)
[864]44 {
45 casa::Table::TableType tp = casa::Table::Memory;
[1077]46 if ( type == 1 ) tp = casa::Table::Plain;
[864]47 table_ = new Scantable(name, tp);
48 }
[90]49
[1350]50 explicit ScantableWrapper(int type=0)
[864]51 {
52 casa::Table::TableType tp = casa::Table::Memory;
[1077]53 if ( type == 1) tp = casa::Table::Plain;
[864]54 table_= new Scantable(tp);
55 }
[90]56
[1350]57 explicit ScantableWrapper(casa::CountedPtr<Scantable> cp) : table_(cp) {;}
[90]58
[847]59 ScantableWrapper(const ScantableWrapper& mt) :
60 table_(mt.getCP()) {;}
[90]61
[2587]62 ~ScantableWrapper()
63 {
64 }
65
[868]66 void assign(const ScantableWrapper& mt)
67 { table_= mt.getCP(); }
68
[847]69 ScantableWrapper copy() {
70 return ScantableWrapper(new Scantable(*(this->getCP()), false));
[80]71 }
[868]72
[896]73 std::vector<float> getSpectrum( int whichrow=0,
[905]74 const std::string& poltype="" ) const {
[896]75 return table_->getSpectrum(whichrow, poltype);
[2]76 }
[527]77 // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const {
78 // Boost fails with 4 arguments.
[902]79 std::string getPolarizationLabel(int index, const std::string& ptype) const {
80 return table_->getPolarizationLabel(index, ptype);
[494]81 }
[527]82
[896]83 std::vector<double> getAbcissa(int whichrow=0) const
84 { return table_->getAbcissa(whichrow); }
[41]85
[896]86 std::string getAbcissaLabel(int whichrow=0) const
87 { return table_->getAbcissaLabel(whichrow); }
[157]88
[896]89 float getTsys(int whichrow=0) const
90 { return table_->getTsys(whichrow); }
[2]91
[2161]92 std::vector<float> getTsysSpectrum(int whichrow=0) const
93 { return table_->getTsysSpectrum(whichrow); }
94
[1947]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)); }
[207]99
[1350]100 double getIntTime(int whichrow=0) const
101 { return table_->getIntTime(whichrow); }
102
[1068]103 std::string getDirectionString(int whichrow=0) const
104 { return table_->getDirectionString(whichrow); }
105
[864]106 std::string getFluxUnit() const { return table_->getFluxUnit(); }
107
108 void setFluxUnit(const std::string& unit) { table_->setFluxUnit(unit); }
109
[238]110 void setInstrument(const std::string& name) {table_->setInstrument(name);}
[1189]111 void setFeedType(const std::string& ftype) {table_->setFeedType(ftype);}
[238]112
[896]113 std::vector<bool> getMask(int whichrow=0) const
114 { return table_->getMask(whichrow); }
[2]115
[1430]116 /**
[1000]117 void flag(const std::vector<bool>& msk=std::vector<bool>())
118 { table_->flag(msk); }
[1430]119 **/
[1994]120 /**
[1430]121 void flag(const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
122 { table_->flag(msk, unflag); }
[1994]123 **/
124 void flag(int whichrow=-1, const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false)
125 { table_->flag(whichrow, msk, unflag); }
[2]126
[1819]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
[896]139 std::string getSourceName(int whichrow=0) const
140 { return table_->getSourceName(whichrow); }
[794]141
[896]142 float getElevation(int whichrow=0) const
143 { return table_->getElevation(whichrow); }
[90]144
[896]145 float getAzimuth(int whichrow=0) const
146 { return table_->getAzimuth(whichrow); }
[2]147
[896]148 float getParAngle(int whichrow=0) const
149 { return table_->getParAngle(whichrow); }
[2]150
[864]151
[884]152 void setSpectrum(std::vector<float> spectrum, int whichrow=0)
153 { table_->setSpectrum(spectrum, whichrow); }
[868]154
[1111]155 std::vector<uint> getIFNos() { return table_->getIFNos(); }
[864]156 int getIF(int whichrow) const {return table_->getIF(whichrow);}
[1111]157 std::vector<uint> getBeamNos() { return table_->getBeamNos(); }
[864]158 int getBeam(int whichrow) const {return table_->getBeam(whichrow);}
[1111]159 std::vector<uint> getPolNos() { return table_->getPolNos(); }
[864]160 int getPol(int whichrow) const {return table_->getPol(whichrow);}
[868]161 int getCycle(int whichrow) const {return table_->getCycle(whichrow);}
[1111]162 std::vector<uint> getScanNos() { return table_->getScanNos(); }
[868]163 int getScan(int whichrow) const {return table_->getScan(whichrow);}
[1819]164 std::vector<uint> getMolNos() { return table_->getMolNos();}
[864]165
166 STSelector getSelection() const { return table_->getSelection(); }
[868]167 void setSelection(const STSelector& sts)
168 { return table_->setSelection(sts);}
[864]169
[896]170 std::string getPolType() const { return table_->getPolType(); }
171
[864]172 int nif(int scanno=-1) const {return table_->nif(scanno);}
173 int nbeam(int scanno=-1) const {return table_->nbeam(scanno);}
174 int npol(int scanno=-1) const {return table_->npol(scanno);}
175 int nchan(int ifno=-1) const {return table_->nchan(ifno);}
176 int nscan() const {return table_->nscan();}
177 int nrow() const {return table_->nrow();}
[902]178 int ncycle(int scanno) const {return table_->ncycle(scanno);}
[2]179
[864]180 void makePersistent(const std::string& fname)
181 { table_->makePersistent(fname); }
[90]182
[1068]183 void setSourceType(int stype)
184 { table_->setSourceType(stype); }
185
[1360]186 void shift(int npix)
187 { table_->shift(npix); }
188
[1819]189/**
190 commented out by TT
[1170]191 void setRestFrequencies(double rf, const std::string& name,
192 const std::string& unit)
193 { table_->setRestFrequencies(rf, name, unit); }
[1819]194**/
195 void setRestFrequencies(vector<double> rf, const vector<std::string>& name,
196 const std::string& unit)
197 { table_->setRestFrequencies(rf, name, unit); }
198
[925]199/*
[868]200 void setRestFrequencies(const std::string& name) {
201 table_->setRestFrequencies(name);
[847]202 }
[925]203*/
[745]204
[1819]205/*
[864]206 std::vector<double> getRestFrequencies() const
207 { return table_->getRestFrequencies(); }
[1819]208*/
209 std::vector<double> getRestFrequency(int id) const
210 { return table_->getRestFrequency(id); }
[251]211
[105]212 void setCoordInfo(std::vector<string> theinfo) {
213 table_->setCoordInfo(theinfo);
214 }
215 std::vector<string> getCoordInfo() const {
216 return table_->getCoordInfo();
217 }
[90]218
[987]219 void setDirection(const std::string& refstr="")
220 { table_->setDirectionRefString(refstr); }
221
[847]222 casa::CountedPtr<Scantable> getCP() const {return table_;}
223 Scantable* getPtr() {return &(*table_);}
[380]224
[2286]225 // std::string summary() const {
226 // return table_->summary();
227 // }
228 void summary(const std::string& filename="") {
[2290]229 //std::string summary(const std::string& filename="") const {
230 table_->summary(filename);
[380]231 }
[745]232
[2178]233 std::string listHeader() const {
[2163]234 return table_->headerSummary();
[2111]235 }
236
[2163]237 std::vector<std::string> getHistory() const
[864]238 { return table_->getHistory(); }
[207]239
[864]240 void addHistory(const std::string& hist)
241 { table_->addHistory(hist); }
[745]242
[972]243 void addFit(const STFitEntry& fit, int row)
244 { table_->addFit(fit, row); }
245
246 STFitEntry getFit(int whichrow) const
247 { return table_->getFit(whichrow); }
248
[2012]249 void calculateAZEL() { table_->calculateAZEL(); }
[465]250
[1003]251 std::vector<std::string> columnNames() const
252 { return table_->columnNames(); }
253
[1391]254 std::string getAntennaName() const
255 { return table_->getAntennaName(); }
256
257 int checkScanInfo(const vector<int>& scanlist) const
258 { return table_->checkScanInfo(scanlist); }
[1819]259
[1730]260 std::vector<double> getDirectionVector(int whichrow) const
[1391]261 { return table_->getDirectionVector(whichrow); }
262
[1586]263 void parallactify(bool flag)
264 { table_->parallactify(flag); }
265
[1598]266 STCoordinate getCoordinate(int row) {
267 return STCoordinate(table_->getSpectralCoordinate(row));
268 }
269
[1730]270 std::vector<float> getWeather(int whichrow) const
271 { return table_->getWeather(whichrow); }
272
[1819]273 void reshapeSpectrum( int nmin, int nmax )
274 { table_->reshapeSpectrum( nmin, nmax ); }
275
[2435]276 void regridSpecChannel( double dnu, int nchan )
277 { table_->regridSpecChannel( dnu, nchan ); }
278
[2189]279 void polyBaseline(const std::vector<bool>& mask, int order, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="")
280 { table_->polyBaseline(mask, order, getresidual, showprogress, outlog, blfile); }
[1907]281
[2189]282 void autoPolyBaseline(const std::vector<bool>& mask, int order, 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="")
283 { table_->autoPolyBaseline(mask, order, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); }
[1907]284
[2189]285 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="")
286 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, showprogress, outlog, blfile); }
[2012]287
[2189]288 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="")
289 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); }
[2012]290
[2189]291 void sinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, 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="")
292 { table_->sinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, getresidual, showprogress, outlog, blfile); }
[2047]293
[2189]294 void autoSinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, 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="")
295 { table_->autoSinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); }
[2047]296
[2012]297 float getRms(const std::vector<bool>& mask, int whichrow)
298 { return table_->getRms(mask, whichrow); }
299
300 std::string formatBaselineParams(const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false)
[2193]301 { return table_->formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, verbose); }
[2012]302
303 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)
[2193]304 { return table_->formatPiecewiseBaselineParams(ranges, params, fixed, rms, -1, masklist, whichrow, verbose); }
[2012]305
[1907]306 bool getFlagtraFast(int whichrow=0) const
[2047]307 { return table_->getFlagtraFast(casa::uInt(whichrow)); }
[1907]308
[2186]309 std::vector<float> execFFT(int whichrow, const std::vector<bool>& mask, bool getRealImag=false, bool getAmplitudeOnly=false)
310 { return table_->execFFT(whichrow, mask, getRealImag, getAmplitudeOnly); }
[1907]311
[2591]312 std::vector<uint> getMoleculeIdColumnData() const
313 { return table_->getMoleculeIdColumnData(); }
314 void setMoleculeIdColumnData(const std::vector<uint>& molids)
315 { table_->setMoleculeIdColumnData(molids); }
[2012]316
[2186]317
[2]318private:
[847]319 casa::CountedPtr<Scantable> table_;
[2]320};
321
322} // namespace
323#endif
Note: See TracBrowser for help on using the repository browser.