casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SideBandSeparator.h
Go to the documentation of this file.
1 /*
2  * SideBandSeparator.h
3  *
4  * Created on: 2017/07/19
5  * Author: kana
6  */
7 
8 #ifndef SIDEBANDSEPARATOR_H_
9 #define SIDEBANDSEPARATOR_H_
10 // STL
11 #include <iostream>
12 #include <string>
13 #include <vector>
14 // casacore
15 #include <casacore/casa/aips.h>
19 
24 
25 // casa
27 
28 namespace casa { //# NAMESPACE CASA - BEGIN
29 
36 public:
37 
44  SideBandSeparatorBase(const std::vector<std::string>& inputname);
48  virtual ~SideBandSeparatorBase();
49 
58  void setShift(const std::vector<double> &shift, const bool signal = true);
59 
65  void setThreshold(const double limit);
66 
74  void solveBoth(const bool flag) { doboth_ = flag; };
75 
85  void solvefromOther(const bool flag) { otherside_ = flag; };
86 
98  virtual void separate(const std::string& outfile, const bool overwrite) = 0;
99 
100 protected:
102  void init();
103  void initshift();
104 
105  void setInput(const std::vector<std::string>& inputname);
106 
108  casacore::Bool checkFile(const std::string name, std::string type="");
109 
111  const std::vector<casacore::uInt> &inIdvec,
112  const bool signal = true);
113 
115  const std::vector<casacore::uInt> &inIdvec,
116  const bool signal = true);
117  void shiftSpectrum(const casacore::Vector<float> &invec, double shift,
118  casacore::Vector<float> &outvec);
119 
120  void shiftFlag(const casacore::Vector<bool> &invec, double shift,
121  casacore::Vector<bool> &outvec);
122 
123  void deconvolve(casacore::Matrix<float> &specmat, const std::vector<double> shiftvec,
124  const double threshold, casacore::Matrix<float> &outmat);
125 
126  void aggregateMat(const casacore::Matrix<float> &inmat, std::vector<float> &outvec);
127 
128  void subtractFromOther(const casacore::Matrix<float> &shiftmat,
129  const std::vector<float> &invec,
130  const std::vector<double> &shift,
131  std::vector<float> &outvec);
133  size_t setupShift();
134 
135  /*
136  * Interpolate masked spectrum channels
137  * In-place interpolation is performed to elements with mask being false.
138  * This function interpolates masked channels in the following rules.
139  * o nearest interpolation for edge channels
140  * o linear interpolation for intermediate masked ranges
141  *
142  * @param[inout] spectrum an 1-D array to be interpolated (in-place).
143  * the number of elements should be equal to that of @a mask.
144  * @param[in] mask an 1-D mask array. the elements in spectrum is valid
145  * when corresponding elements in mask is true.
146  * the number of elements should be equal to that of @a spectrum.
147  *
148  * the function returns false if no valid channel (mask is all false)
149  */
151  const casacore::Array<bool> maskp);
152 
154  // name of images
155  std::vector<std::string> inputNames_;
156  // frequency and direction setup to select data.
157  std::vector<double> sigShift_, imgShift_;
158  unsigned int nshift_, nchan_;
159  // solution parameters
161  double rejlimit_;
162 
164 
165 
166 }; // SideBandSeparatorBase
167 
174 public:
181  SideBandSeparatorII(const std::vector<std::string>& imagename);
185  virtual ~SideBandSeparatorII(){};
186 
196  virtual void separate(const std::string& outfile, const bool overwrite);
197 
204  void setImageBandFrequency(const double refpix, const casacore::Quantity refval);
205 
206  //protected:
207 private:
208  void initLocal();
209  void checkImage();
210 
211  bool getImageCoordinate(const string& imagename, casacore::CoordinateSystem &csys, casacore::IPosition &npix);
212  bool compareImageAxes(const string& imagename, const casacore::CoordinateSystem &refcsys, const casacore::IPosition &refnpix);
213  bool getSpectraToSolve(const std::vector<casa::SPIIF> &images, const casacore::Slicer &slicer,
214  casacore::Matrix<float>& specMat, casacore::Matrix<bool>& maskMat, std::vector<casacore::uInt>& imgIdvec);
216 
217 };
218 
219 
220 } //# NAMESPACE CASA - END
221 #endif /* SIDEBANDSEPARATOR_H_ */
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
void initLocal()
protected:
casacore::Bool checkFile(const std::string name, std::string type="")
Return if the path exists (optionally, check file type)
std::vector< double > imgShift_
void solveBoth(const bool flag)
Resolve both image and signal sideband when true is set.
bool otherside_
solution parameters
void shiftSpectrum(const casacore::Vector< float > &invec, double shift, casacore::Vector< float > &outvec)
void setInput(const std::vector< std::string > &inputname)
std::vector< std::string > inputNames_
Member variables.
SideBandSeparatorBase(const std::vector< std::string > &inputname)
The constructor.
casacore::Vector< bool > collapseMask(const casacore::Matrix< bool > &flagMat, const std::vector< casacore::uInt > &inIdvec, const bool signal=true)
virtual Type type()
Return the type enum.
bool getSpectraToSolve(const std::vector< casa::SPIIF > &images, const casacore::Slicer &slicer, casacore::Matrix< float > &specMat, casacore::Matrix< bool > &maskMat, std::vector< casacore::uInt > &imgIdvec)
casacore::FFTServer< casacore::Float, casacore::Complex > fftsi
A 2-D Specialization of the Array class.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
casacore::Vector< float > solve(const casacore::Matrix< float > &specMat, const std::vector< casacore::uInt > &inIdvec, const bool signal=true)
std::vector< double > sigShift_
frequency and direction setup to select data.
void solvefromOther(const bool flag)
Obtain spectra by subtracting the solution of the other sideband.
Data model dependent side band separator class.
bool compareImageAxes(const string &imagename, const casacore::CoordinateSystem &refcsys, const casacore::IPosition &refnpix)
bool interpolateMaskedChannels(casacore::Array< float > spectrum, const casacore::Array< bool > maskp)
The base class of side band separation algorithm using FFT.
void deconvolve(casacore::Matrix< float > &specmat, const std::vector< double > shiftvec, const double threshold, casacore::Matrix< float > &outmat)
void subtractFromOther(const casacore::Matrix< float > &shiftmat, const std::vector< float > &invec, const std::vector< double > &shift, std::vector< float > &outvec)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
SideBandSeparatorII(const std::vector< std::string > &imagename)
The constructor.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
void init()
Initialize member variables.
void setThreshold(const double limit)
Set rejection limit of solution.
void aggregateMat(const casacore::Matrix< float > &inmat, std::vector< float > &outvec)
virtual void separate(const std::string &outfile, const bool overwrite)=0
invoke sideband separation
void setShift(const std::vector< double > &shift, const bool signal=true)
Set the number of channels shifted in each input data.
casacore::FFTServer< casacore::Float, casacore::Complex > fftsf
virtual ~SideBandSeparatorII()
The destructor.
virtual void separate(const std::string &outfile, const bool overwrite)
invoke sideband separation
void shiftFlag(const casacore::Vector< bool > &invec, double shift, casacore::Vector< bool > &outvec)
void setImageBandFrequency(const double refpix, const casacore::Quantity refval)
set frequency information of output image in image sideband
virtual ~SideBandSeparatorBase()
The destructor.
Interconvert pixel and world coordinates.
bool getImageCoordinate(const string &imagename, casacore::CoordinateSystem &csys, casacore::IPosition &npix)