source: trunk/src/SDMemTableWrapper.h @ 16

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

Updated data container. Changed the axis order in the spectrum/flag arrays to [nBeam,nIF,nPol,nChan]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
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:
46  SDMemTableWrapper(const std::string& name = "SDinput.tbl") :
47    table_(new SDMemTable(name)) {;}
48  SDMemTableWrapper(CountedPtr<SDMemTable> cp) : table_(cp) {;}
49  SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
50 
51  SDMemTableWrapper(const SDMemTableWrapper& mt, int scan) :
52    table_(new SDMemTable(mt.getCP()->table(), scan)) {;}
53 
54  SDMemTableWrapper getScan(int scan) {
55    return SDMemTableWrapper(*this, scan);
56  }
57  std::vector<float> getSpectrum(int whichRow) const {
58    return table_->getSpectrum(whichRow);
59  }
60  float getTsys(int whichRow) {return table_->getTsys(whichRow);}
61  double getTime(int whichRow) {return table_->getTime(whichRow);}
62
63  std::vector<bool> getMask(int whichRow) const {
64    return table_->getMask(whichRow);
65  }
66  bool setMask(const std::vector<int> mvals) const {
67    return table_->setMask(mvals);
68  }
69
70  std::string getSourceName(int whichRow) {
71    return table_->getSourceName(whichRow);
72  }
73
74  bool setIF(int whichIF=0) {return table_->setIF(whichIF);}
75  bool setBeam(int whichBeam=0) {return table_->setBeam(whichBeam);}
76  bool setPol(int whichPol=0) {return table_->setPol(whichPol);}
77
78  int getIF() {return table_->getIF();}
79  int getBeam() {return table_->getBeam();}
80  int getPol() {return table_->getPol();}
81
82
83  //sets the mask
84  bool setChannels(const std::vector<int>& whichChans) {
85    return setChannels(whichChans);
86  }
87  void makePersistent(const std::string& fname) {
88    table_->makePersistent(fname);
89  }
90  CountedPtr<SDMemTable> getCP() const {return table_;}
91  void summary() { table_->summary(); }
92  std::string name() { return table_->name(); }
93 
94private:
95  CountedPtr<SDMemTable> table_;
96};
97
98class SDReaderWrapper : public SDReader {
99public:
100  SDReaderWrapper() {;}
101  SDReaderWrapper(SDMemTableWrapper tbl) :
102    SDReader(tbl.getCP()){;}
103  SDMemTableWrapper getSDMemTable() const {
104    return SDMemTableWrapper(getTable());
105  }
106};
107
108class SDMathWrapper {
109public:
110  SDMemTableWrapper average(const SDMemTableWrapper& sdt) {
111    return SDMemTableWrapper(SDMath::average(sdt.getCP()));
112  }
113  SDMemTableWrapper quotient(const SDMemTableWrapper& on,
114                             const SDMemTableWrapper& off) {
115    return SDMemTableWrapper(SDMath::quotient(on.getCP(),
116                                             off.getCP()));
117  }
118  SDMemTableWrapper multiply(const SDMemTableWrapper& in,
119                             Float factor) {
120    return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));
121  }
122};
123
124} // namespace
125
126#endif
127
Note: See TracBrowser for help on using the repository browser.