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