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