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