[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] | 43 | namespace 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 | */
|
---|
| 63 | class Scantable : private SDLog
|
---|
| 64 | {
|
---|
[2] | 65 | public:
|
---|
[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
|
---|
[845] | 87 | * @return consantcasa::Table reference
|
---|
[824] | 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 |
|
---|
[845] | 98 |
|
---|
| 99 | /**
|
---|
| 100 | * Get a handle to the selection object
|
---|
| 101 | * @return constant STSelector reference
|
---|
| 102 | */
|
---|
| 103 | const STSelector& getSelection() const { return selector_; }
|
---|
| 104 |
|
---|
| 105 | /**
|
---|
| 106 | * Set the data to be a subset as defined by the STSelector
|
---|
| 107 | * @param selection a STSelector object
|
---|
| 108 | */
|
---|
[824] | 109 | void setSelection(const STSelector& selection);
|
---|
[845] | 110 |
|
---|
| 111 | /**
|
---|
| 112 | * unset the selection of the data
|
---|
| 113 | */
|
---|
[824] | 114 | void unsetSelection();
|
---|
| 115 | /**
|
---|
| 116 | * set the header
|
---|
| 117 | * @param[in] sdh an SDHeader object
|
---|
| 118 | */
|
---|
[845] | 119 | void setHeader( const SDHeader& sdh );
|
---|
[386] | 120 |
|
---|
[824] | 121 | /**
|
---|
| 122 | * get the header information
|
---|
| 123 | * @return an SDHeader object
|
---|
| 124 | */
|
---|
[845] | 125 | SDHeader getHeader( ) const;
|
---|
[824] | 126 | /**
|
---|
| 127 | * Checks if the "other" Scantable is conformant with this,
|
---|
| 128 | * i.e. if header values are the same.
|
---|
| 129 | * @param[in] other another Scantable
|
---|
| 130 | * @return true or false
|
---|
| 131 | */
|
---|
| 132 | bool conformant( const Scantable& other);
|
---|
[430] | 133 |
|
---|
[824] | 134 | /**
|
---|
| 135 | * return the number of scans in the table
|
---|
| 136 | * @return number of scans in the table
|
---|
| 137 | */
|
---|
[845] | 138 | int nscan() const;
|
---|
[490] | 139 |
|
---|
[824] | 140 | //casa::MDirection::Types getDirectionReference() const;
|
---|
| 141 | //casa::MEpoch::Types getTimeReference() const;
|
---|
[21] | 142 |
|
---|
[824] | 143 | /**
|
---|
| 144 | * Get global antenna position
|
---|
[845] | 145 | * @return casa::MPosition
|
---|
[824] | 146 | */
|
---|
| 147 | casa::MPosition getAntennaPosition() const;
|
---|
[490] | 148 |
|
---|
[824] | 149 | /**
|
---|
[845] | 150 | * Return the Flux unit of the data, e.g. "Jy" or "K"
|
---|
| 151 | * @return string
|
---|
[824] | 152 | */
|
---|
| 153 | std::string getFluxUnit() const;
|
---|
[472] | 154 |
|
---|
[824] | 155 | /**
|
---|
[845] | 156 | * Set the Flux unit of the data
|
---|
| 157 | * @param unit a string representing the unit, e.g "Jy" or "K"
|
---|
[824] | 158 | */
|
---|
| 159 | void setFluxUnit( const std::string& unit );
|
---|
[472] | 160 |
|
---|
[824] | 161 | /**
|
---|
| 162 | *
|
---|
[845] | 163 | * @param instrument a string representing an insturment. see xxx
|
---|
[824] | 164 | */
|
---|
| 165 | void setInstrument( const std::string& instrument );
|
---|
[2] | 166 |
|
---|
[845] | 167 | /**
|
---|
| 168 | * (Re)calculate the azimuth and elevationnfor all rows
|
---|
| 169 | */
|
---|
[824] | 170 | void calculateAZEL();
|
---|
[745] | 171 |
|
---|
[824] | 172 | /**
|
---|
[845] | 173 | * "hard" flag the data, this flags everything selected in setSelection()
|
---|
[824] | 174 | */
|
---|
| 175 | void flag();
|
---|
[455] | 176 |
|
---|
[845] | 177 |
|
---|
| 178 | /**
|
---|
| 179 | * Get the number of beams in the data or a specific scan
|
---|
| 180 | * @param scanno the scan number to get the number of beams for.
|
---|
| 181 | * If scanno<0 the number is retrieved from the header.
|
---|
| 182 | * @return an integer number
|
---|
| 183 | */
|
---|
[824] | 184 | int nbeam(int scanno=-1) const;
|
---|
[845] | 185 | /**
|
---|
| 186 | * Get the number of IFs in the data or a specific scan
|
---|
| 187 | * @param scanno the scan number to get the number of IFs for.
|
---|
| 188 | * If scanno<0 the number is retrieved from the header.
|
---|
| 189 | * @return an integer number
|
---|
| 190 | */
|
---|
[824] | 191 | int nif(int scanno=-1) const;
|
---|
[845] | 192 | /**
|
---|
| 193 | * Get the number of polarizations in the data or a specific scan
|
---|
| 194 | * @param scanno the scan number to get the number of polarizations for.
|
---|
| 195 | * If scanno<0 the number is retrieved from the header.
|
---|
| 196 | * @return an integer number
|
---|
| 197 | */
|
---|
[824] | 198 | int npol(int scanno=-1) const;
|
---|
[794] | 199 |
|
---|
[845] | 200 | /**
|
---|
| 201 | * Get the number of channels in the data or a specific IF. This currently
|
---|
| 202 | * varies only with IF number
|
---|
| 203 | * @param ifno the IF number to get the number of channels for.
|
---|
| 204 | * If ifno<0 the number is retrieved from the header.
|
---|
| 205 | * @return an integer number
|
---|
| 206 | */
|
---|
| 207 | int nchan(int ifno=-1) const;
|
---|
| 208 |
|
---|
| 209 | /**
|
---|
| 210 | * Get the number of integartion cycles
|
---|
| 211 | * @param scanno the scan number to get the number of rows for.
|
---|
| 212 | * If scanno<0 the number is retrieved from the header.
|
---|
| 213 | * @return
|
---|
| 214 | */
|
---|
[824] | 215 | int nrow(int scanno=-1) const;
|
---|
[794] | 216 |
|
---|
[845] | 217 | int ncycle(int scanno=-1) const;
|
---|
[50] | 218 |
|
---|
[847] | 219 | int getBeam(int whichrow) const;
|
---|
| 220 | int getIF(int whichrow) const;
|
---|
| 221 | int getPol(int whichrow) const;
|
---|
[206] | 222 |
|
---|
[847] | 223 | double getInterval(int whichrow) const
|
---|
| 224 | { return integrCol_(whichrow); }
|
---|
[845] | 225 |
|
---|
[847] | 226 | float getTsys(int whichrow) const;
|
---|
| 227 | float getElevation(int whichrow) const
|
---|
| 228 | { return elCol_(whichrow); }
|
---|
| 229 | float getAzimuth(int whichrow) const
|
---|
| 230 | { return azCol_(whichrow); }
|
---|
| 231 | float getParangle(int whichrow) const
|
---|
| 232 | { return paraCol_(whichrow); }
|
---|
[386] | 233 |
|
---|
[847] | 234 | std::vector<bool> getMask(int whichrow) const;
|
---|
| 235 | std::vector<float> getSpectrum(int whichrow) const;
|
---|
| 236 |
|
---|
[824] | 237 | std::vector<float> getStokesSpectrum( int whichrow=0,
|
---|
| 238 | bool dopol=false) const;
|
---|
| 239 | std::string getPolarizationLabel(bool linear, bool stokes,
|
---|
| 240 | bool linpol,
|
---|
| 241 | int polidx=-1) const;
|
---|
[401] | 242 |
|
---|
[845] | 243 | /**
|
---|
| 244 | * Write the Scantable to disk
|
---|
| 245 | * @param filename the output file name
|
---|
| 246 | */
|
---|
[824] | 247 | void makePersistent(const std::string& filename);
|
---|
[745] | 248 |
|
---|
[483] | 249 | std::vector<std::string> getHistory() const;
|
---|
| 250 | void addHistory(const std::string& hist);
|
---|
| 251 |
|
---|
[488] | 252 | casa::Table getHistoryTable() const;
|
---|
| 253 | void appendToHistoryTable(const casa::Table& otherHist);
|
---|
| 254 |
|
---|
[824] | 255 | std::string summary(bool verbose=false);
|
---|
| 256 | std::string getTime(int whichrow=-1, bool showdate=true) const;
|
---|
[19] | 257 |
|
---|
[847] | 258 | // returns unit, conversion frame, doppler, base-frame
|
---|
[18] | 259 |
|
---|
[847] | 260 | /**
|
---|
| 261 | * Get the frequency set up
|
---|
| 262 | * This is forwarded to the STFrequencies subtable
|
---|
| 263 | * @return unit, frame, doppler
|
---|
| 264 | */
|
---|
| 265 | std::vector<std::string> getCoordInfo() const
|
---|
| 266 | { return freqTable_.getInfo(); };
|
---|
| 267 |
|
---|
| 268 | void setCoordInfo(std::vector<string> theinfo)
|
---|
| 269 | { return freqTable_.setInfo(theinfo); };
|
---|
| 270 |
|
---|
| 271 | std::string getAbcissaLabel(int whichrow) const;
|
---|
| 272 | std::vector<double> getRestFrequencies() const
|
---|
| 273 | { return moleculeTable_.getRestFrequencies(); }
|
---|
| 274 |
|
---|
| 275 | void setRestFrequencies(double rf, const std::string& = "Hz");
|
---|
| 276 | void setRestFrequencies(const std::string& name);
|
---|
| 277 |
|
---|
[824] | 278 | STFrequencies& frequencies() { return freqTable_; }
|
---|
| 279 | STWeather& weather() { return weatherTable_; }
|
---|
| 280 | STFocus& focus() { return focusTable_; }
|
---|
| 281 | STTcal& tcal() { return tcalTable_; }
|
---|
| 282 | STMolecules& molecules() { return moleculeTable_; }
|
---|
[2] | 283 |
|
---|
[824] | 284 | private:
|
---|
| 285 | /**
|
---|
| 286 | * Turns a time vale into a formatted string
|
---|
| 287 | * @param x
|
---|
| 288 | * @return
|
---|
| 289 | */
|
---|
| 290 | std::string formatSec(casa::Double x) const;
|
---|
[18] | 291 |
|
---|
[824] | 292 | std::string formatTime(const casa::MEpoch& me, bool showdate)const;
|
---|
[22] | 293 |
|
---|
[824] | 294 | /**
|
---|
| 295 | * Turns a casa::MDirection into a nicely formatted string
|
---|
| 296 | * @param md an casa::MDirection
|
---|
| 297 | * @return
|
---|
| 298 | */
|
---|
| 299 | std::string formatDirection(const casa::MDirection& md) const;
|
---|
[19] | 300 |
|
---|
[286] | 301 |
|
---|
[824] | 302 | /**
|
---|
| 303 | * Create a unique file name for the paged (temporary) table
|
---|
| 304 | * @return just the name
|
---|
| 305 | */
|
---|
| 306 | static casa::String generateName();
|
---|
[286] | 307 |
|
---|
[824] | 308 | /**
|
---|
| 309 | * attach to cached columns
|
---|
| 310 | */
|
---|
| 311 | void attach();
|
---|
[50] | 312 |
|
---|
[824] | 313 | /**
|
---|
| 314 | * Set up the main casa::Table
|
---|
| 315 | */
|
---|
| 316 | void setupMainTable();
|
---|
[88] | 317 |
|
---|
[824] | 318 | void setupHistoryTable();
|
---|
| 319 | void setupMoleculeTable();
|
---|
| 320 | void setupFitTable();
|
---|
[212] | 321 |
|
---|
[824] | 322 | /**
|
---|
| 323 | * Convert an "old" asap1 style row index into a new index
|
---|
| 324 | * @param[in] therow
|
---|
| 325 | * @return and index into @table_
|
---|
| 326 | */
|
---|
| 327 | int rowToScanIndex(int therow);
|
---|
[212] | 328 |
|
---|
[824] | 329 | static const unsigned int version_ = 2;
|
---|
[286] | 330 |
|
---|
[824] | 331 | STSelector selector_;
|
---|
[236] | 332 |
|
---|
[824] | 333 | casa::Table::TableType type_;
|
---|
[465] | 334 |
|
---|
[824] | 335 | // the actual data
|
---|
| 336 | casa::Table table_;
|
---|
| 337 | casa::Table originalTable_;
|
---|
[745] | 338 |
|
---|
[824] | 339 | STTcal tcalTable_;
|
---|
| 340 | STFrequencies freqTable_;
|
---|
| 341 | STWeather weatherTable_;
|
---|
| 342 | STFocus focusTable_;
|
---|
| 343 | STMolecules moleculeTable_;
|
---|
| 344 | casa::Table fitTable_;
|
---|
| 345 | casa::Table historyTable_;
|
---|
[777] | 346 |
|
---|
[824] | 347 | // Cached Columns to avoid reconstructing them for each row get/put
|
---|
[847] | 348 | casa::ScalarColumn<casa::Double> integrCol_;
|
---|
[824] | 349 | casa::MDirection::ScalarColumn dirCol_;
|
---|
[847] | 350 | casa::MEpoch::ScalarColumn timeCol_;
|
---|
[824] | 351 | casa::ScalarColumn<casa::Double> azCol_;
|
---|
| 352 | casa::ScalarColumn<casa::Double> elCol_;
|
---|
| 353 | casa::ScalarColumn<casa::Float> paraCol_;
|
---|
| 354 | casa::ScalarColumn<casa::String> srcnCol_, fldnCol_;
|
---|
[847] | 355 | casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_;
|
---|
[824] | 356 | casa::ScalarColumn<casa::Int> rbeamCol_;
|
---|
| 357 | casa::ArrayColumn<casa::Float> specCol_, tsCol_;
|
---|
| 358 | casa::ArrayColumn<casa::uChar> flagsCol_;
|
---|
[430] | 359 |
|
---|
[824] | 360 | // id in frequencies table
|
---|
| 361 | casa::ScalarColumn<casa::uInt> mfreqidCol_;
|
---|
| 362 | // id in tcal table
|
---|
| 363 | casa::ScalarColumn<casa::uInt> mtcalidCol_;
|
---|
[430] | 364 |
|
---|
[824] | 365 | casa::ArrayColumn<casa::String> histitemCol_;
|
---|
| 366 | casa::ScalarColumn<casa::uInt> mfitidCol_, fitidCol_;
|
---|
| 367 | // id in weather table and main table
|
---|
| 368 | casa::ScalarColumn<casa::uInt> mweatheridCol_;
|
---|
[322] | 369 |
|
---|
[824] | 370 | casa::ScalarColumn<casa::uInt> mfocusidCol_;
|
---|
| 371 |
|
---|
| 372 | casa::ScalarColumn<casa::uInt> mmolidCol_;
|
---|
| 373 |
|
---|
[2] | 374 | };
|
---|
| 375 |
|
---|
[824] | 376 |
|
---|
| 377 | } // namespace
|
---|
| 378 |
|
---|
[2] | 379 | #endif
|
---|