source: trunk/src/Scantable.h@ 2767

Last change on this file since 2767 was 2767, checked in by WataruKawasaki, 12 years ago

New Development: Yes

JIRA Issue: Yes CAS-4794

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: functions to apply/write STBaselineTable in which baseline parameters stored.


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