1 | //#---------------------------------------------------------------------------
|
---|
2 | //# SDMemTable.h: A MemoryTable container for single dish integrations
|
---|
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 _SDMEMTABLE_H_
|
---|
32 | #define _SDMEMTABLE_H_
|
---|
33 |
|
---|
34 | // STL
|
---|
35 | #include <string>
|
---|
36 | #include <vector>
|
---|
37 | // AIPS++
|
---|
38 | #include <aips/aips.h>
|
---|
39 | #include <aips/Utilities/String.h>
|
---|
40 | #include <aips/Tables/Table.h>
|
---|
41 | #include <aips/Arrays/MaskedArray.h>
|
---|
42 |
|
---|
43 | namespace atnf_sd {
|
---|
44 |
|
---|
45 | class SDContainer;
|
---|
46 | class SDHeader;
|
---|
47 | class SDFrequencyTable;
|
---|
48 |
|
---|
49 |
|
---|
50 | class SDMemTable {
|
---|
51 | public:
|
---|
52 | // create a new (empty) SDMemTable
|
---|
53 | SDMemTable();
|
---|
54 | // create a SDMemTable from a )aips++) table on disk
|
---|
55 | SDMemTable(const std::string& name);
|
---|
56 |
|
---|
57 | // Copy Construct a SDMemTable, if clear==True only header and
|
---|
58 | // skeleton are copied, otherwise the whole table is copied.
|
---|
59 | SDMemTable(const SDMemTable& other, Bool clear=False);
|
---|
60 |
|
---|
61 | // Copy Construct a SDMemTable, give a scanid constraint
|
---|
62 | // see also getScan()
|
---|
63 | SDMemTable(const Table& tab, Int scanID);
|
---|
64 |
|
---|
65 | virtual ~SDMemTable();
|
---|
66 |
|
---|
67 | // put data from meta conatiner into the table
|
---|
68 | virtual bool putSDContainer(const SDContainer& sdc);
|
---|
69 | virtual bool putSDHeader(const SDHeader& sdh);
|
---|
70 | virtual bool putSDFreqTable(const SDFrequencyTable& sdft) {;}
|
---|
71 |
|
---|
72 | //get the dat wrapped up in a meta container
|
---|
73 | virtual SDContainer getSDContainer(uInt whichRow=0) const;
|
---|
74 | virtual SDHeader getSDHeader() const;
|
---|
75 |
|
---|
76 | // get spectrum,mask and tsys for the given row, at the selected
|
---|
77 | // cursor - all as stl vectors
|
---|
78 | virtual std::vector<float> getSpectrum(Int whichRow);
|
---|
79 | virtual std::vector<bool> getMask(Int whichRow) const;
|
---|
80 |
|
---|
81 | virtual Float getTsys(Int whichRow) const;
|
---|
82 | // get all as aips++ Vectors
|
---|
83 | virtual void getSpectrum(Vector<Float>& spectrum, Int whichRow=0);
|
---|
84 | virtual void getMask(Vector<Bool>& mask,Int whichRow=0) const;
|
---|
85 |
|
---|
86 | // get info for current row
|
---|
87 | virtual Double getTime(Int whichRow) const ;
|
---|
88 | virtual std::string getSourceName(Int whichRow) const;
|
---|
89 |
|
---|
90 | // set the current value
|
---|
91 | virtual bool setIF(Int whichIF=0);
|
---|
92 | virtual bool setBeam(Int whichBeam=0);
|
---|
93 | virtual bool setPol(Int whichPol=0);
|
---|
94 | //sets the user mask
|
---|
95 | virtual bool setMask(const std::vector<int>& whichChans);
|
---|
96 |
|
---|
97 | // return the currently selected values
|
---|
98 | virtual Int getIF() { return IFSel_; }
|
---|
99 | virtual Int getBeam() { return beamSel_; }
|
---|
100 | virtual Int getPol() { return polSel_; }
|
---|
101 |
|
---|
102 | // print a summary to stdout
|
---|
103 | virtual void summary() const;
|
---|
104 |
|
---|
105 | // write to disk as aips++ table
|
---|
106 | void makePersistent(const std::string& filename);
|
---|
107 |
|
---|
108 | // get a new SDMemTable containg all rows with the same give SCANID
|
---|
109 | SDMemTable getScan(Int scanID);
|
---|
110 |
|
---|
111 | const TableRecord& getHeader() const {return table_.keywordSet();}
|
---|
112 | // get a handle to the "raw" aips++ table
|
---|
113 | const Table& table() { return table_; }
|
---|
114 |
|
---|
115 | // return the number of values
|
---|
116 | Int nBeam() const;
|
---|
117 | Int nIF() const;
|
---|
118 | Int nPol() const;
|
---|
119 | Int nChan() const;
|
---|
120 |
|
---|
121 | // return the number of rows (integrations) in the table
|
---|
122 | Int nRows() const { return table_.nrow(); }
|
---|
123 |
|
---|
124 | // return a row as a Masked array, internally converting uChar flags
|
---|
125 | // to bool mask
|
---|
126 | MaskedArray<Float> rowAsMaskedArray(uInt whichRow,
|
---|
127 | Bool useSelection = False);
|
---|
128 |
|
---|
129 | private:
|
---|
130 | // set up table structure
|
---|
131 | void setup();
|
---|
132 | // the current cursor into the array
|
---|
133 | Int IFSel_,beamSel_,polSel_;
|
---|
134 | std::vector<bool> chanMask_;
|
---|
135 | String name_;
|
---|
136 | // the unerlying memory table
|
---|
137 | Table table_;
|
---|
138 | };
|
---|
139 |
|
---|
140 | }// namespace
|
---|
141 | #endif
|
---|