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 <casa/Exceptions/Error.h>
|
---|
13 | #include <tables/Tables/TableDesc.h>
|
---|
14 | #include <tables/Tables/SetupNewTab.h>
|
---|
15 | #include <tables/Tables/ArrColDesc.h>
|
---|
16 | #include <tables/Tables/ScaColDesc.h>
|
---|
17 | #include <tables/Tables/TableRecord.h>
|
---|
18 | #include <measures/TableMeasures/TableMeasDesc.h>
|
---|
19 | #include <measures/TableMeasures/TableMeasRefDesc.h>
|
---|
20 | #include <measures/TableMeasures/TableMeasValueDesc.h>
|
---|
21 |
|
---|
22 | #include "Scantable.h"
|
---|
23 | #include "STCalTsysTable.h"
|
---|
24 |
|
---|
25 |
|
---|
26 | using namespace casa;
|
---|
27 |
|
---|
28 | namespace asap {
|
---|
29 |
|
---|
30 | const String STCalTsysTable::name_ = "APPLY_TSYS";
|
---|
31 |
|
---|
32 | STCalTsysTable::STCalTsysTable(const Scantable& parent)
|
---|
33 | : STApplyTable(parent, name_)
|
---|
34 | {
|
---|
35 | setup();
|
---|
36 | }
|
---|
37 |
|
---|
38 | STCalTsysTable::STCalTsysTable(const String &name)
|
---|
39 | : STApplyTable(name)
|
---|
40 | {
|
---|
41 | attachOptionalColumns();
|
---|
42 | }
|
---|
43 |
|
---|
44 | STCalTsysTable::~STCalTsysTable()
|
---|
45 | {
|
---|
46 | }
|
---|
47 |
|
---|
48 | void STCalTsysTable::setup()
|
---|
49 | {
|
---|
50 | table_.addColumn(ArrayColumnDesc<Float>("TSYS"));
|
---|
51 | table_.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
|
---|
52 |
|
---|
53 | table_.rwKeywordSet().define("ApplyType", "CALTSYS");
|
---|
54 |
|
---|
55 | attachOptionalColumns();
|
---|
56 | }
|
---|
57 |
|
---|
58 | void STCalTsysTable::attachOptionalColumns()
|
---|
59 | {
|
---|
60 | tsysCol_.attach(table_, "TSYS");
|
---|
61 | elCol_.attach(table_,"ELEVATION");
|
---|
62 |
|
---|
63 | }
|
---|
64 |
|
---|
65 | void STCalTsysTable::setdata(uInt irow, uInt scanno, uInt cycleno,
|
---|
66 | uInt beamno, uInt ifno, uInt polno, uInt freqid,
|
---|
67 | Double time, Float elevation, Vector<Float> tsys)
|
---|
68 | {
|
---|
69 | if (irow >= (uInt)nrow()) {
|
---|
70 | throw AipsError("row index out of range");
|
---|
71 | }
|
---|
72 |
|
---|
73 | if (!sel_.empty()) {
|
---|
74 | os_.origin(LogOrigin("STCalTsysTable","setdata",WHERE));
|
---|
75 | os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
|
---|
76 | }
|
---|
77 |
|
---|
78 | setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
|
---|
79 | elCol_.put(irow, elevation);
|
---|
80 | tsysCol_.put(irow, tsys);
|
---|
81 | }
|
---|
82 |
|
---|
83 | void STCalTsysTable::appenddata(uInt scanno, uInt cycleno,
|
---|
84 | uInt beamno, uInt ifno, uInt polno, uInt freqid,
|
---|
85 | Double time, Float elevation, Vector<Float> tsys)
|
---|
86 | {
|
---|
87 | uInt irow = nrow();
|
---|
88 | table_.addRow(1, True);
|
---|
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;
|
---|
114 | }
|
---|
115 | }
|
---|