source: trunk/src/SDMemTableWrapper.h@ 44

Last change on this file since 44 was 41, checked in by mmarquar, 20 years ago

Added wrappers for baseline,hanning and getAbscissa.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
RevLine 
[2]1//#---------------------------------------------------------------------------
2//# SDMemTableWrapper.h: Wrapper classes to use CountedPtr
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# Malte Marquarding, ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31#ifndef _SDMEMTABLEWRAPPER_H_
32#define _SDMEMTABLEWRAPPER_H_
33
34#include <vector>
35#include <string>
36
37#include "SDMemTable.h"
38#include "SDReader.h"
39#include "SDMath.h"
40
41namespace atnf_sd {
42
43class SDMemTableWrapper {
44
45public:
[18]46 SDMemTableWrapper(const std::string& name) :
[2]47 table_(new SDMemTable(name)) {;}
[18]48 SDMemTableWrapper() :
49 table_(new SDMemTable()) {;}
50
[2]51 SDMemTableWrapper(CountedPtr<SDMemTable> cp) : table_(cp) {;}
52 SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
53
54 SDMemTableWrapper(const SDMemTableWrapper& mt, int scan) :
55 table_(new SDMemTable(mt.getCP()->table(), scan)) {;}
56
57 SDMemTableWrapper getScan(int scan) {
58 return SDMemTableWrapper(*this, scan);
59 }
60 std::vector<float> getSpectrum(int whichRow) const {
61 return table_->getSpectrum(whichRow);
62 }
[41]63
64 std::vector<double> getAbscissa(int whichRow,
65 const std::string& unit = "GHz",
66 double restfreq=0.0) const {
67 return table_->getAbscissa(whichRow,unit,restfreq);
68 }
69
[2]70 float getTsys(int whichRow) {return table_->getTsys(whichRow);}
71 double getTime(int whichRow) {return table_->getTime(whichRow);}
72
[16]73 std::vector<bool> getMask(int whichRow) const {
74 return table_->getMask(whichRow);
75 }
76 bool setMask(const std::vector<int> mvals) const {
77 return table_->setMask(mvals);
78 }
[2]79
80 std::string getSourceName(int whichRow) {
81 return table_->getSourceName(whichRow);
82 }
83
84 bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
85 bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
86 bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
87
88 int getIF() {return table_->getIF();}
89 int getBeam() {return table_->getBeam();}
90 int getPol() {return table_->getPol();}
91
[18]92 int nIF() {return table_->nIF();}
93 int nBeam() {return table_->nBeam();}
94 int nPol() {return table_->nPol();}
95 int nChan() {return table_->nChan();}
[2]96
97 //sets the mask
98 bool setChannels(const std::vector<int>& whichChans) {
99 return setChannels(whichChans);
100 }
101 void makePersistent(const std::string& fname) {
102 table_->makePersistent(fname);
103 }
104 CountedPtr<SDMemTable> getCP() const {return table_;}
105 void summary() { table_->summary(); }
106
107private:
108 CountedPtr<SDMemTable> table_;
109};
110
111class SDReaderWrapper : public SDReader {
112public:
113 SDReaderWrapper() {;}
114 SDReaderWrapper(SDMemTableWrapper tbl) :
115 SDReader(tbl.getCP()){;}
116 SDMemTableWrapper getSDMemTable() const {
117 return SDMemTableWrapper(getTable());
118 }
119};
120
121class SDMathWrapper {
122public:
123 SDMemTableWrapper average(const SDMemTableWrapper& sdt) {
124 return SDMemTableWrapper(SDMath::average(sdt.getCP()));
125 }
[10]126 SDMemTableWrapper quotient(const SDMemTableWrapper& on,
127 const SDMemTableWrapper& off) {
128 return SDMemTableWrapper(SDMath::quotient(on.getCP(),
129 off.getCP()));
130 }
[16]131 SDMemTableWrapper multiply(const SDMemTableWrapper& in,
132 Float factor) {
[24]133 return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));
[16]134 }
[41]135
136 SDMemTableWrapper hanning(const SDMemTableWrapper& in) {
137 return SDMemTableWrapper(SDMath::hanning(in.getCP()));
138 }
[24]139 std::vector<float> baseline(const SDMemTableWrapper& in, const std::string& fitexpr) {
140 return SDMath::baseline(in.getCP(), fitexpr);
141 }
[2]142};
143
144} // namespace
145
146#endif
147
Note: See TracBrowser for help on using the repository browser.