source: trunk/src/STSideBandSep.h @ 2852

Last change on this file since 2852 was 2852, checked in by Kana Sugimoto, 11 years ago

New Development: Yes

JIRA Issue: Yes (CAS-5139/TRAC-290)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: A couple of private functions are added to STSideBandSep class.

Test Programs:

Put in Release Notes: Yes

Module(s): asap.sbseparator

Description: Implemented a way to transfer channel based flag of imput tables to output tables. Channel flag is accumulated by logical SUM.


File size: 5.4 KB
Line 
1// C++ Interface: STSideBandSep
2//
3// Description:
4//    A class to invoke sideband separation of Scantable
5//
6// Author: Kanako Sugimoto <kana.sugi@nao.ac.jp>, (C) 2012
7//
8// Copyright: See COPYING file that comes with this distribution
9//
10//
11#ifndef ASAPSIDEBANDSEP_H
12#define ASAPSIDEBANDSEP_H
13
14// STL
15#include <iostream>
16#include <string>
17#include <vector>
18// casacore
19#include <casa/aips.h>
20#include <casa/Utilities/CountedPtr.h>
21#include <measures/Measures/MDirection.h>
22#include <coordinates/Coordinates/DirectionCoordinate.h>
23#include <coordinates/Coordinates/SpectralCoordinate.h>
24#include <scimath/Mathematics/FFTServer.h>
25// asap
26#include "ScantableWrapper.h"
27#include "Scantable.h"
28
29using namespace std;
30using namespace casa;
31
32namespace asap {
33
34class STSideBandSep {
35public:
36  /**
37   * constructors and a destructor
38   **/
39  STSideBandSep() { throw( AipsError("No data set to process") ); };
40  explicit STSideBandSep(const vector<string> &names);
41  explicit STSideBandSep(const vector<ScantableWrapper> &tables);
42  virtual ~STSideBandSep();
43
44
45  /**
46   * Separate side bands
47   **/
48  void separate(string outname);
49
50  /**
51   * Set IFNO and frequency tolerance to select data to process
52   **/
53  void setFrequency(const unsigned int ifno, const string freqtol,
54                    const string frame="");
55
56  /**
57   * Set direction tolerance to group spectra.
58   * The spectra within this range will be averaged before procesing.
59   **/
60  void setDirTolerance(const vector<string> dirtol);
61
62  /**
63   * Set the number of channels shifted in image side band
64   * of each of scantable.
65   **/
66  void setShift(const vector<double> &shift);
67
68  /**
69   * Set rejection limit of solution.
70   **/
71  void setThreshold(const double limit);
72
73  /**
74   * Resolve both image and signal sideband when true is set.
75   **/
76  void solveBoth(const bool flag) { doboth_ = flag; };
77
78  /**
79   * Obtain spectra by subtracting the solution of the other sideband.
80   **/
81  void solvefromOther(const bool flag) { otherside_ = flag; };
82
83  /**
84   * Set scantable to fill frequencies of image sideband (temporal)
85   **/
86  void setImageTable(const ScantableWrapper &s);
87  void setScanTb0(const ScantableWrapper &s);
88
89  /**
90   * Set additional information to fill frequencies of image sideband
91   **/
92  void setLO1(const string lo1, const string frame="TOPO",
93              const double reftime=-1, string refdir="");
94  void setLO1Root(const string name);
95
96private:
97  /** Initialize member variables **/
98  void init();
99  void initshift();
100
101  /** Return if the path exists (optionally, check file type) **/
102  Bool checkFile(const string name, string type="");
103
104  /** **/
105  unsigned int setupShift();
106  bool getFreqInfo(const CountedPtr<Scantable> &stab, const unsigned int &ifno,
107                   double &freq0, double &incr, unsigned int &nchan);
108
109  /** Grid scantable **/
110  ScantableWrapper gridTable();
111  void mapExtent(vector< CountedPtr<Scantable> > &tablist,
112                 Double &xmin, Double &xmax,
113                 Double &ymin, Double &ymax);
114
115  /**
116   * Actual calculation of frequencies of image sideband
117   **/
118  void solveImageFrequency();
119
120  /**
121   * Get LO1 frequency to solve the frequencies of image side band
122   **/
123  bool getLo1FromAsdm(const string asdmname,
124                      const double refval, const double refpix,
125                      const double increment, const int nChan);
126  bool getLo1FromAsisTab(const string msname,
127                         const double refval, const double refpix,
128                         const double increment, const int nChan);
129  bool getLo1FromScanTab(casa::CountedPtr< Scantable > &scantab,
130                         const double refval, const double refpix,
131                         const double increment, const int nChan);
132  //  bool getSpectraToSolve(const int polId, const int beamId,
133  //                     const double dirX, const double dirY,
134  //                     Matrix<float> &specmat, vector<uInt> &tabIdvec);
135  bool getSpectraToSolve(const int polId, const int beamId,
136                         const double dirX, const double dirY,
137                         Matrix<float> &specMat, Matrix<bool> &flagMat,
138                         vector<uInt> &tabIdvec);
139
140  vector<float> solve(const Matrix<float> &specMat,
141                      const vector<uInt> &tabIdvec,
142                      const bool signal = true);
143
144  Vector<bool> collapseFlag(const Matrix<bool> &flagMat,
145                            const vector<uInt> &tabIdvec,
146                            const bool signal = true);
147
148  void shiftSpectrum(const Vector<float> &invec, double shift,
149                     Vector<float> &outvec);
150
151  void shiftFlag(const Vector<bool> &invec, double shift,
152                     Vector<bool> &outvec);
153
154  void deconvolve(Matrix<float> &specmat, const vector<double> shiftvec,
155                  const double threshold, Matrix<float> &outmat);
156
157  void aggregateMat(Matrix<float> &inmat, vector<float> &outvec);
158
159  void subtractFromOther(const Matrix<float> &shiftmat,
160                         const vector<float> &invec,
161                         const vector<double> &shift,
162                         vector<float> &outvec);
163
164
165
166  /** Member variables **/
167  // input tables
168  vector<string> infileList_;
169  vector< CountedPtr<Scantable> > intabList_;
170  unsigned int ntable_;
171  // frequency and direction setup to select data.
172  int sigIfno_;
173  Quantum<Double> ftol_;
174  MFrequency::Types solFrame_;
175  vector<double> sigShift_, imgShift_;
176  unsigned int nshift_, nchan_;
177  vector< CountedPtr<Scantable> > tableList_;
178  Double xtol_, ytol_;
179  // solution parameters
180  bool otherside_, doboth_;
181  double rejlimit_;
182  // LO1
183  double lo1Freq_; // in Hz
184  MFrequency::Types loFrame_;
185  double loTime_;
186  string loDir_;
187  string asdmName_, asisName_;
188
189  //CountedPtr<Scantable> imgTab_p, sigTab_p;
190  CountedPtr<Scantable> imgTab_p, sigTab_p;
191  Table::TableType tp_;
192  FFTServer<Float, Complex> fftsf, fftsi;
193
194}; // class
195
196} // namespace
197
198#endif
Note: See TracBrowser for help on using the repository browser.