source: trunk/src/Scantable.h@ 2730

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

New Development: Yes

JIRA Issue: Yes CAS-3618

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: new method for scantable to calculate AIC, AICc, BIC and GCV.


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