- Timestamp:
- 01/09/13 19:27:23 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 14 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CMakeLists.txt
r2707 r2720 76 76 ${SRCDIR}/STCalibration.cpp 77 77 ${SRCDIR}/STCalSkyPSAlma.cpp 78 ${SRCDIR}/STCalTsys.cpp ) 78 ${SRCDIR}/STCalTsys.cpp 79 ${SRCDIR}/STApplyCal.cpp 80 ${SRCDIR}/Calibrator.cpp 81 ${SRCDIR}/PSAlmaCalibrator.cpp 82 ${SRCDIR}/Locator.cpp 83 ${SRCDIR}/BisectionLocator.cpp 84 ${SRCDIR}/Interpolator1D.cpp 85 ${SRCDIR}/NearestInterpolator1D.cpp ) 79 86 80 87 set( ASAP_PYSRCS -
trunk/src/STApplyTable.cpp
r2703 r2720 15 15 #include <tables/Tables/ScaColDesc.h> 16 16 #include <tables/Tables/TableRecord.h> 17 #include <tables/Tables/Table.h> 18 #include <tables/Tables/ExprNode.h> 17 19 #include <measures/TableMeasures/TableMeasDesc.h> 18 20 #include <measures/TableMeasures/TableMeasRefDesc.h> … … 35 37 td.addColumn(ScalarColumnDesc<uInt>("IFNO")); 36 38 td.addColumn(ScalarColumnDesc<uInt>("POLNO")); 39 td.addColumn(ScalarColumnDesc<uInt>("FREQ_ID")); 37 40 td.addColumn(ScalarColumnDesc<Double>("TIME")); 38 41 TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default … … 53 56 table_.tableInfo().setType("ApplyTable"); 54 57 58 originaltable_ = table_; 59 } 60 61 STApplyTable::STApplyTable(const String &name) 62 { 63 table_ = Table(name, Table::Update); 64 attachBaseColumns(); 55 65 originaltable_ = table_; 56 66 } … … 76 86 timeCol_.attach(table_, "TIME"); 77 87 timeMeasCol_.attach(table_, "TIME"); 88 freqidCol_.attach(table_, "FREQ_ID"); 78 89 } 79 90 80 void STApplyTable::setSelection(STSelector &sel )91 void STApplyTable::setSelection(STSelector &sel, bool sortByTime) 81 92 { 82 93 table_ = sel.apply(originaltable_); 94 if (sortByTime) 95 table_.sort("TIME", Sort::Descending); 83 96 attach(); 84 97 sel_ = sel; … … 94 107 void STApplyTable::setbasedata(uInt irow, uInt scanno, uInt cycleno, 95 108 uInt beamno, uInt ifno, uInt polno, 96 Double time)109 uInt freqid, Double time) 97 110 { 98 111 scanCol_.put(irow, scanno); … … 102 115 polCol_.put(irow, polno); 103 116 timeCol_.put(irow, time); 117 freqidCol_.put(irow, freqid); 104 118 } 105 119 … … 109 123 } 110 124 125 String STApplyTable::caltype() 126 { 127 if (table_.keywordSet().isDefined("ApplyType")) { 128 return table_.keywordSet().asString("ApplyType"); 129 } 130 else 131 return "NONE"; 111 132 } 133 134 STCalEnum::CalType STApplyTable::getCalType(const String &name) 135 { 136 Table t(name, Table::Old); 137 return stringToType(t.keywordSet().asString("ApplyType")); 138 } 139 140 STCalEnum::CalType STApplyTable::getCalType(CountedPtr<STApplyTable> tab) 141 { 142 return stringToType(tab->caltype()); 143 } 144 145 STCalEnum::CalType STApplyTable::getCalType(STApplyTable *tab) 146 { 147 return stringToType(tab->caltype()); 148 } 149 150 STCalEnum::CalType STApplyTable::stringToType(const String &caltype) 151 { 152 if (caltype == "CALSKY_PSALMA") 153 return STCalEnum::CalPSAlma; 154 else if (caltype == "CALTSYS") 155 return STCalEnum::CalTsys; 156 else 157 return STCalEnum::NoType; 158 } 159 160 Block<Double> STApplyTable::getFrequenciesRow(uInt id) 161 { 162 const TableRecord &rec = table_.keywordSet(); 163 rec.print(os_.output()); 164 os_ << LogIO::POST; 165 Table ftab = rec.asTable("FREQUENCIES"); 166 Table t = ftab(ftab.col("ID") == id); 167 ROTableColumn col(t, "REFPIX"); 168 Block<Double> r(3); 169 r[0] = col.asdouble(0); 170 col.attach(t, "REFVAL"); 171 r[1] = col.asdouble(0); 172 col.attach(t, "INCREMENT"); 173 r[2] = col.asdouble(0); 174 return r; 175 } 176 } -
trunk/src/STApplyTable.h
r2703 r2720 22 22 #include "Scantable.h" 23 23 #include "STSelector.h" 24 #include "STCalEnum.h" 24 25 25 26 namespace asap { … … 36 37 STApplyTable() {;} 37 38 STApplyTable(const Scantable& parent, const casa::String& name); 39 STApplyTable(const casa::String &name); 38 40 39 41 virtual ~STApplyTable(); … … 55 57 virtual void attachOptionalColumns() = 0; 56 58 57 casa:: Int nrow() {return table_.nrow();}59 casa::uInt nrow() {return table_.nrow();} 58 60 59 61 casa::Vector<casa::uInt> getScan() {return scanCol_.getColumn();} … … 64 66 casa::Vector<casa::Double> getTime() {return timeCol_.getColumn();} 65 67 66 void setSelection(STSelector &sel );68 void setSelection(STSelector &sel, bool sortByTime=false); 67 69 void unsetSelection(); 70 casa::String caltype(); 68 71 69 72 void save(const casa::String &name); 73 74 virtual casa::uInt nchan(casa::uInt ifno) = 0; 75 76 // static methods 77 static STCalEnum::CalType getCalType(const casa::String &name); 78 static STCalEnum::CalType getCalType(casa::CountedPtr<STApplyTable> tab); 79 static STCalEnum::CalType getCalType(STApplyTable *tab); 70 80 71 81 protected: 72 82 void setbasedata(casa::uInt irow, casa::uInt scanno, casa::uInt cycleno, 73 83 casa::uInt beamno, casa::uInt ifno, casa::uInt polno, 74 casa::Double time); 84 casa::uInt freqid, casa::Double time); 85 casa::Block<casa::Double> getFrequenciesRow(casa::uInt id); 75 86 76 87 casa::Table table_, originaltable_; 77 casa::ScalarColumn<casa::uInt> scanCol_, cycleCol_, beamCol_, ifCol_, polCol_ ;88 casa::ScalarColumn<casa::uInt> scanCol_, cycleCol_, beamCol_, ifCol_, polCol_, freqidCol_; 78 89 casa::ScalarColumn<casa::Double> timeCol_; 79 90 casa::MEpoch::ScalarColumn timeMeasCol_; … … 82 93 83 94 private: 95 static STCalEnum::CalType stringToType(const casa::String &caltype); 84 96 }; 85 97 -
trunk/src/STCalSkyPSAlma.cpp
r2703 r2720 26 26 : STCalibration(s) 27 27 { 28 applytable_ = new STCalSkyTable(*s, "PS ");28 applytable_ = new STCalSkyTable(*s, "PSALMA"); 29 29 } 30 30 … … 63 63 ROArrayColumn<Float> specCol(scantable_->table(), "SPECTRA"); 64 64 ROArrayColumn<uChar> flagCol(scantable_->table(), "FLAGTRA"); 65 ROScalarColumn<uInt> freqidCol(scantable_->table(), "FREQ_ID"); 65 66 66 67 // dummy Tsys: the following process doesn't need Tsys but RowAccumulator … … 124 125 STCalSkyTable *p = dynamic_cast<STCalSkyTable *>(&(*applytable_)); 125 126 p->appenddata(0, 0, current[2], current[0], current[1], 126 timeCen, elCen, acc.getSpectrum());127 freqidCol(irow), timeCen, elCen, acc.getSpectrum()); 127 128 } 128 129 acc.reset() ; -
trunk/src/STCalSkyTable.cpp
r2703 r2720 38 38 } 39 39 40 STCalSkyTable::STCalSkyTable(const String &name) 41 : STApplyTable(name) 42 { 43 attachOptionalColumns(); 44 } 45 40 46 STCalSkyTable::~STCalSkyTable() 41 47 { … … 63 69 64 70 void STCalSkyTable::setdata(uInt irow, uInt scanno, uInt cycleno, 65 uInt beamno, uInt ifno, uInt polno,66 Double time, Float elevation, Vector<Float> spectra)71 uInt beamno, uInt ifno, uInt polno, uInt freqid, 72 Double time, Float elevation, Vector<Float> spectra) 67 73 { 68 74 if (irow >= (uInt)nrow()) { … … 75 81 } 76 82 77 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, time);83 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time); 78 84 elCol_.put(irow, elevation); 79 85 spectraCol_.put(irow, spectra); … … 81 87 82 88 void STCalSkyTable::appenddata(uInt scanno, uInt cycleno, 83 uInt beamno, uInt ifno, uInt polno,84 Double time, Float elevation, Vector<Float> spectra)89 uInt beamno, uInt ifno, uInt polno, uInt freqid, 90 Double time, Float elevation, Vector<Float> spectra) 85 91 { 86 92 uInt irow = nrow(); 87 93 table_.addRow(1, True); 88 setdata(irow, scanno, cycleno, beamno, ifno, polno, time, elevation, spectra);94 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, spectra); 89 95 } 96 97 uInt STCalSkyTable::nchan(uInt ifno) 98 { 99 STSelector org = sel_; 100 STSelector sel; 101 sel.setIFs(vector<int>(1,(int)ifno)); 102 setSelection(sel); 103 uInt n = spectraCol_(0).nelements(); 104 unsetSelection(); 105 if (!org.empty()) 106 setSelection(org); 107 return n; 90 108 } 109 110 // Vector<Double> STCalSkyTable::getBaseFrequency(uInt whichrow) 111 // { 112 // assert(whichrow < nrow()); 113 // uInt freqid = freqidCol_(whichrow); 114 // uInt nc = spectraCol_(whichrow).nelements(); 115 // Block<Double> f = getFrequenciesRow(freqid); 116 // Vector<Double> freqs(nc); 117 // indgen(freqs, f[1]-f[0]*f[2], f[2]); 118 // return freqs; 119 // } 120 } -
trunk/src/STCalSkyTable.h
r2703 r2720 35 35 STCalSkyTable() {;} 36 36 STCalSkyTable(const Scantable& parent, const casa::String &caltype); 37 STCalSkyTable(const casa::String &name); 37 38 38 39 virtual ~STCalSkyTable(); … … 44 45 45 46 void setdata(casa::uInt irow, casa::uInt scannos, casa::uInt cycleno, 46 casa::uInt beamno, casa::uInt ifno, 47 casa::uInt polno, casa::Double time, casa::Float elevation,47 casa::uInt beamno, casa::uInt ifno, casa::uInt polno, 48 casa::uInt freqid, casa::Double time, casa::Float elevation, 48 49 casa::Vector<casa::Float> spectra); 49 50 void appenddata(casa::uInt scanno, casa::uInt cycleno, casa::uInt beamno, 50 casa::uInt ifno, casa::uInt polno, 51 casa::uInt ifno, casa::uInt polno, casa::uInt freqid, 51 52 casa::Double time, casa::Float elevation, 52 53 casa::Vector<casa::Float> spectra); … … 54 55 casa::Vector<casa::Float> getElevation() {return elCol_.getColumn();} 55 56 casa::Matrix<casa::Float> getSpectra() {return spectraCol_.getColumn();} 57 casa::uInt nchan(casa::uInt ifno); 56 58 59 //casa::Vector<casa::Double> getBaseFrequency(casa::uInt whichrow); 57 60 private: 58 61 static const casa::String name_; -
trunk/src/STCalTsys.cpp
r2703 r2720 65 65 ROArrayColumn<Float> specCol(scantable_->table(), "TSYS"); 66 66 ROArrayColumn<uChar> flagCol(scantable_->table(), "FLAGTRA"); 67 ROScalarColumn<uInt> freqidCol(scantable_->table(), "FREQ_ID"); 67 68 68 69 // dummy Tsys: the following process doesn't need Tsys but RowAccumulator … … 126 127 STCalTsysTable *p = dynamic_cast<STCalTsysTable *>(&(*applytable_)); 127 128 p->appenddata(0, 0, current[2], current[0], current[1], 128 timeCen, elCen, acc.getSpectrum());129 freqidCol(irow), timeCen, elCen, acc.getSpectrum()); 129 130 } 130 131 acc.reset() ; -
trunk/src/STCalTsysTable.cpp
r2703 r2720 36 36 } 37 37 38 STCalTsysTable::STCalTsysTable(const String &name) 39 : STApplyTable(name) 40 { 41 attachOptionalColumns(); 42 } 43 38 44 STCalTsysTable::~STCalTsysTable() 39 45 { … … 45 51 table_.addColumn(ScalarColumnDesc<Float>("ELEVATION")); 46 52 47 table_.rwKeywordSet().define("ApplyType", " TSYS");53 table_.rwKeywordSet().define("ApplyType", "CALTSYS"); 48 54 49 55 attachOptionalColumns(); … … 58 64 59 65 void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno, 60 uInt beamno, uInt ifno, uInt polno,61 Double time, Float elevation, Vector<Float> tsys)66 uInt beamno, uInt ifno, uInt polno, uInt freqid, 67 Double time, Float elevation, Vector<Float> tsys) 62 68 { 63 69 if (irow >= (uInt)nrow()) { … … 70 76 } 71 77 72 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, time);78 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time); 73 79 elCol_.put(irow, elevation); 74 80 tsysCol_.put(irow, tsys); … … 76 82 77 83 void STCalTsysTable::appenddata(uInt scanno, uInt cycleno, 78 uInt beamno, uInt ifno, uInt polno,79 Double time, Float elevation, Vector<Float> tsys)84 uInt beamno, uInt ifno, uInt polno, uInt freqid, 85 Double time, Float elevation, Vector<Float> tsys) 80 86 { 81 87 uInt irow = nrow(); 82 88 table_.addRow(1, True); 83 setdata(irow, scanno, cycleno, beamno, ifno, polno, time, elevation, tsys); 89 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, tsys); 90 } 91 92 uInt STCalTsysTable::nchan(uInt ifno) 93 { 94 STSelector org = sel_; 95 STSelector sel; 96 sel.setIFs(vector<int>(1,(int)ifno)); 97 setSelection(sel); 98 uInt n = tsysCol_(0).nelements(); 99 unsetSelection(); 100 if (!org.empty()) 101 setSelection(org); 102 return n; 103 } 104 105 Vector<Double> STCalTsysTable::getBaseFrequency(uInt whichrow) 106 { 107 assert(whichrow < nrow()); 108 uInt freqid = freqidCol_(whichrow); 109 uInt nc = tsysCol_(whichrow).nelements(); 110 Block<Double> f = getFrequenciesRow(freqid); 111 Vector<Double> freqs(nc); 112 indgen(freqs, f[1]-f[0]*f[2], f[2]); 113 return freqs; 84 114 } 85 115 } -
trunk/src/STCalTsysTable.h
r2703 r2720 33 33 STCalTsysTable() {;} 34 34 STCalTsysTable(const Scantable& parent); 35 STCalTsysTable(const casa::String &name); 35 36 36 37 virtual ~STCalTsysTable(); … … 42 43 43 44 void setdata(casa::uInt irow, casa::uInt scanno, casa::uInt cycleno, 44 casa::uInt beamno, casa::uInt ifno, 45 casa::uInt polno, casa::Double time, casa::Float elevation,45 casa::uInt beamno, casa::uInt ifno, casa::uInt polno, 46 casa::uInt freqid, casa::Double time, casa::Float elevation, 46 47 casa::Vector<casa::Float> tsys); 47 48 void appenddata(casa::uInt scanno, casa::uInt cycleno, 48 49 casa::uInt beamno, casa::uInt ifno, casa::uInt polno, 49 casa:: Double time, casa::Float elevation,50 casa::uInt freqid, casa::Double time, casa::Float elevation, 50 51 casa::Vector<casa::Float> tsys); 51 52 52 53 casa::Vector<casa::Float> getElevation() {return elCol_.getColumn();} 53 54 casa::Matrix<casa::Float> getTsys() {return tsysCol_.getColumn();} 55 casa::uInt nchan(casa::uInt ifno); 56 57 casa::Vector<casa::Double> getBaseFrequency(casa::uInt whichrow); 54 58 55 59 private:
Note:
See TracChangeset
for help on using the changeset viewer.