source: trunk/src/ScantableWrapper.h @ 3046

Last change on this file since 3046 was 3046, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: Yes CAS-7764

Ready for Test: Yes

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description:


Release GIL in some time-consuming functions. Currently the following functions releases GIL:


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