source: trunk/src/Scantable.h@ 1082

Last change on this file since 1082 was 1068, checked in by mar637, 18 years ago

added Scantable::getDirectionString; added Scantable::setSourceType

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