- Timestamp:
- 01/10/13 20:37:28 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STSideBandSep.cpp
r2716 r2726 32 32 using namespace asap ; 33 33 34 //#ifndef KS_DEBUG35 //#define KS_DEBUG36 //#endif34 #ifndef KS_DEBUG 35 #define KS_DEBUG 36 #endif 37 37 38 38 namespace asap { 39 39 40 40 // constructors 41 STSideBandSep::STSideBandSep() 42 : sigIfno_(0), ftol_(-1), 43 loTime_(-1), lo1Freq_(-1), loDir_("") 44 { 45 #ifdef KS_DEBUG 46 cout << "Default constructor STSideBandSep()" << endl; 47 #endif 48 // Default LO frame is TOPO 49 loFrame_ = MFrequency::TOPO; 41 STSideBandSep::STSideBandSep(const vector<string> &names) 42 { 43 LogIO os(LogOrigin("STSideBandSep","STSideBandSep()", WHERE)); 44 os << "Setting scantable names to process." << LogIO::POST ; 45 // Set file names 46 ntable_ = names.size(); 47 infileList_.resize(ntable_); 48 for (unsigned int i = 0; i < ntable_; i++){ 49 if (!checkFile(names[i], "d")) 50 throw( AipsError("File does not exist") ); 51 infileList_[i] = names[i]; 52 } 53 intabList_.resize(0); 54 55 init(); 56 57 {// Summary 58 os << ntable_ << " files are set: ["; 59 for (unsigned int i = 0; i < ntable_; i++) { 60 os << " '" << infileList_[i] << "' "; 61 if (i != ntable_-1) os << ","; 62 } 63 os << "] " << LogIO::POST; 64 } 65 }; 66 67 STSideBandSep::STSideBandSep(const vector<ScantableWrapper> &tables) 68 { 69 LogIO os(LogOrigin("STSideBandSep","STSideBandSep()", WHERE)); 70 os << "Setting list of scantables to process." << LogIO::POST ; 71 // Set file names 72 ntable_ = tables.size(); 73 intabList_.resize(ntable_); 74 for (unsigned int i = 0; i < ntable_; i++){ 75 intabList_[i] = tables[i].getCP(); 76 } 77 infileList_.resize(0); 78 79 init(); 80 81 os << ntable_ << " tables are set." << LogIO::POST; 50 82 }; 51 83 … … 57 89 }; 58 90 59 60 void STSideBandSep::setFrequency(const unsigned int ifno, const double freqtol, string frame) 61 { 62 #ifdef KS_DEBUG 63 cout << "STSideBandSep::setFrequency" << endl; 64 cout << "IFNO = " << ifno << endl; 65 cout << "freq tol = " << freqtol << " [Hz]" << endl; 66 cout << "frame = " << frame << endl; 67 #endif 91 void STSideBandSep::init() 92 { 93 // frequency setup 94 sigIfno_= 0; 95 ftol_ = -1; 96 solFrame_ = MFrequency::N_Types; 97 // shifts 98 initshift(); 99 // direction tolerance 100 xtol_ = ytol_ = 9.69627e-6; // 2arcsec 101 // solution parameters 102 otherside_ = false; 103 doboth_ = false; 104 rejlimit_ = 0.2; 105 // LO1 values 106 lo1Freq_ = -1; 107 loTime_ = -1; 108 loDir_ = ""; 109 // Default LO frame is TOPO 110 loFrame_ = MFrequency::TOPO; 111 }; 112 113 void STSideBandSep::initshift() 114 { 115 // shifts 116 nshift_ = 0; 117 nchan_ = 0; 118 sigShift_.resize(0); 119 imgShift_.resize(0); 120 tableList_.resize(0); 121 }; 122 123 void STSideBandSep::setFrequency(const unsigned int ifno, 124 const string freqtol, 125 const string frame) 126 { 127 LogIO os(LogOrigin("STSideBandSep","setFrequency()", WHERE)); 128 129 initshift(); 130 131 // IFNO 132 sigIfno_ = ifno; 133 134 // Frequency tolerance 135 Quantum<Double> qftol; 136 readQuantity(qftol, String(freqtol)); 137 if (!qftol.getUnit().empty()){ 138 // make sure the quantity is frequency 139 if (qftol.getFullUnit().getValue() != Unit("Hz").getValue()) 140 throw( AipsError("Invalid quantity for frequency tolerance.") ); 141 qftol.convert("Hz"); 142 } 143 ftol_ = qftol; 144 145 // Frequency Frame 146 if (!frame.empty()){ 147 MFrequency::Types mft; 148 if (!MFrequency::getType(mft, frame)) 149 throw( AipsError("Invalid frame type.") ); 150 solFrame_ = mft; 151 } else { 152 solFrame_ = MFrequency::N_Types; 153 } 154 155 {// Summary 156 const String sframe = ( (solFrame_ == MFrequency::N_Types) ? 157 "table frame" : 158 MFrequency::showType(solFrame_) ); 159 os << "Frequency setup to search IF group: " 160 << "IFNO of table[0] = " << sigIfno_ 161 << " , Freq tolerance = " << ftol_.getValue() << " [ " 162 << (ftol_.getUnit().empty() ? "channel" : ftol_.getUnit() ) 163 << " ] (in " << sframe <<")" << LogIO::POST; 164 } 165 }; 166 167 168 void STSideBandSep::setDirTolerance(const vector<string> dirtol) 169 { 170 LogIO os(LogOrigin("STSideBandSep","setDirTolerance()", WHERE)); 171 Quantum<Double> qcell; 172 if ( (dirtol.size() == 1) && !dirtol[0].empty() ) { 173 readQuantity(qcell, String(dirtol[0])); 174 if (qcell.getFullUnit().getValue() == Unit("rad").getValue()) 175 xtol_ = ytol_ = qcell.getValue("rad"); 176 else 177 throw( AipsError("Invalid unit for direction tolerance.") ); 178 } 179 else if (dirtol.size() > 1) { 180 if ( dirtol[0].empty() && dirtol[1].empty() ) 181 throw( AipsError("Direction tolerance is empty.") ); 182 if ( !dirtol[0].empty() ) { 183 readQuantity(qcell, String(dirtol[0])); 184 if (qcell.getFullUnit().getValue() == Unit("rad").getValue()) 185 xtol_ = qcell.getValue("rad"); 186 else 187 throw( AipsError("Invalid unit for direction tolerance.") ); 188 } 189 if ( !dirtol[1].empty() ) { 190 readQuantity(qcell, String(dirtol[1])); 191 if (qcell.getFullUnit().getValue() == Unit("rad").getValue()) 192 ytol_ = qcell.getValue("rad"); 193 else 194 throw( AipsError("Invalid unit for direction tolerance.") ); 195 } 196 else { 197 ytol_ = xtol_; 198 } 199 } 200 else throw( AipsError("Invalid direction tolerance.") ); 201 202 os << "Direction tolerance: ( " 203 << xtol_ << " , " << ytol_ << " ) [rad]" << LogIO::POST; 204 }; 205 206 void STSideBandSep::setShift(const vector<double> &shift) 207 { 208 LogIO os(LogOrigin("STSideBandSep","setShift()", WHERE)); 209 imgShift_.resize(shift.size()); 210 for (unsigned int i = 0; i < shift.size(); i++) 211 imgShift_[i] = shift[i]; 212 213 if (imgShift_.size() == 0) { 214 os << "Channel shifts are cleared." << LogIO::POST; 215 } else { 216 os << "Channel shifts of image sideband are set: ( "; 217 for (unsigned int i = 0; i < imgShift_.size(); i++) { 218 os << imgShift_[i]; 219 if (i != imgShift_.size()-1) os << " , "; 220 } 221 os << " ) [channel]" << LogIO::POST; 222 } 223 }; 224 225 void STSideBandSep::setThreshold(const double limit) 226 { 227 LogIO os(LogOrigin("STSideBandSep","setThreshold()", WHERE)); 228 if (limit < 0) 229 throw( AipsError("Rejection limit should be positive number.") ); 230 231 rejlimit_ = limit; 232 os << "Rejection limit is set to " << rejlimit_; 68 233 }; 69 234 … … 81 246 82 247 // 83 void STSideBandSep::setLO1(const double lo1, string frame, double reftime, string refdir) 248 void STSideBandSep::setLO1(const double lo1, const string frame, 249 const double reftime, const string refdir) 84 250 { 85 251 lo1Freq_ = lo1; -
trunk/src/STSideBandSep.h
r2712 r2726 36 36 * constructors and a destructor 37 37 **/ 38 STSideBandSep() ;39 //explicit STSideBandSep(const vector<string> infile);40 //explicit STSideBandSep(const vector<ScantableWrapper> &tables);38 STSideBandSep() { throw( AipsError("No data set to process") ); }; 39 explicit STSideBandSep(const vector<string> &names); 40 explicit STSideBandSep(const vector<ScantableWrapper> &tables); 41 41 virtual ~STSideBandSep(); 42 42 43 43 /** 44 * Set parameters for sideband separation44 * Set IFNO and frequency tolerance to select data to process 45 45 **/ 46 void setFrequency(const unsigned int ifno, const double freqtol, string frame=""); 46 void setFrequency(const unsigned int ifno, const string freqtol, 47 const string frame=""); 48 49 /** 50 * Set direction tolerance to group spectra. 51 * The spectra within this range will be averaged before procesing. 52 **/ 53 void setDirTolerance(const vector<string> dirtol); 54 55 /** 56 * Set the number of channels shifted in image side band 57 * of each of scantable. 58 **/ 59 void setShift(const vector<double> &shift); 60 61 /** 62 * Set rejection limit of solution. 63 **/ 64 void setThreshold(const double limit); 65 66 /** 67 * Resolve both image and signal sideband when true is set. 68 **/ 69 void solveBoth(const bool flag) { doboth_ = flag; }; 70 71 /** 72 * Obtain spectra by subtracting the solution of the other sideband. 73 **/ 74 void solvefromOther(const bool flag) { otherside_ = flag; }; 47 75 48 76 /** … … 51 79 void setImageTable(const ScantableWrapper &s); 52 80 void setScanTb0(const ScantableWrapper &s); 81 53 82 /** 54 83 * Set additional information to fill frequencies of image sideband 55 84 **/ 56 void setLO1(const double lo1, string frame="TOPO", double reftime=-1, string refdir=""); 85 void setLO1(const double lo1, const string frame="TOPO", 86 const double reftime=-1, string refdir=""); 57 87 void setLO1Root(const string name); 88 58 89 /** 59 90 * Actual calculation of frequencies of image sideband … … 62 93 63 94 private: 95 /** Initialize member variables **/ 96 void init(); 97 void initshift(); 98 99 /** Return if the path exists (optionally, check file type) **/ 64 100 Bool checkFile(const string name, string type=""); 101 102 /** 103 * Get LO1 frequency to solve the frequencies of image side band 104 **/ 65 105 bool getLo1FromAsdm(const string asdmname, 66 106 const double refval, const double refpix, … … 73 113 const double increment, const int nChan); 74 114 115 /** Member variables **/ 116 // input tables 117 vector<string> infileList_; 118 vector< CountedPtr<Scantable> > intabList_; 119 unsigned int ntable_; 120 // frequency and direction setup to select data. 75 121 unsigned int sigIfno_; 76 double ftol_; 122 Quantum<Double> ftol_; 123 MFrequency::Types solFrame_; 124 vector<double> sigShift_, imgShift_; 125 unsigned int nshift_, nchan_; 126 vector< CountedPtr<Scantable> > tableList_; 127 Double xtol_, ytol_; 128 // solution parameters 129 bool otherside_, doboth_; 130 double rejlimit_; 131 // LO1 77 132 double lo1Freq_; 78 133 MFrequency::Types loFrame_; -
trunk/src/python_STSideBandSep.cpp
r2712 r2726 10 10 #include <boost/python/args.hpp> 11 11 12 13 12 #include "STSideBandSep.h" 14 13 … … 21 20 class_<STSideBandSep>("SBSeparator") 22 21 .def( init <> () ) 22 .def( init < const std::vector<std::string> > () ) 23 .def( init < const std::vector<ScantableWrapper> > () ) 23 24 .def( "set_freq", &STSideBandSep::setFrequency, 24 25 (boost::python::arg("frame")="") ) 26 .def( "set_dirtol", &STSideBandSep::setDirTolerance ) 27 .def( "set_shift", &STSideBandSep::setShift ) 28 .def( "set_limit", &STSideBandSep::setThreshold ) 29 .def( "solve_both", &STSideBandSep::solveBoth ) 30 .def( "subtract_other", &STSideBandSep::solvefromOther ) 25 31 .def( "set_lo1", &STSideBandSep::setLO1, 26 32 (boost::python::arg("frame")="TOPO",
Note:
See TracChangeset
for help on using the changeset viewer.