source: trunk/src/Scantable.h@ 866

Last change on this file since 866 was 865, checked in by mar637, 19 years ago

added getAbcissa and several inline get functions. Full support of Table::Plain now (Ger modifications incasa::Table)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 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"
[860]40#include "STHistory.h"
[2]41
[745]42
[2]43
[824]44namespace asap {
[2]45
[824]46/**
47 * This class contains and wraps a casa::Table, which is used to store
48 * all the information. This can be either a MemoryTable or a
49 * disk based Table.
50 * It provides access functions to the underlying table
51 * It contains n subtables:
52 * @li weather
53 * @li frequencies
54 * @li molecules
55 * @li tcal
56 * @li focus
57 * @li fits
58 *
59 * @brief The main ASAP data container
60 * @author Malte Marquarding
61 * @date
62 * @version
63*/
64class Scantable : private SDLog
65{
[2]66public:
[824]67 /**
68 * Default constructor
69 */
70 Scantable(casa::Table::TableType ttype = casa::Table::Memory);
[19]71
[824]72 /**
73 * Create a Scantable object form an existing table on disk
74 * @param[in] name the name of the existing Scantable
75 */
76 Scantable(const std::string& name, casa::Table::TableType ttype = casa::Table::Memory);
[2]77
[824]78 /// @fixme this is only sensible for MemoryTables....
79 Scantable(const Scantable& other, bool clear=true);
[161]80
[824]81 /**
82 * Destructor
83 */
84 virtual ~Scantable();
[745]85
[824]86 /**
87 * get a const reference to the underlying casa::Table
[845]88 * @return consantcasa::Table reference
[824]89 */
90 const casa::Table& table() const;
[19]91
[824]92 /**
93 * get a reference to the underlying casa::Table with the Selection
94 * object applied if set
95 * @return casa::Table reference
96 */
97 casa::Table& table();
[21]98
[845]99
100 /**
101 * Get a handle to the selection object
102 * @return constant STSelector reference
103 */
104 const STSelector& getSelection() const { return selector_; }
105
106 /**
107 * Set the data to be a subset as defined by the STSelector
108 * @param selection a STSelector object
109 */
[824]110 void setSelection(const STSelector& selection);
[845]111
112 /**
113 * unset the selection of the data
114 */
[824]115 void unsetSelection();
116 /**
117 * set the header
118 * @param[in] sdh an SDHeader object
119 */
[845]120 void setHeader( const SDHeader& sdh );
[386]121
[824]122 /**
123 * get the header information
124 * @return an SDHeader object
125 */
[845]126 SDHeader getHeader( ) const;
[824]127 /**
128 * Checks if the "other" Scantable is conformant with this,
129 * i.e. if header values are the same.
130 * @param[in] other another Scantable
131 * @return true or false
132 */
133 bool conformant( const Scantable& other);
[430]134
[824]135 /**
136 * return the number of scans in the table
137 * @return number of scans in the table
138 */
[845]139 int nscan() const;
[490]140
[824]141 //casa::MDirection::Types getDirectionReference() const;
142 //casa::MEpoch::Types getTimeReference() const;
[21]143
[824]144 /**
145 * Get global antenna position
[845]146 * @return casa::MPosition
[824]147 */
148 casa::MPosition getAntennaPosition() const;
[490]149
[824]150 /**
[845]151 * Return the Flux unit of the data, e.g. "Jy" or "K"
152 * @return string
[824]153 */
154 std::string getFluxUnit() const;
[472]155
[824]156 /**
[845]157 * Set the Flux unit of the data
158 * @param unit a string representing the unit, e.g "Jy" or "K"
[824]159 */
160 void setFluxUnit( const std::string& unit );
[472]161
[824]162 /**
163 *
[845]164 * @param instrument a string representing an insturment. see xxx
[824]165 */
166 void setInstrument( const std::string& instrument );
[2]167
[845]168 /**
169 * (Re)calculate the azimuth and elevationnfor all rows
170 */
[824]171 void calculateAZEL();
[745]172
[824]173 /**
[845]174 * "hard" flag the data, this flags everything selected in setSelection()
[824]175 */
176 void flag();
[455]177
[852]178 /**
179 * Return a list of row numbers with respect to the original table.
180 * @return a lsi of rownumbers with respect to the original table
181 */
182 std::vector<unsigned int> rownumbers() const;
[845]183
[852]184
[845]185 /**
186 * Get the number of beams in the data or a specific scan
187 * @param scanno the scan number to get the number of beams for.
188 * If scanno<0 the number is retrieved from the header.
189 * @return an integer number
190 */
[824]191 int nbeam(int scanno=-1) const;
[845]192 /**
193 * Get the number of IFs in the data or a specific scan
194 * @param scanno the scan number to get the number of IFs for.
195 * If scanno<0 the number is retrieved from the header.
196 * @return an integer number
197 */
[824]198 int nif(int scanno=-1) const;
[845]199 /**
200 * Get the number of polarizations in the data or a specific scan
201 * @param scanno the scan number to get the number of polarizations for.
202 * If scanno<0 the number is retrieved from the header.
203 * @return an integer number
204 */
[824]205 int npol(int scanno=-1) const;
[794]206
[845]207 /**
208 * Get the number of channels in the data or a specific IF. This currently
209 * varies only with IF number
210 * @param ifno the IF number to get the number of channels for.
211 * If ifno<0 the number is retrieved from the header.
212 * @return an integer number
213 */
214 int nchan(int ifno=-1) const;
215
216 /**
217 * Get the number of integartion cycles
218 * @param scanno the scan number to get the number of rows for.
219 * If scanno<0 the number is retrieved from the header.
220 * @return
221 */
[824]222 int nrow(int scanno=-1) const;
[794]223
[845]224 int ncycle(int scanno=-1) const;
[50]225
[847]226 int getBeam(int whichrow) const;
227 int getIF(int whichrow) const;
228 int getPol(int whichrow) const;
[865]229 int getCycle(int whichrow) const { return cycleCol_(whichrow); }
230 int getScan(int whichrow) const { return scanCol_(whichrow); }
[206]231
[847]232 double getInterval(int whichrow) const
233 { return integrCol_(whichrow); }
[845]234
[865]235 float getTsys(int whichrow) const
236 { return casa::Vector<casa::Float>(tsysCol_(whichrow))(0); }
[847]237 float getElevation(int whichrow) const
238 { return elCol_(whichrow); }
239 float getAzimuth(int whichrow) const
240 { return azCol_(whichrow); }
[865]241 float getParAngle(int whichrow) const
[847]242 { return paraCol_(whichrow); }
[386]243
[865]244 std::string getSourceName(int whichrow) const
245 { return srcnCol_(whichrow); }
246
[847]247 std::vector<bool> getMask(int whichrow) const;
248 std::vector<float> getSpectrum(int whichrow) const;
249
[824]250 std::vector<float> getStokesSpectrum( int whichrow=0,
251 bool dopol=false) const;
252 std::string getPolarizationLabel(bool linear, bool stokes,
253 bool linpol,
254 int polidx=-1) const;
[401]255
[845]256 /**
257 * Write the Scantable to disk
258 * @param filename the output file name
259 */
[824]260 void makePersistent(const std::string& filename);
[745]261
[860]262 std::vector<std::string> getHistory() const
263 { return historyTable_.getHistory(); };
[483]264
[860]265 void addHistory(const std::string& hist) { historyTable_.addEntry(hist); }
[488]266
[860]267 void appendToHistoryTable(const STHistory& otherhist)
268 { historyTable_.append(otherhist); }
269
[824]270 std::string summary(bool verbose=false);
271 std::string getTime(int whichrow=-1, bool showdate=true) const;
[19]272
[847]273 // returns unit, conversion frame, doppler, base-frame
[18]274
[847]275 /**
276 * Get the frequency set up
277 * This is forwarded to the STFrequencies subtable
278 * @return unit, frame, doppler
279 */
280 std::vector<std::string> getCoordInfo() const
281 { return freqTable_.getInfo(); };
282
283 void setCoordInfo(std::vector<string> theinfo)
284 { return freqTable_.setInfo(theinfo); };
285
[865]286
287 std::vector<double> getAbcissa(int whichrow) const;
288
[847]289 std::string getAbcissaLabel(int whichrow) const;
290 std::vector<double> getRestFrequencies() const
291 { return moleculeTable_.getRestFrequencies(); }
292
293 void setRestFrequencies(double rf, const std::string& = "Hz");
294 void setRestFrequencies(const std::string& name);
295
[824]296 STFrequencies& frequencies() { return freqTable_; }
297 STWeather& weather() { return weatherTable_; }
298 STFocus& focus() { return focusTable_; }
299 STTcal& tcal() { return tcalTable_; }
300 STMolecules& molecules() { return moleculeTable_; }
[860]301 STHistory& history() { return historyTable_; }
[2]302
[824]303private:
304 /**
305 * Turns a time vale into a formatted string
306 * @param x
307 * @return
308 */
309 std::string formatSec(casa::Double x) const;
[18]310
[824]311 std::string formatTime(const casa::MEpoch& me, bool showdate)const;
[22]312
[824]313 /**
314 * Turns a casa::MDirection into a nicely formatted string
315 * @param md an casa::MDirection
316 * @return
317 */
318 std::string formatDirection(const casa::MDirection& md) const;
[19]319
[286]320
[824]321 /**
322 * Create a unique file name for the paged (temporary) table
323 * @return just the name
324 */
325 static casa::String generateName();
[286]326
[824]327 /**
328 * attach to cached columns
329 */
330 void attach();
[50]331
[824]332 /**
333 * Set up the main casa::Table
334 */
335 void setupMainTable();
[88]336
[824]337 void setupFitTable();
[212]338
[859]339 void attachSubtables();
[865]340 void copySubtables(const Scantable& other);
341
[824]342 /**
343 * Convert an "old" asap1 style row index into a new index
344 * @param[in] therow
345 * @return and index into @table_
346 */
347 int rowToScanIndex(int therow);
[212]348
[824]349 static const unsigned int version_ = 2;
[286]350
[824]351 STSelector selector_;
[236]352
[824]353 casa::Table::TableType type_;
[465]354
[824]355 // the actual data
356 casa::Table table_;
357 casa::Table originalTable_;
[745]358
[824]359 STTcal tcalTable_;
360 STFrequencies freqTable_;
361 STWeather weatherTable_;
362 STFocus focusTable_;
363 STMolecules moleculeTable_;
[860]364 STHistory historyTable_;
365
[824]366 casa::Table fitTable_;
[777]367
[824]368 // Cached Columns to avoid reconstructing them for each row get/put
[847]369 casa::ScalarColumn<casa::Double> integrCol_;
[824]370 casa::MDirection::ScalarColumn dirCol_;
[847]371 casa::MEpoch::ScalarColumn timeCol_;
[824]372 casa::ScalarColumn<casa::Double> azCol_;
373 casa::ScalarColumn<casa::Double> elCol_;
374 casa::ScalarColumn<casa::Float> paraCol_;
375 casa::ScalarColumn<casa::String> srcnCol_, fldnCol_;
[847]376 casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_;
[824]377 casa::ScalarColumn<casa::Int> rbeamCol_;
[865]378 casa::ArrayColumn<casa::Float> specCol_, tsysCol_;
[824]379 casa::ArrayColumn<casa::uChar> flagsCol_;
[430]380
[824]381 // id in frequencies table
382 casa::ScalarColumn<casa::uInt> mfreqidCol_;
383 // id in tcal table
384 casa::ScalarColumn<casa::uInt> mtcalidCol_;
[430]385
[824]386 casa::ArrayColumn<casa::String> histitemCol_;
387 casa::ScalarColumn<casa::uInt> mfitidCol_, fitidCol_;
388 // id in weather table and main table
389 casa::ScalarColumn<casa::uInt> mweatheridCol_;
[322]390
[824]391 casa::ScalarColumn<casa::uInt> mfocusidCol_;
392
393 casa::ScalarColumn<casa::uInt> mmolidCol_;
394
[2]395};
396
[824]397
398} // namespace
399
[2]400#endif
Note: See TracBrowser for help on using the repository browser.