[2703] | 1 | //
|
---|
| 2 | // C++ Implementation: STCalTsysTable
|
---|
| 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 | //
|
---|
[2724] | 12 | #include <assert.h>
|
---|
| 13 |
|
---|
[2703] | 14 | #include <casa/Exceptions/Error.h>
|
---|
[2756] | 15 | #include <casa/Utilities/Assert.h>
|
---|
[2703] | 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 "STCalTsysTable.h"
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | using namespace casa;
|
---|
| 30 |
|
---|
| 31 | namespace asap {
|
---|
| 32 |
|
---|
| 33 | const String STCalTsysTable::name_ = "APPLY_TSYS";
|
---|
| 34 |
|
---|
| 35 | STCalTsysTable::STCalTsysTable(const Scantable& parent)
|
---|
| 36 | : STApplyTable(parent, name_)
|
---|
| 37 | {
|
---|
| 38 | setup();
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[2720] | 41 | STCalTsysTable::STCalTsysTable(const String &name)
|
---|
| 42 | : STApplyTable(name)
|
---|
| 43 | {
|
---|
| 44 | attachOptionalColumns();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[2703] | 47 | STCalTsysTable::~STCalTsysTable()
|
---|
| 48 | {
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | void STCalTsysTable::setup()
|
---|
| 52 | {
|
---|
| 53 | table_.addColumn(ArrayColumnDesc<Float>("TSYS"));
|
---|
| 54 | table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
|
---|
| 55 |
|
---|
[2720] | 56 | table_.rwKeywordSet().define("ApplyType", "CALTSYS");
|
---|
[2703] | 57 |
|
---|
| 58 | attachOptionalColumns();
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | void STCalTsysTable::attachOptionalColumns()
|
---|
| 62 | {
|
---|
| 63 | tsysCol_.attach(table_, "TSYS");
|
---|
| 64 | elCol_.attach(table_,"ELEVATION");
|
---|
| 65 |
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno,
|
---|
[2720] | 69 | uInt beamno, uInt ifno, uInt polno, uInt freqid,
|
---|
| 70 | Double time, Float elevation, Vector<Float> tsys)
|
---|
[2703] | 71 | {
|
---|
| 72 | if (irow >= (uInt)nrow()) {
|
---|
| 73 | throw AipsError("row index out of range");
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | if (!sel_.empty()) {
|
---|
| 77 | os_.origin(LogOrigin("STCalTsysTable","setdata",WHERE));
|
---|
| 78 | os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[2720] | 81 | setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
|
---|
[2703] | 82 | elCol_.put(irow, elevation);
|
---|
| 83 | tsysCol_.put(irow, tsys);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void STCalTsysTable::appenddata(uInt scanno, uInt cycleno,
|
---|
[2720] | 87 | uInt beamno, uInt ifno, uInt polno, uInt freqid,
|
---|
| 88 | Double time, Float elevation, Vector<Float> tsys)
|
---|
[2703] | 89 | {
|
---|
| 90 | uInt irow = nrow();
|
---|
| 91 | table_.addRow(1, True);
|
---|
[2720] | 92 | setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, elevation, tsys);
|
---|
[2703] | 93 | }
|
---|
[2720] | 94 |
|
---|
| 95 | uInt STCalTsysTable::nchan(uInt ifno)
|
---|
| 96 | {
|
---|
| 97 | STSelector org = sel_;
|
---|
| 98 | STSelector sel;
|
---|
| 99 | sel.setIFs(vector<int>(1,(int)ifno));
|
---|
| 100 | setSelection(sel);
|
---|
| 101 | uInt n = tsysCol_(0).nelements();
|
---|
| 102 | unsetSelection();
|
---|
| 103 | if (!org.empty())
|
---|
| 104 | setSelection(org);
|
---|
| 105 | return n;
|
---|
[2703] | 106 | }
|
---|
[2720] | 107 |
|
---|
| 108 | Vector<Double> STCalTsysTable::getBaseFrequency(uInt whichrow)
|
---|
| 109 | {
|
---|
[2756] | 110 | //assert(whichrow < nrow());
|
---|
| 111 | assert_<AipsError>(whichrow < nrow(), "row index out of range.");
|
---|
[2720] | 112 | uInt freqid = freqidCol_(whichrow);
|
---|
| 113 | uInt nc = tsysCol_(whichrow).nelements();
|
---|
| 114 | Block<Double> f = getFrequenciesRow(freqid);
|
---|
| 115 | Vector<Double> freqs(nc);
|
---|
| 116 | indgen(freqs, f[1]-f[0]*f[2], f[2]);
|
---|
| 117 | return freqs;
|
---|
| 118 | }
|
---|
| 119 | }
|
---|