[2703] | 1 | // |
---|
| 2 | // C++ Implementation: STCalSkyTable |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp> (C) 2012 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
[2727] | 12 | #include <assert.h> |
---|
| 13 | |
---|
[2703] | 14 | #include <casa/Exceptions/Error.h> |
---|
| 15 | #include <casa/Logging/LogIO.h> |
---|
| 16 | #include <tables/Tables/TableDesc.h> |
---|
| 17 | #include <tables/Tables/SetupNewTab.h> |
---|
| 18 | #include <tables/Tables/ArrColDesc.h> |
---|
| 19 | #include <tables/Tables/ScaColDesc.h> |
---|
| 20 | #include <tables/Tables/TableRecord.h> |
---|
| 21 | #include <measures/TableMeasures/TableMeasDesc.h> |
---|
| 22 | #include <measures/TableMeasures/TableMeasRefDesc.h> |
---|
| 23 | #include <measures/TableMeasures/TableMeasValueDesc.h> |
---|
| 24 | |
---|
| 25 | #include "Scantable.h" |
---|
| 26 | #include "STCalSkyTable.h" |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | using namespace casa; |
---|
| 30 | |
---|
| 31 | namespace asap { |
---|
| 32 | |
---|
| 33 | const String STCalSkyTable::name_ = "APPLY_SKY"; |
---|
| 34 | |
---|
| 35 | STCalSkyTable::STCalSkyTable(const Scantable& parent, const String &caltype) |
---|
| 36 | : STApplyTable(parent, name_), |
---|
| 37 | caltype_(caltype) |
---|
| 38 | { |
---|
| 39 | setup(); |
---|
| 40 | } |
---|
| 41 | |
---|
[2720] | 42 | STCalSkyTable::STCalSkyTable(const String &name) |
---|
| 43 | : STApplyTable(name) |
---|
| 44 | { |
---|
| 45 | attachOptionalColumns(); |
---|
| 46 | } |
---|
| 47 | |
---|
[2703] | 48 | STCalSkyTable::~STCalSkyTable() |
---|
| 49 | { |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | void STCalSkyTable::setup() |
---|
| 53 | { |
---|
| 54 | table_.addColumn(ArrayColumnDesc<Float>("SPECTRA")); |
---|
| 55 | table_.addColumn(ScalarColumnDesc<Float>("ELEVATION")); |
---|
| 56 | |
---|
| 57 | //table_.rwKeywordSet().define("ApplyType", "SKY"); |
---|
| 58 | String caltype = "CALSKY_" + caltype_; |
---|
| 59 | caltype.upcase(); |
---|
| 60 | table_.rwKeywordSet().define("ApplyType", caltype); |
---|
| 61 | |
---|
| 62 | attachOptionalColumns(); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | void STCalSkyTable::attachOptionalColumns() |
---|
| 66 | { |
---|
| 67 | spectraCol_.attach(table_, "SPECTRA"); |
---|
| 68 | elCol_.attach(table_,"ELEVATION"); |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | void STCalSkyTable::setdata(uInt irow, uInt scanno, uInt cycleno, |
---|
[2720] | 73 | uInt beamno, uInt ifno, uInt polno, uInt freqid, |
---|
| 74 | Double time, Float elevation, Vector<Float> spectra) |
---|
[2703] | 75 | { |
---|
| 76 | if (irow >= (uInt)nrow()) { |
---|
| 77 | throw AipsError("row index out of range"); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if (!sel_.empty()) { |
---|
| 81 | os_.origin(LogOrigin("STCalSkyTable","setdata",WHERE)); |
---|
| 82 | os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST; |
---|
| 83 | } |
---|
| 84 | |
---|
[2720] | 85 | setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time); |
---|
[2703] | 86 | elCol_.put(irow, elevation); |
---|
| 87 | spectraCol_.put(irow, spectra); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | void STCalSkyTable::appenddata(uInt scanno, uInt cycleno, |
---|
[2720] | 91 | uInt beamno, uInt ifno, uInt polno, uInt freqid, |
---|
| 92 | Double time, Float elevation, Vector<Float> spectra) |
---|
[2703] | 93 | { |
---|
| 94 | uInt irow = nrow(); |
---|
| 95 | table_.addRow(1, True); |
---|
[2720] | 96 | setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, spectra); |
---|
[2703] | 97 | } |
---|
[2720] | 98 | |
---|
| 99 | uInt STCalSkyTable::nchan(uInt ifno) |
---|
| 100 | { |
---|
| 101 | STSelector org = sel_; |
---|
| 102 | STSelector sel; |
---|
| 103 | sel.setIFs(vector<int>(1,(int)ifno)); |
---|
| 104 | setSelection(sel); |
---|
| 105 | uInt n = spectraCol_(0).nelements(); |
---|
| 106 | unsetSelection(); |
---|
| 107 | if (!org.empty()) |
---|
| 108 | setSelection(org); |
---|
| 109 | return n; |
---|
[2703] | 110 | } |
---|
[2720] | 111 | |
---|
| 112 | // Vector<Double> STCalSkyTable::getBaseFrequency(uInt whichrow) |
---|
| 113 | // { |
---|
| 114 | // assert(whichrow < nrow()); |
---|
| 115 | // uInt freqid = freqidCol_(whichrow); |
---|
| 116 | // uInt nc = spectraCol_(whichrow).nelements(); |
---|
| 117 | // Block<Double> f = getFrequenciesRow(freqid); |
---|
| 118 | // Vector<Double> freqs(nc); |
---|
| 119 | // indgen(freqs, f[1]-f[0]*f[2], f[2]); |
---|
| 120 | // return freqs; |
---|
| 121 | // } |
---|
| 122 | } |
---|