source: trunk/src/Scantable.h @ 824

Last change on this file since 824 was 824, checked in by mar637, 18 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
Line 
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
14
15// STL
16#include <string>
17#include <vector>
18// AIPS++
19#include <casa/aips.h>
20#include <casa/Arrays/MaskedArray.h>
21#include <casa/BasicSL/String.h>
22#include <casa/Utilities/CountedPtr.h>
23
24#include <coordinates/Coordinates/SpectralCoordinate.h>
25
26#include <tables/Tables/Table.h>
27#include <tables/Tables/ArrayColumn.h>
28#include <tables/Tables/ScalarColumn.h>
29
30#include <measures/TableMeasures/ScalarMeasColumn.h>
31
32#include "SDLog.h"
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"
40
41
42
43namespace asap {
44
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{
65public:
66  /**
67   * Default constructor
68   */
69  Scantable(casa::Table::TableType ttype = casa::Table::Memory);
70
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);
76
77  /// @fixme this is only sensible for MemoryTables....
78  Scantable(const Scantable& other, bool clear=true);
79
80  /**
81   * Destructor
82   */
83  virtual ~Scantable();
84
85  /**
86   * get a const reference to the underlying casa::Table
87   * @return const casa::Table reference
88   */
89  const casa::Table& table() const;
90
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();
97
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 );
105
106  /**
107   * get the header information
108   * @return an SDHeader object
109   */
110  SDHeader getSDHeader( ) const;
111
112
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);
120
121  /**
122   * return the number of scans in the table
123   * @return number of scans in the table
124   */
125  int nScan() const;
126
127  //casa::MDirection::Types getDirectionReference() const;
128  //casa::MEpoch::Types getTimeReference() const;
129
130  /**
131   * Get global antenna position
132   * @return
133   */
134  casa::MPosition getAntennaPosition() const;
135
136  /**
137   *
138   * @return
139   */
140
141  std::string getFluxUnit() const;
142
143  /**
144   *
145   * @param unit
146   */
147  void setFluxUnit( const std::string& unit );
148
149  /**
150   *
151   * @param instrument
152   */
153  void setInstrument( const std::string& instrument );
154
155  void calculateAZEL();
156
157  /**
158   * "hard" flags
159   * @param[in] whichrow
160   */
161  void flag();
162
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;
167
168  int nrow(int scanno=-1) const;
169
170  double getInterval(int whichrow=0) const;
171
172  float getTsys(int whichrow=0) const;
173
174  std::vector<bool> getMask(int whichrow=0) const;
175  std::vector<float> getSpectrum(int whichrow=0) const;
176
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;
182
183  void makePersistent(const std::string& filename);
184
185
186  void select(const STSelector& sel);
187
188  const STSelector& selection() const { return selector_; }
189
190  std::vector<std::string> getHistory() const;
191  void addHistory(const std::string& hist);
192
193  casa::Table getHistoryTable() const;
194  void appendToHistoryTable(const casa::Table& otherHist);
195
196  std::string summary(bool verbose=false);
197  std::string getTime(int whichrow=-1, bool showdate=true) const;
198
199
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_; }
205
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;
213
214  std::string formatTime(const casa::MEpoch& me, bool showdate)const;
215
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;
222
223
224  /**
225   * Create a unique file name for the paged (temporary) table
226   * @return just the name
227   */
228  static casa::String generateName();
229
230  /**
231   * attach to cached columns
232   */
233  void attach();
234
235  /**
236   * Set up the main casa::Table
237   */
238  void setupMainTable();
239
240  void setupHistoryTable();
241  void setupMoleculeTable();
242  void setupFitTable();
243
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);
250
251  static const unsigned int version_ = 2;
252
253  STSelector selector_;
254
255  casa::Table::TableType type_;
256
257  // the actual data
258  casa::Table table_;
259  casa::Table originalTable_;
260
261  STTcal tcalTable_;
262  STFrequencies freqTable_;
263  STWeather weatherTable_;
264  STFocus focusTable_;
265  STMolecules moleculeTable_;
266  casa::Table fitTable_;
267  casa::Table historyTable_;
268
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_;
280
281  // id in frequencies table
282  casa::ScalarColumn<casa::uInt> mfreqidCol_;
283  // id in tcal table
284  casa::ScalarColumn<casa::uInt> mtcalidCol_;
285
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_;
290
291  casa::ScalarColumn<casa::uInt> mfocusidCol_;
292
293  casa::ScalarColumn<casa::uInt> mmolidCol_;
294
295};
296
297
298} // namespace
299
300#endif
Note: See TracBrowser for help on using the repository browser.