[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 |
---|
[2186] | 16 | #include <fstream> |
---|
| 17 | #include <iostream> |
---|
| 18 | #include <sstream> |
---|
[2] | 19 | #include <string> |
---|
| 20 | #include <vector> |
---|
| 21 | // AIPS++ |
---|
[455] | 22 | #include <casa/aips.h> |
---|
[322] | 23 | #include <casa/Arrays/MaskedArray.h> |
---|
[2186] | 24 | #include <casa/Arrays/Vector.h> |
---|
[80] | 25 | #include <casa/BasicSL/String.h> |
---|
[2186] | 26 | #include <casa/Containers/Record.h> |
---|
| 27 | #include <casa/Exceptions/Error.h> |
---|
| 28 | #include <casa/Quanta/Quantum.h> |
---|
[824] | 29 | #include <casa/Utilities/CountedPtr.h> |
---|
| 30 | |
---|
[2186] | 31 | #include <coordinates/Coordinates/SpectralCoordinate.h> |
---|
[322] | 32 | |
---|
[824] | 33 | #include <measures/TableMeasures/ScalarMeasColumn.h> |
---|
| 34 | |
---|
[2186] | 35 | #include <scimath/Mathematics/FFTServer.h> |
---|
[1598] | 36 | |
---|
[2186] | 37 | #include <tables/Tables/ArrayColumn.h> |
---|
| 38 | #include <tables/Tables/ScalarColumn.h> |
---|
| 39 | #include <tables/Tables/Table.h> |
---|
[1819] | 40 | |
---|
[894] | 41 | #include "Logger.h" |
---|
[2186] | 42 | #include "MathUtils.h" |
---|
| 43 | #include "STFit.h" |
---|
| 44 | #include "STFitEntry.h" |
---|
| 45 | #include "STFitter.h" |
---|
| 46 | #include "STFocus.h" |
---|
| 47 | #include "STFrequencies.h" |
---|
[901] | 48 | #include "STHeader.h" |
---|
[2186] | 49 | #include "STHistory.h" |
---|
[824] | 50 | #include "STMolecules.h" |
---|
[2186] | 51 | #include "STPol.h" |
---|
[824] | 52 | #include "STSelector.h" |
---|
[2186] | 53 | #include "STTcal.h" |
---|
| 54 | #include "STWeather.h" |
---|
[2] | 55 | |
---|
[824] | 56 | namespace asap { |
---|
[2] | 57 | |
---|
[824] | 58 | /** |
---|
| 59 | * This class contains and wraps a casa::Table, which is used to store |
---|
| 60 | * all the information. This can be either a MemoryTable or a |
---|
| 61 | * disk based Table. |
---|
| 62 | * It provides access functions to the underlying table |
---|
| 63 | * It contains n subtables: |
---|
| 64 | * @li weather |
---|
| 65 | * @li frequencies |
---|
| 66 | * @li molecules |
---|
| 67 | * @li tcal |
---|
| 68 | * @li focus |
---|
| 69 | * @li fits |
---|
| 70 | * |
---|
| 71 | * @brief The main ASAP data container |
---|
| 72 | * @author Malte Marquarding |
---|
| 73 | * @date |
---|
| 74 | * @version |
---|
| 75 | */ |
---|
[890] | 76 | class Scantable : private Logger |
---|
[824] | 77 | { |
---|
[902] | 78 | |
---|
| 79 | friend class STMath; |
---|
| 80 | |
---|
[2] | 81 | public: |
---|
[824] | 82 | /** |
---|
| 83 | * Default constructor |
---|
| 84 | */ |
---|
[1350] | 85 | explicit Scantable(casa::Table::TableType ttype = casa::Table::Memory); |
---|
[19] | 86 | |
---|
[824] | 87 | /** |
---|
| 88 | * Create a Scantable object form an existing table on disk |
---|
| 89 | * @param[in] name the name of the existing Scantable |
---|
| 90 | */ |
---|
[1385] | 91 | explicit Scantable(const std::string& name, casa::Table::TableType ttype = casa::Table::Memory); |
---|
[2] | 92 | |
---|
[824] | 93 | /// @fixme this is only sensible for MemoryTables.... |
---|
| 94 | Scantable(const Scantable& other, bool clear=true); |
---|
[161] | 95 | |
---|
[824] | 96 | /** |
---|
| 97 | * Destructor |
---|
| 98 | */ |
---|
| 99 | virtual ~Scantable(); |
---|
[745] | 100 | |
---|
[824] | 101 | /** |
---|
| 102 | * get a const reference to the underlying casa::Table |
---|
[1104] | 103 | * @return const \ref casa::Table reference |
---|
[824] | 104 | */ |
---|
| 105 | const casa::Table& table() const; |
---|
[19] | 106 | |
---|
[824] | 107 | /** |
---|
| 108 | * get a reference to the underlying casa::Table with the Selection |
---|
| 109 | * object applied if set |
---|
| 110 | * @return casa::Table reference |
---|
| 111 | */ |
---|
| 112 | casa::Table& table(); |
---|
[21] | 113 | |
---|
[845] | 114 | |
---|
| 115 | /** |
---|
| 116 | * Get a handle to the selection object |
---|
| 117 | * @return constant STSelector reference |
---|
| 118 | */ |
---|
| 119 | const STSelector& getSelection() const { return selector_; } |
---|
| 120 | |
---|
| 121 | /** |
---|
| 122 | * Set the data to be a subset as defined by the STSelector |
---|
| 123 | * @param selection a STSelector object |
---|
| 124 | */ |
---|
[824] | 125 | void setSelection(const STSelector& selection); |
---|
[845] | 126 | |
---|
| 127 | /** |
---|
| 128 | * unset the selection of the data |
---|
| 129 | */ |
---|
[824] | 130 | void unsetSelection(); |
---|
| 131 | /** |
---|
| 132 | * set the header |
---|
[1295] | 133 | * @param[in] sth an STHeader object |
---|
[824] | 134 | */ |
---|
[901] | 135 | void setHeader( const STHeader& sth ); |
---|
[386] | 136 | |
---|
[824] | 137 | /** |
---|
| 138 | * get the header information |
---|
[901] | 139 | * @return an STHeader object |
---|
[824] | 140 | */ |
---|
[901] | 141 | STHeader getHeader( ) const; |
---|
[1068] | 142 | |
---|
[824] | 143 | /** |
---|
| 144 | * Checks if the "other" Scantable is conformant with this, |
---|
| 145 | * i.e. if header values are the same. |
---|
| 146 | * @param[in] other another Scantable |
---|
| 147 | * @return true or false |
---|
| 148 | */ |
---|
| 149 | bool conformant( const Scantable& other); |
---|
[430] | 150 | |
---|
[824] | 151 | /** |
---|
[1068] | 152 | * |
---|
| 153 | * @param stype The type of the source, 0 = on, 1 = off |
---|
| 154 | */ |
---|
| 155 | void setSourceType(int stype); |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | /** |
---|
[1104] | 159 | * The number of scans in the table |
---|
[824] | 160 | * @return number of scans in the table |
---|
| 161 | */ |
---|
[845] | 162 | int nscan() const; |
---|
[490] | 163 | |
---|
[915] | 164 | casa::MEpoch::Types getTimeReference() const; |
---|
[21] | 165 | |
---|
[1411] | 166 | |
---|
| 167 | casa::MEpoch getEpoch(int whichrow) const; |
---|
| 168 | |
---|
[824] | 169 | /** |
---|
| 170 | * Get global antenna position |
---|
[845] | 171 | * @return casa::MPosition |
---|
[824] | 172 | */ |
---|
| 173 | casa::MPosition getAntennaPosition() const; |
---|
[490] | 174 | |
---|
[1441] | 175 | /** |
---|
| 176 | * the @ref casa::MDirection for a specific row |
---|
| 177 | * @param[in] whichrow the row number |
---|
| 178 | * return casa::MDirection |
---|
| 179 | */ |
---|
[987] | 180 | casa::MDirection getDirection( int whichrow ) const; |
---|
[1598] | 181 | |
---|
[1441] | 182 | /** |
---|
| 183 | * get the direction type as a string, e.g. "J2000" |
---|
| 184 | * @param[in] whichrow the row number |
---|
| 185 | * return the direction string |
---|
| 186 | */ |
---|
[1068] | 187 | std::string getDirectionString( int whichrow ) const; |
---|
| 188 | |
---|
[1441] | 189 | /** |
---|
| 190 | * set the direction type as a string, e.g. "J2000" |
---|
| 191 | * @param[in] refstr the direction type |
---|
| 192 | */ |
---|
[987] | 193 | void setDirectionRefString(const std::string& refstr=""); |
---|
[1441] | 194 | |
---|
[1104] | 195 | /** |
---|
| 196 | * get the direction reference string |
---|
| 197 | * @return a string describing the direction reference |
---|
| 198 | */ |
---|
[1598] | 199 | std::string getDirectionRefString() const; |
---|
[987] | 200 | |
---|
[824] | 201 | /** |
---|
[845] | 202 | * Return the Flux unit of the data, e.g. "Jy" or "K" |
---|
| 203 | * @return string |
---|
[824] | 204 | */ |
---|
| 205 | std::string getFluxUnit() const; |
---|
[472] | 206 | |
---|
[824] | 207 | /** |
---|
[845] | 208 | * Set the Flux unit of the data |
---|
| 209 | * @param unit a string representing the unit, e.g "Jy" or "K" |
---|
[824] | 210 | */ |
---|
| 211 | void setFluxUnit( const std::string& unit ); |
---|
[472] | 212 | |
---|
[824] | 213 | /** |
---|
[1189] | 214 | * Set the Stokes type of the data |
---|
[1295] | 215 | * @param feedtype a string representing the type, e.g "circular" or "linear" |
---|
[1189] | 216 | */ |
---|
| 217 | void setFeedType( const std::string& feedtype ); |
---|
| 218 | |
---|
| 219 | /** |
---|
[824] | 220 | * |
---|
[845] | 221 | * @param instrument a string representing an insturment. see xxx |
---|
[824] | 222 | */ |
---|
| 223 | void setInstrument( const std::string& instrument ); |
---|
[2] | 224 | |
---|
[845] | 225 | /** |
---|
| 226 | * (Re)calculate the azimuth and elevationnfor all rows |
---|
| 227 | */ |
---|
[824] | 228 | void calculateAZEL(); |
---|
[745] | 229 | |
---|
[824] | 230 | /** |
---|
[845] | 231 | * "hard" flag the data, this flags everything selected in setSelection() |
---|
[1104] | 232 | * param[in] msk a boolean mask of length nchan describing the points to |
---|
| 233 | * to be flagged |
---|
[824] | 234 | */ |
---|
[1430] | 235 | //void flag( const std::vector<bool>& msk = std::vector<bool>()); |
---|
[1994] | 236 | //void flag( const std::vector<bool>& msk = std::vector<bool>(), bool unflag=false); |
---|
[455] | 237 | |
---|
[1994] | 238 | void flag( int whichrow = -1, const std::vector<bool>& msk = std::vector<bool>(), bool unflag=false); |
---|
| 239 | |
---|
[852] | 240 | /** |
---|
[1819] | 241 | * Flag the data in a row-based manner. (CAS-1433 Wataru Kawasaki) |
---|
| 242 | * param[in] rows list of row numbers to be flagged |
---|
| 243 | */ |
---|
| 244 | void flagRow( const std::vector<casa::uInt>& rows = std::vector<casa::uInt>(), bool unflag=false); |
---|
| 245 | |
---|
| 246 | /** |
---|
| 247 | * Get flagRow info at the specified row. If true, the whole data |
---|
| 248 | * at the row should be flagged. |
---|
| 249 | */ |
---|
| 250 | bool getFlagRow(int whichrow) const |
---|
| 251 | { return (flagrowCol_(whichrow) > 0); } |
---|
| 252 | |
---|
| 253 | /** |
---|
| 254 | * Flag the data outside a specified range (in a channel-based manner). |
---|
| 255 | * (CAS-1807 Wataru Kawasaki) |
---|
| 256 | */ |
---|
| 257 | void clip(const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag); |
---|
| 258 | |
---|
| 259 | /** |
---|
| 260 | * Return a list of booleans with the size of nchan for a specified row, to get info |
---|
| 261 | * about which channel is clipped. |
---|
| 262 | */ |
---|
| 263 | std::vector<bool> getClipMask(int whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag); |
---|
| 264 | void srchChannelsToClip(casa::uInt whichrow, const casa::Float uthres, const casa::Float dthres, bool clipoutside, bool unflag, |
---|
| 265 | casa::Vector<casa::uChar> flgs); |
---|
| 266 | |
---|
| 267 | /** |
---|
[852] | 268 | * Return a list of row numbers with respect to the original table. |
---|
[902] | 269 | * @return a list of unsigned ints |
---|
[852] | 270 | */ |
---|
| 271 | std::vector<unsigned int> rownumbers() const; |
---|
[845] | 272 | |
---|
[852] | 273 | |
---|
[845] | 274 | /** |
---|
| 275 | * Get the number of beams in the data or a specific scan |
---|
| 276 | * @param scanno the scan number to get the number of beams for. |
---|
| 277 | * If scanno<0 the number is retrieved from the header. |
---|
| 278 | * @return an integer number |
---|
| 279 | */ |
---|
[824] | 280 | int nbeam(int scanno=-1) const; |
---|
[845] | 281 | /** |
---|
| 282 | * Get the number of IFs in the data or a specific scan |
---|
| 283 | * @param scanno the scan number to get the number of IFs for. |
---|
| 284 | * If scanno<0 the number is retrieved from the header. |
---|
| 285 | * @return an integer number |
---|
| 286 | */ |
---|
[824] | 287 | int nif(int scanno=-1) const; |
---|
[845] | 288 | /** |
---|
| 289 | * Get the number of polarizations in the data or a specific scan |
---|
| 290 | * @param scanno the scan number to get the number of polarizations for. |
---|
| 291 | * If scanno<0 the number is retrieved from the header. |
---|
| 292 | * @return an integer number |
---|
| 293 | */ |
---|
[824] | 294 | int npol(int scanno=-1) const; |
---|
[794] | 295 | |
---|
[896] | 296 | std::string getPolType() const; |
---|
| 297 | |
---|
[845] | 298 | |
---|
| 299 | /** |
---|
| 300 | * Get the number of integartion cycles |
---|
| 301 | * @param scanno the scan number to get the number of rows for. |
---|
| 302 | * If scanno<0 the number is retrieved from the header. |
---|
[1104] | 303 | * @return the number of rows (for the specified scanno) |
---|
[845] | 304 | */ |
---|
[824] | 305 | int nrow(int scanno=-1) const; |
---|
[794] | 306 | |
---|
[1111] | 307 | int getBeam(int whichrow) const; |
---|
[1694] | 308 | std::vector<uint> getBeamNos() const { return getNumbers(beamCol_); } |
---|
[50] | 309 | |
---|
[847] | 310 | int getIF(int whichrow) const; |
---|
[1694] | 311 | std::vector<uint> getIFNos() const { return getNumbers(ifCol_); } |
---|
[1111] | 312 | |
---|
[847] | 313 | int getPol(int whichrow) const; |
---|
[1694] | 314 | std::vector<uint> getPolNos() const { return getNumbers(polCol_); } |
---|
[1111] | 315 | |
---|
[1694] | 316 | std::vector<uint> getScanNos() const { return getNumbers(scanCol_); } |
---|
[865] | 317 | int getScan(int whichrow) const { return scanCol_(whichrow); } |
---|
[1111] | 318 | |
---|
[1819] | 319 | //TT addition |
---|
| 320 | std::vector<uint> getMolNos() {return getNumbers(mmolidCol_); } |
---|
| 321 | |
---|
[1111] | 322 | /** |
---|
| 323 | * Get the number of channels in the data or a specific IF. This currently |
---|
| 324 | * varies only with IF number |
---|
| 325 | * @param ifno the IF number to get the number of channels for. |
---|
| 326 | * If ifno<0 the number is retrieved from the header. |
---|
| 327 | * @return an integer number |
---|
| 328 | */ |
---|
| 329 | int nchan(int ifno=-1) const; |
---|
[923] | 330 | int getChannels(int whichrow) const; |
---|
[206] | 331 | |
---|
[1111] | 332 | int ncycle(int scanno=-1) const; |
---|
| 333 | int getCycle(int whichrow) const { return cycleCol_(whichrow); } |
---|
| 334 | |
---|
[847] | 335 | double getInterval(int whichrow) const |
---|
| 336 | { return integrCol_(whichrow); } |
---|
[845] | 337 | |
---|
[865] | 338 | float getTsys(int whichrow) const |
---|
| 339 | { return casa::Vector<casa::Float>(tsysCol_(whichrow))(0); } |
---|
[2161] | 340 | std::vector<float> getTsysSpectrum(int whichrow) const ; |
---|
[847] | 341 | float getElevation(int whichrow) const |
---|
| 342 | { return elCol_(whichrow); } |
---|
| 343 | float getAzimuth(int whichrow) const |
---|
| 344 | { return azCol_(whichrow); } |
---|
[865] | 345 | float getParAngle(int whichrow) const |
---|
[1819] | 346 | { return focus().getParAngle(mfocusidCol_(whichrow)); } |
---|
| 347 | int getTcalId(int whichrow) const |
---|
| 348 | { return mtcalidCol_(whichrow); } |
---|
[386] | 349 | |
---|
[865] | 350 | std::string getSourceName(int whichrow) const |
---|
| 351 | { return srcnCol_(whichrow); } |
---|
| 352 | |
---|
[847] | 353 | std::vector<bool> getMask(int whichrow) const; |
---|
[896] | 354 | std::vector<float> getSpectrum(int whichrow, |
---|
[905] | 355 | const std::string& poltype = "" ) const; |
---|
[847] | 356 | |
---|
[884] | 357 | void setSpectrum(const std::vector<float>& spec, int whichrow); |
---|
| 358 | |
---|
[902] | 359 | std::string getPolarizationLabel(int index, const std::string& ptype) const |
---|
| 360 | { return STPol::getPolLabel(index, ptype ); } |
---|
[401] | 361 | |
---|
[845] | 362 | /** |
---|
| 363 | * Write the Scantable to disk |
---|
| 364 | * @param filename the output file name |
---|
| 365 | */ |
---|
[824] | 366 | void makePersistent(const std::string& filename); |
---|
[745] | 367 | |
---|
[860] | 368 | std::vector<std::string> getHistory() const |
---|
| 369 | { return historyTable_.getHistory(); }; |
---|
[483] | 370 | |
---|
[860] | 371 | void addHistory(const std::string& hist) { historyTable_.addEntry(hist); } |
---|
[488] | 372 | |
---|
[860] | 373 | void appendToHistoryTable(const STHistory& otherhist) |
---|
| 374 | { historyTable_.append(otherhist); } |
---|
| 375 | |
---|
[2163] | 376 | std::string headerSummary(); |
---|
[2286] | 377 | // std::string summary(); |
---|
| 378 | void summary(const std::string& filename=""); |
---|
[1947] | 379 | //std::string getTime(int whichrow=-1, bool showdate=true) const; |
---|
| 380 | std::string getTime(int whichrow=-1, bool showdate=true, casa::uInt prec=0) const; |
---|
[1350] | 381 | double getIntTime(int whichrow) const { return integrCol_(whichrow); } |
---|
[19] | 382 | |
---|
[847] | 383 | // returns unit, conversion frame, doppler, base-frame |
---|
[18] | 384 | |
---|
[847] | 385 | /** |
---|
| 386 | * Get the frequency set up |
---|
| 387 | * This is forwarded to the STFrequencies subtable |
---|
| 388 | * @return unit, frame, doppler |
---|
| 389 | */ |
---|
| 390 | std::vector<std::string> getCoordInfo() const |
---|
| 391 | { return freqTable_.getInfo(); }; |
---|
| 392 | |
---|
| 393 | void setCoordInfo(std::vector<string> theinfo) |
---|
| 394 | { return freqTable_.setInfo(theinfo); }; |
---|
| 395 | |
---|
[865] | 396 | |
---|
| 397 | std::vector<double> getAbcissa(int whichrow) const; |
---|
| 398 | |
---|
[1730] | 399 | std::vector<float> getWeather(int whichrow) const; |
---|
| 400 | |
---|
[847] | 401 | std::string getAbcissaLabel(int whichrow) const; |
---|
| 402 | std::vector<double> getRestFrequencies() const |
---|
| 403 | { return moleculeTable_.getRestFrequencies(); } |
---|
[1819] | 404 | std::vector<double> getRestFrequency(int id) const |
---|
| 405 | { return moleculeTable_.getRestFrequency(id); } |
---|
[847] | 406 | |
---|
[1819] | 407 | /** |
---|
[1170] | 408 | void setRestFrequencies(double rf, const std::string& name = "", |
---|
| 409 | const std::string& = "Hz"); |
---|
[1819] | 410 | **/ |
---|
| 411 | // Modified by Takeshi Nakazato 05/09/2008 |
---|
| 412 | /*** |
---|
| 413 | void setRestFrequencies(vector<double> rf, const vector<std::string>& name = "", |
---|
| 414 | const std::string& = "Hz"); |
---|
| 415 | ***/ |
---|
| 416 | void setRestFrequencies(vector<double> rf, |
---|
| 417 | const vector<std::string>& name = vector<std::string>(1,""), |
---|
| 418 | const std::string& = "Hz"); |
---|
[847] | 419 | |
---|
[1819] | 420 | //void setRestFrequencies(const std::string& name); |
---|
| 421 | void setRestFrequencies(const vector<std::string>& name); |
---|
| 422 | |
---|
[1360] | 423 | void shift(int npix); |
---|
| 424 | |
---|
[1598] | 425 | casa::SpectralCoordinate getSpectralCoordinate(int whichrow) const; |
---|
| 426 | |
---|
[987] | 427 | void convertDirection(const std::string& newframe); |
---|
| 428 | |
---|
[824] | 429 | STFrequencies& frequencies() { return freqTable_; } |
---|
[1375] | 430 | const STFrequencies& frequencies() const { return freqTable_; } |
---|
[824] | 431 | STWeather& weather() { return weatherTable_; } |
---|
[1375] | 432 | const STWeather& weather() const { return weatherTable_; } |
---|
[824] | 433 | STFocus& focus() { return focusTable_; } |
---|
[1375] | 434 | const STFocus& focus() const { return focusTable_; } |
---|
[824] | 435 | STTcal& tcal() { return tcalTable_; } |
---|
[1375] | 436 | const STTcal& tcal() const { return tcalTable_; } |
---|
[824] | 437 | STMolecules& molecules() { return moleculeTable_; } |
---|
[1375] | 438 | const STMolecules& molecules() const { return moleculeTable_; } |
---|
[860] | 439 | STHistory& history() { return historyTable_; } |
---|
[1375] | 440 | const STHistory& history() const { return historyTable_; } |
---|
[972] | 441 | STFit& fit() { return fitTable_; } |
---|
[1375] | 442 | const STFit& fit() const { return fitTable_; } |
---|
[2] | 443 | |
---|
[902] | 444 | std::vector<std::string> columnNames() const; |
---|
[896] | 445 | |
---|
[972] | 446 | void addFit(const STFitEntry& fit, int row); |
---|
| 447 | STFitEntry getFit(int row) const |
---|
| 448 | { STFitEntry fe; fitTable_.getEntry(fe, mfitidCol_(row)); return fe; } |
---|
| 449 | |
---|
[1391] | 450 | //Added by TT |
---|
| 451 | /** |
---|
| 452 | * Get the antenna name |
---|
| 453 | * @return antenna name string |
---|
| 454 | */ |
---|
[1819] | 455 | casa::String getAntennaName() const; |
---|
[1391] | 456 | |
---|
| 457 | /** |
---|
| 458 | * For GBT MS data only. check a scan list |
---|
| 459 | * against the information found in GBT_GO table for |
---|
| 460 | * scan number orders to get correct pairs. |
---|
| 461 | * @param[in] scan list |
---|
| 462 | * @return status |
---|
| 463 | */ |
---|
| 464 | int checkScanInfo(const std::vector<int>& scanlist) const; |
---|
| 465 | |
---|
| 466 | /** |
---|
| 467 | * Get the direction as a vector, for a specific row |
---|
| 468 | * @param[in] whichrow the row numbyyer |
---|
| 469 | * @return the direction in a vector |
---|
| 470 | */ |
---|
| 471 | std::vector<double> getDirectionVector(int whichrow) const; |
---|
| 472 | |
---|
[1586] | 473 | /** |
---|
| 474 | * Set a flag indicating whether the data was parallactified |
---|
| 475 | * @param[in] flag true or false |
---|
| 476 | */ |
---|
[1598] | 477 | void parallactify(bool flag) |
---|
[1727] | 478 | { focus().setParallactify(flag); } |
---|
| 479 | |
---|
[1819] | 480 | /** |
---|
| 481 | * Reshape spectrum |
---|
| 482 | * @param[in] nmin, nmax minimum and maximum channel |
---|
| 483 | * @param[in] irow row number |
---|
| 484 | * |
---|
| 485 | * 30/07/2008 Takeshi Nakazato |
---|
| 486 | **/ |
---|
| 487 | void reshapeSpectrum( int nmin, int nmax ) throw( casa::AipsError ); |
---|
| 488 | void reshapeSpectrum( int nmin, int nmax, int irow ) ; |
---|
| 489 | |
---|
| 490 | /** |
---|
| 491 | * Change channel number under fixed bandwidth |
---|
| 492 | * @param[in] nchan, dnu new channel number and spectral resolution |
---|
| 493 | * @param[in] irow row number |
---|
| 494 | * |
---|
| 495 | * 27/08/2008 Takeshi Nakazato |
---|
| 496 | **/ |
---|
| 497 | void regridChannel( int nchan, double dnu ) ; |
---|
| 498 | void regridChannel( int nchan, double dnu, int irow ) ; |
---|
| 499 | |
---|
[2047] | 500 | bool getFlagtraFast(casa::uInt whichrow); |
---|
[1819] | 501 | |
---|
[2012] | 502 | void polyBaseline(const std::vector<bool>& mask, |
---|
| 503 | int order, |
---|
[2094] | 504 | bool getResidual=true, |
---|
[2189] | 505 | const std::string& progressInfo="true,1000", |
---|
| 506 | const bool outLogger=false, |
---|
[2012] | 507 | const std::string& blfile=""); |
---|
| 508 | void autoPolyBaseline(const std::vector<bool>& mask, |
---|
| 509 | int order, |
---|
| 510 | const std::vector<int>& edge, |
---|
| 511 | float threshold=3.0, |
---|
| 512 | int chanAvgLimit=1, |
---|
[2094] | 513 | bool getResidual=true, |
---|
[2189] | 514 | const std::string& progressInfo="true,1000", |
---|
| 515 | const bool outLogger=false, |
---|
[2012] | 516 | const std::string& blfile=""); |
---|
| 517 | void cubicSplineBaseline(const std::vector<bool>& mask, |
---|
| 518 | int nPiece, |
---|
| 519 | float thresClip, |
---|
| 520 | int nIterClip, |
---|
[2094] | 521 | bool getResidual=true, |
---|
[2189] | 522 | const std::string& progressInfo="true,1000", |
---|
| 523 | const bool outLogger=false, |
---|
[2012] | 524 | const std::string& blfile=""); |
---|
| 525 | void autoCubicSplineBaseline(const std::vector<bool>& mask, |
---|
| 526 | int nPiece, |
---|
| 527 | float thresClip, |
---|
| 528 | int nIterClip, |
---|
| 529 | const std::vector<int>& edge, |
---|
| 530 | float threshold=3.0, |
---|
| 531 | int chanAvgLimit=1, |
---|
[2094] | 532 | bool getResidual=true, |
---|
[2189] | 533 | const std::string& progressInfo="true,1000", |
---|
| 534 | const bool outLogger=false, |
---|
[2012] | 535 | const std::string& blfile=""); |
---|
[2047] | 536 | void sinusoidBaseline(const std::vector<bool>& mask, |
---|
[2186] | 537 | const bool applyFFT, |
---|
| 538 | const std::string& fftMethod, |
---|
| 539 | const std::string& fftThresh, |
---|
| 540 | const std::vector<int>& addNWaves, |
---|
| 541 | const std::vector<int>& rejectNWaves, |
---|
[2047] | 542 | float thresClip, |
---|
| 543 | int nIterClip, |
---|
[2081] | 544 | bool getResidual=true, |
---|
[2189] | 545 | const std::string& progressInfo="true,1000", |
---|
| 546 | const bool outLogger=false, |
---|
[2047] | 547 | const std::string& blfile=""); |
---|
| 548 | void autoSinusoidBaseline(const std::vector<bool>& mask, |
---|
[2186] | 549 | const bool applyFFT, |
---|
| 550 | const std::string& fftMethod, |
---|
| 551 | const std::string& fftThresh, |
---|
| 552 | const std::vector<int>& addNWaves, |
---|
| 553 | const std::vector<int>& rejectNWaves, |
---|
[2047] | 554 | float thresClip, |
---|
| 555 | int nIterClip, |
---|
| 556 | const std::vector<int>& edge, |
---|
| 557 | float threshold=3.0, |
---|
| 558 | int chanAvgLimit=1, |
---|
[2081] | 559 | bool getResidual=true, |
---|
[2189] | 560 | const std::string& progressInfo="true,1000", |
---|
| 561 | const bool outLogger=false, |
---|
[2047] | 562 | const std::string& blfile=""); |
---|
[2186] | 563 | std::vector<float> execFFT(const int whichrow, |
---|
| 564 | const std::vector<bool>& inMask, |
---|
| 565 | bool getRealImag=false, |
---|
| 566 | bool getAmplitudeOnly=false); |
---|
[2012] | 567 | float getRms(const std::vector<bool>& mask, int whichrow); |
---|
| 568 | std::string formatBaselineParams(const std::vector<float>& params, |
---|
| 569 | const std::vector<bool>& fixed, |
---|
| 570 | float rms, |
---|
[2193] | 571 | int nClipped, |
---|
[2012] | 572 | const std::string& masklist, |
---|
| 573 | int whichrow, |
---|
[2064] | 574 | bool verbose=false, |
---|
| 575 | int start=-1, |
---|
| 576 | int count=-1, |
---|
| 577 | bool resetparamid=false) const; |
---|
[2012] | 578 | std::string formatPiecewiseBaselineParams(const std::vector<int>& ranges, |
---|
| 579 | const std::vector<float>& params, |
---|
| 580 | const std::vector<bool>& fixed, |
---|
| 581 | float rms, |
---|
[2193] | 582 | int nClipped, |
---|
[2012] | 583 | const std::string& masklist, |
---|
| 584 | int whichrow, |
---|
| 585 | bool verbose=false) const; |
---|
[1907] | 586 | |
---|
[2012] | 587 | |
---|
[824] | 588 | private: |
---|
[896] | 589 | |
---|
| 590 | casa::Matrix<casa::Float> getPolMatrix( casa::uInt whichrow ) const; |
---|
| 591 | |
---|
[824] | 592 | /** |
---|
[2005] | 593 | * Turns a time value into a formatted string |
---|
[824] | 594 | * @param x |
---|
| 595 | * @return |
---|
| 596 | */ |
---|
| 597 | std::string formatSec(casa::Double x) const; |
---|
[18] | 598 | |
---|
[824] | 599 | std::string formatTime(const casa::MEpoch& me, bool showdate)const; |
---|
[1947] | 600 | std::string formatTime(const casa::MEpoch& me, bool showdate, casa::uInt prec)const; |
---|
[22] | 601 | |
---|
[824] | 602 | /** |
---|
| 603 | * Turns a casa::MDirection into a nicely formatted string |
---|
| 604 | * @param md an casa::MDirection |
---|
| 605 | * @return |
---|
| 606 | */ |
---|
| 607 | std::string formatDirection(const casa::MDirection& md) const; |
---|
[19] | 608 | |
---|
[824] | 609 | /** |
---|
| 610 | * Create a unique file name for the paged (temporary) table |
---|
| 611 | * @return just the name |
---|
| 612 | */ |
---|
| 613 | static casa::String generateName(); |
---|
[286] | 614 | |
---|
[824] | 615 | /** |
---|
| 616 | * attach to cached columns |
---|
| 617 | */ |
---|
| 618 | void attach(); |
---|
[50] | 619 | |
---|
[824] | 620 | /** |
---|
| 621 | * Set up the main casa::Table |
---|
| 622 | */ |
---|
| 623 | void setupMainTable(); |
---|
[88] | 624 | |
---|
[859] | 625 | void attachSubtables(); |
---|
[865] | 626 | void copySubtables(const Scantable& other); |
---|
| 627 | |
---|
[824] | 628 | /** |
---|
| 629 | * Convert an "old" asap1 style row index into a new index |
---|
| 630 | * @param[in] therow |
---|
| 631 | * @return and index into @table_ |
---|
| 632 | */ |
---|
| 633 | int rowToScanIndex(int therow); |
---|
[212] | 634 | |
---|
[1694] | 635 | std::vector<uint> getNumbers(const casa::ScalarColumn<casa::uInt>& col) const; |
---|
[1111] | 636 | |
---|
[1586] | 637 | static const casa::uInt version_ = 3; |
---|
[286] | 638 | |
---|
[824] | 639 | STSelector selector_; |
---|
[236] | 640 | |
---|
[824] | 641 | casa::Table::TableType type_; |
---|
[465] | 642 | |
---|
[824] | 643 | // the actual data |
---|
| 644 | casa::Table table_; |
---|
| 645 | casa::Table originalTable_; |
---|
[745] | 646 | |
---|
[824] | 647 | STTcal tcalTable_; |
---|
| 648 | STFrequencies freqTable_; |
---|
| 649 | STWeather weatherTable_; |
---|
| 650 | STFocus focusTable_; |
---|
| 651 | STMolecules moleculeTable_; |
---|
[860] | 652 | STHistory historyTable_; |
---|
[960] | 653 | STFit fitTable_; |
---|
[860] | 654 | |
---|
[824] | 655 | // Cached Columns to avoid reconstructing them for each row get/put |
---|
[847] | 656 | casa::ScalarColumn<casa::Double> integrCol_; |
---|
[824] | 657 | casa::MDirection::ScalarColumn dirCol_; |
---|
[847] | 658 | casa::MEpoch::ScalarColumn timeCol_; |
---|
[923] | 659 | casa::ScalarColumn<casa::Float> azCol_; |
---|
| 660 | casa::ScalarColumn<casa::Float> elCol_; |
---|
[824] | 661 | casa::ScalarColumn<casa::String> srcnCol_, fldnCol_; |
---|
[1819] | 662 | casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_, flagrowCol_; |
---|
[1068] | 663 | casa::ScalarColumn<casa::Int> rbeamCol_, srctCol_; |
---|
[865] | 664 | casa::ArrayColumn<casa::Float> specCol_, tsysCol_; |
---|
[824] | 665 | casa::ArrayColumn<casa::uChar> flagsCol_; |
---|
[430] | 666 | |
---|
[824] | 667 | // id in frequencies table |
---|
| 668 | casa::ScalarColumn<casa::uInt> mfreqidCol_; |
---|
| 669 | // id in tcal table |
---|
| 670 | casa::ScalarColumn<casa::uInt> mtcalidCol_; |
---|
[430] | 671 | |
---|
[824] | 672 | casa::ArrayColumn<casa::String> histitemCol_; |
---|
[972] | 673 | casa::ScalarColumn<casa::Int> mfitidCol_; |
---|
[824] | 674 | casa::ScalarColumn<casa::uInt> mweatheridCol_; |
---|
[322] | 675 | |
---|
[824] | 676 | casa::ScalarColumn<casa::uInt> mfocusidCol_; |
---|
| 677 | |
---|
| 678 | casa::ScalarColumn<casa::uInt> mmolidCol_; |
---|
| 679 | |
---|
[896] | 680 | static std::map<std::string, STPol::STPolFactory *> factories_; |
---|
| 681 | void initFactories(); |
---|
| 682 | |
---|
[1819] | 683 | /** |
---|
| 684 | * Add an auxiliary column to the main table and attach it to a |
---|
| 685 | * cached column. Use for adding new columns that the original asap2 |
---|
| 686 | * tables do not have. |
---|
| 687 | * @param[in] col reference to the cached column to be attached |
---|
| 688 | * @param[in] colName column name in asap table |
---|
| 689 | * @param[in] defValue default value to fill in the column |
---|
| 690 | * |
---|
| 691 | * 25/10/2009 Wataru Kawasaki |
---|
| 692 | */ |
---|
| 693 | template<class T, class T2> void attachAuxColumnDef(casa::ScalarColumn<T>&, |
---|
| 694 | const casa::String&, |
---|
| 695 | const T2&); |
---|
| 696 | template<class T, class T2> void attachAuxColumnDef(casa::ArrayColumn<T>&, |
---|
| 697 | const casa::String&, |
---|
| 698 | const casa::Array<T2>&); |
---|
[1907] | 699 | |
---|
[2012] | 700 | void fitBaseline(const std::vector<bool>& mask, int whichrow, Fitter& fitter); |
---|
| 701 | std::vector<float> doCubicSplineFitting(const std::vector<float>& data, |
---|
| 702 | const std::vector<bool>& mask, |
---|
[2081] | 703 | int nPiece, |
---|
[2064] | 704 | std::vector<int>& idxEdge, |
---|
[2012] | 705 | std::vector<float>& params, |
---|
[2193] | 706 | int& nClipped, |
---|
[2012] | 707 | float thresClip=3.0, |
---|
[2058] | 708 | int nIterClip=1, |
---|
[2094] | 709 | bool getResidual=true); |
---|
[2047] | 710 | std::vector<float> doSinusoidFitting(const std::vector<float>& data, |
---|
| 711 | const std::vector<bool>& mask, |
---|
[2081] | 712 | const std::vector<int>& waveNumbers, |
---|
[2047] | 713 | std::vector<float>& params, |
---|
[2193] | 714 | int& nClipped, |
---|
[2047] | 715 | float thresClip=3.0, |
---|
[2058] | 716 | int nIterClip=1, |
---|
[2094] | 717 | bool getResidual=true); |
---|
[2186] | 718 | void selectWaveNumbers(const int whichrow, |
---|
| 719 | const std::vector<bool>& chanMask, |
---|
| 720 | const bool applyFFT, |
---|
| 721 | const std::string& fftMethod, |
---|
| 722 | const std::string& fftThresh, |
---|
| 723 | const std::vector<int>& addNWaves, |
---|
| 724 | const std::vector<int>& rejectNWaves, |
---|
| 725 | std::vector<int>& nWaves); |
---|
| 726 | void parseThresholdExpression(const std::string& fftThresh, |
---|
| 727 | std::string& fftThAttr, |
---|
| 728 | float& fftThSigma, |
---|
| 729 | int& fftThTop); |
---|
| 730 | void doSelectWaveNumbers(const int whichrow, |
---|
| 731 | const std::vector<bool>& chanMask, |
---|
| 732 | const std::string& fftMethod, |
---|
| 733 | const float fftThSigma, |
---|
| 734 | const int fftThTop, |
---|
| 735 | const std::string& fftThAttr, |
---|
| 736 | std::vector<int>& nWaves); |
---|
| 737 | void addAuxWaveNumbers(const std::vector<int>& addNWaves, |
---|
| 738 | const std::vector<int>& rejectNWaves, |
---|
| 739 | std::vector<int>& nWaves); |
---|
[2012] | 740 | bool hasSameNchanOverIFs(); |
---|
| 741 | std::string getMaskRangeList(const std::vector<bool>& mask, |
---|
| 742 | int whichrow, |
---|
| 743 | const casa::String& coordInfo, |
---|
[2047] | 744 | bool hasSameNchan, |
---|
| 745 | bool verbose=false); |
---|
| 746 | std::vector<int> getMaskEdgeIndices(const std::vector<bool>& mask); |
---|
[2012] | 747 | std::string formatBaselineParamsHeader(int whichrow, const std::string& masklist, bool verbose) const; |
---|
[2193] | 748 | std::string formatBaselineParamsFooter(float rms, int nClipped, bool verbose) const; |
---|
[2012] | 749 | std::vector<bool> getCompositeChanMask(int whichrow, const std::vector<bool>& inMask); |
---|
| 750 | //std::vector<bool> getCompositeChanMask(int whichrow, const std::vector<bool>& inMask, const std::vector<int>& edge, const int minEdgeSize, STLineFinder& lineFinder); |
---|
[2047] | 751 | void outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, Fitter& fitter); |
---|
[2193] | 752 | void outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, const std::vector<int>& edge, const std::vector<float>& params, const int nClipped); |
---|
| 753 | void outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, const std::vector<float>& params, const int nClipped); |
---|
[2189] | 754 | void parseProgressInfo(const std::string& progressInfo, bool& showProgress, int& minNRow); |
---|
| 755 | void showProgressOnTerminal(const int nProcessed, const int nTotal, const bool showProgress=true, const int nTotalThreshold=1000); |
---|
[1994] | 756 | |
---|
| 757 | void applyChanFlag( casa::uInt whichrow, const std::vector<bool>& msk, casa::uChar flagval); |
---|
| 758 | |
---|
| 759 | |
---|
[2] | 760 | }; |
---|
| 761 | |
---|
[824] | 762 | } // namespace |
---|
| 763 | |
---|
[2] | 764 | #endif |
---|