source: trunk/src/Scantable.h@ 830

Last change on this file since 830 was 824, checked in by mar637, 19 years ago

Forgot to change the contents in the last check in

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
RevLine 
[824]1//
2// C++ Interface: Scantable
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2005
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef ASAPSCANTABLE_H
13#define ASAPSCANTABLE_H
[2]14
15// STL
16#include <string>
17#include <vector>
18// AIPS++
[455]19#include <casa/aips.h>
[322]20#include <casa/Arrays/MaskedArray.h>
[80]21#include <casa/BasicSL/String.h>
[824]22#include <casa/Utilities/CountedPtr.h>
23
[322]24#include <coordinates/Coordinates/SpectralCoordinate.h>
[824]25
[80]26#include <tables/Tables/Table.h>
[322]27#include <tables/Tables/ArrayColumn.h>
28#include <tables/Tables/ScalarColumn.h>
29
[824]30#include <measures/TableMeasures/ScalarMeasColumn.h>
31
[717]32#include "SDLog.h"
[824]33#include "SDContainer.h"
34#include "STFrequencies.h"
35#include "STWeather.h"
36#include "STFocus.h"
37#include "STTcal.h"
38#include "STMolecules.h"
39#include "STSelector.h"
[2]40
[745]41
[2]42
[824]43namespace asap {
[2]44
[824]45/**
46 * This class contains and wraps a casa::Table, which is used to store
47 * all the information. This can be either a MemoryTable or a
48 * disk based Table.
49 * It provides access functions to the underlying table
50 * It contains n subtables:
51 * @li weather
52 * @li frequencies
53 * @li molecules
54 * @li tcal
55 * @li focus
56 * @li fits
57 *
58 * @brief The main ASAP data container
59 * @author Malte Marquarding
60 * @date
61 * @version
62*/
63class Scantable : private SDLog
64{
[2]65public:
[824]66 /**
67 * Default constructor
68 */
69 Scantable(casa::Table::TableType ttype = casa::Table::Memory);
[19]70
[824]71 /**
72 * Create a Scantable object form an existing table on disk
73 * @param[in] name the name of the existing Scantable
74 */
75 Scantable(const std::string& name, casa::Table::TableType ttype = casa::Table::Memory);
[2]76
[824]77 /// @fixme this is only sensible for MemoryTables....
78 Scantable(const Scantable& other, bool clear=true);
[161]79
[824]80 /**
81 * Destructor
82 */
83 virtual ~Scantable();
[745]84
[824]85 /**
86 * get a const reference to the underlying casa::Table
87 * @return const casa::Table reference
88 */
89 const casa::Table& table() const;
[19]90
[824]91 /**
92 * get a reference to the underlying casa::Table with the Selection
93 * object applied if set
94 * @return casa::Table reference
95 */
96 casa::Table& table();
[21]97
[824]98 void setSelection(const STSelector& selection);
99 void unsetSelection();
100 /**
101 * set the header
102 * @param[in] sdh an SDHeader object
103 */
104 void putSDHeader( const SDHeader& sdh );
[386]105
[824]106 /**
107 * get the header information
108 * @return an SDHeader object
109 */
110 SDHeader getSDHeader( ) const;
[293]111
[306]112
[824]113 /**
114 * Checks if the "other" Scantable is conformant with this,
115 * i.e. if header values are the same.
116 * @param[in] other another Scantable
117 * @return true or false
118 */
119 bool conformant( const Scantable& other);
[430]120
[824]121 /**
122 * return the number of scans in the table
123 * @return number of scans in the table
124 */
125 int nScan() const;
[490]126
[824]127 //casa::MDirection::Types getDirectionReference() const;
128 //casa::MEpoch::Types getTimeReference() const;
[21]129
[824]130 /**
131 * Get global antenna position
132 * @return
133 */
134 casa::MPosition getAntennaPosition() const;
[490]135
[824]136 /**
137 *
138 * @return
139 */
[430]140
[824]141 std::string getFluxUnit() const;
[472]142
[824]143 /**
144 *
145 * @param unit
146 */
147 void setFluxUnit( const std::string& unit );
[472]148
[824]149 /**
150 *
151 * @param instrument
152 */
153 void setInstrument( const std::string& instrument );
[2]154
[824]155 void calculateAZEL();
[745]156
[824]157 /**
158 * "hard" flags
159 * @param[in] whichrow
160 */
161 void flag();
[455]162
[824]163 int nbeam(int scanno=-1) const;
164 int nif(int scanno=-1) const;
165 int npol(int scanno=-1) const;
166 int nchan(int scanno=-1, int ifno=-1) const;
[794]167
[824]168 int nrow(int scanno=-1) const;
[794]169
[824]170 double getInterval(int whichrow=0) const;
[50]171
[824]172 float getTsys(int whichrow=0) const;
[206]173
[824]174 std::vector<bool> getMask(int whichrow=0) const;
175 std::vector<float> getSpectrum(int whichrow=0) const;
[386]176
[824]177 std::vector<float> getStokesSpectrum( int whichrow=0,
178 bool dopol=false) const;
179 std::string getPolarizationLabel(bool linear, bool stokes,
180 bool linpol,
181 int polidx=-1) const;
[401]182
[824]183 void makePersistent(const std::string& filename);
[745]184
[236]185
[824]186 void select(const STSelector& sel);
[88]187
[824]188 const STSelector& selection() const { return selector_; }
[303]189
[483]190 std::vector<std::string> getHistory() const;
191 void addHistory(const std::string& hist);
192
[488]193 casa::Table getHistoryTable() const;
194 void appendToHistoryTable(const casa::Table& otherHist);
195
[824]196 std::string summary(bool verbose=false);
197 std::string getTime(int whichrow=-1, bool showdate=true) const;
[19]198
[18]199
[824]200 STFrequencies& frequencies() { return freqTable_; }
201 STWeather& weather() { return weatherTable_; }
202 STFocus& focus() { return focusTable_; }
203 STTcal& tcal() { return tcalTable_; }
204 STMolecules& molecules() { return moleculeTable_; }
[2]205
[824]206private:
207 /**
208 * Turns a time vale into a formatted string
209 * @param x
210 * @return
211 */
212 std::string formatSec(casa::Double x) const;
[18]213
[824]214 std::string formatTime(const casa::MEpoch& me, bool showdate)const;
[22]215
[824]216 /**
217 * Turns a casa::MDirection into a nicely formatted string
218 * @param md an casa::MDirection
219 * @return
220 */
221 std::string formatDirection(const casa::MDirection& md) const;
[19]222
[286]223
[824]224 /**
225 * Create a unique file name for the paged (temporary) table
226 * @return just the name
227 */
228 static casa::String generateName();
[286]229
[824]230 /**
231 * attach to cached columns
232 */
233 void attach();
[50]234
[824]235 /**
236 * Set up the main casa::Table
237 */
238 void setupMainTable();
[88]239
[824]240 void setupHistoryTable();
241 void setupMoleculeTable();
242 void setupFitTable();
[212]243
[824]244 /**
245 * Convert an "old" asap1 style row index into a new index
246 * @param[in] therow
247 * @return and index into @table_
248 */
249 int rowToScanIndex(int therow);
[212]250
[824]251 static const unsigned int version_ = 2;
[286]252
[824]253 STSelector selector_;
[236]254
[824]255 casa::Table::TableType type_;
[465]256
[824]257 // the actual data
258 casa::Table table_;
259 casa::Table originalTable_;
[745]260
[824]261 STTcal tcalTable_;
262 STFrequencies freqTable_;
263 STWeather weatherTable_;
264 STFocus focusTable_;
265 STMolecules moleculeTable_;
266 casa::Table fitTable_;
267 casa::Table historyTable_;
[777]268
[824]269 // Cached Columns to avoid reconstructing them for each row get/put
270 casa::ScalarColumn<casa::Double> timeCol_, integrCol_;
271 casa::MDirection::ScalarColumn dirCol_;
272 casa::ScalarColumn<casa::Double> azCol_;
273 casa::ScalarColumn<casa::Double> elCol_;
274 casa::ScalarColumn<casa::Float> paraCol_;
275 casa::ScalarColumn<casa::String> srcnCol_, fldnCol_;
276 casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, cycleCol_;
277 casa::ScalarColumn<casa::Int> rbeamCol_;
278 casa::ArrayColumn<casa::Float> specCol_, tsCol_;
279 casa::ArrayColumn<casa::uChar> flagsCol_;
[430]280
[824]281 // id in frequencies table
282 casa::ScalarColumn<casa::uInt> mfreqidCol_;
283 // id in tcal table
284 casa::ScalarColumn<casa::uInt> mtcalidCol_;
[430]285
[824]286 casa::ArrayColumn<casa::String> histitemCol_;
287 casa::ScalarColumn<casa::uInt> mfitidCol_, fitidCol_;
288 // id in weather table and main table
289 casa::ScalarColumn<casa::uInt> mweatheridCol_;
[322]290
[824]291 casa::ScalarColumn<casa::uInt> mfocusidCol_;
292
293 casa::ScalarColumn<casa::uInt> mmolidCol_;
294
[2]295};
296
[824]297
298} // namespace
299
[2]300#endif
Note: See TracBrowser for help on using the repository browser.