source: trunk/src/ScantableWrapper.h@ 2077

Last change on this file since 2077 was 2047, checked in by WataruKawasaki, 14 years ago

New Development: Yes

JIRA Issue: Yes CAS-2847

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: Yes

Module(s): scantable

Description: added {auto_}sinusoid_baseline() for sinusoidal baseline fitting. also minor bug fixes for asapfitter.


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