1 | // |
---|
2 | // C++ Implementation: STApplyTable |
---|
3 | // |
---|
4 | // Description: |
---|
5 | // |
---|
6 | // |
---|
7 | // Author: Takeshi Nakazato |
---|
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/ScaColDesc.h> |
---|
16 | #include <tables/Tables/TableRecord.h> |
---|
17 | #include <measures/TableMeasures/TableMeasDesc.h> |
---|
18 | #include <measures/TableMeasures/TableMeasRefDesc.h> |
---|
19 | #include <measures/TableMeasures/TableMeasValueDesc.h> |
---|
20 | |
---|
21 | #include "Scantable.h" |
---|
22 | #include "STApplyTable.h" |
---|
23 | |
---|
24 | |
---|
25 | using namespace casa; |
---|
26 | |
---|
27 | namespace asap { |
---|
28 | |
---|
29 | STApplyTable::STApplyTable( const Scantable& parent, const casa::String& name ) |
---|
30 | { |
---|
31 | TableDesc td("", "1", TableDesc::Scratch); |
---|
32 | td.addColumn(ScalarColumnDesc<uInt>("SCANNO")); |
---|
33 | td.addColumn(ScalarColumnDesc<uInt>("CYCLENO")); |
---|
34 | td.addColumn(ScalarColumnDesc<uInt>("BEAMNO")); |
---|
35 | td.addColumn(ScalarColumnDesc<uInt>("IFNO")); |
---|
36 | td.addColumn(ScalarColumnDesc<uInt>("POLNO")); |
---|
37 | td.addColumn(ScalarColumnDesc<Double>("TIME")); |
---|
38 | TableMeasRefDesc measRef(MEpoch::UTC); // UTC as default |
---|
39 | TableMeasValueDesc measVal(td, "TIME"); |
---|
40 | TableMeasDesc<MEpoch> mepochCol(measVal, measRef); |
---|
41 | mepochCol.write(td); |
---|
42 | String tabname = parent.table().tableName()+"/"+name; |
---|
43 | SetupNewTable aNewTab(tabname, td, Table::Scratch); |
---|
44 | //table_ = Table(aNewTab, parent.table().tableType()); |
---|
45 | table_ = Table(aNewTab, Table::Memory); |
---|
46 | attachBaseColumns(); |
---|
47 | |
---|
48 | table_.rwKeywordSet().define("VERSION", 1); |
---|
49 | table_.rwKeywordSet().define("ScantableName", parent.table().tableName()); |
---|
50 | table_.rwKeywordSet().define("ApplyType", "NONE"); |
---|
51 | table_.rwKeywordSet().defineTable("FREQUENCIES", parent.frequencies().table()); |
---|
52 | |
---|
53 | table_.tableInfo().setType("ApplyTable"); |
---|
54 | |
---|
55 | originaltable_ = table_; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | STApplyTable::~STApplyTable() |
---|
60 | { |
---|
61 | } |
---|
62 | |
---|
63 | void STApplyTable::attach() |
---|
64 | { |
---|
65 | attachBaseColumns(); |
---|
66 | attachOptionalColumns(); |
---|
67 | } |
---|
68 | |
---|
69 | void STApplyTable::attachBaseColumns() |
---|
70 | { |
---|
71 | scanCol_.attach(table_, "SCANNO"); |
---|
72 | cycleCol_.attach(table_, "CYCLENO"); |
---|
73 | beamCol_.attach(table_, "BEAMNO"); |
---|
74 | ifCol_.attach(table_, "IFNO"); |
---|
75 | polCol_.attach(table_, "POLNO"); |
---|
76 | timeCol_.attach(table_, "TIME"); |
---|
77 | timeMeasCol_.attach(table_, "TIME"); |
---|
78 | } |
---|
79 | |
---|
80 | void STApplyTable::setSelection(STSelector &sel) |
---|
81 | { |
---|
82 | table_ = sel.apply(originaltable_); |
---|
83 | attach(); |
---|
84 | sel_ = sel; |
---|
85 | } |
---|
86 | |
---|
87 | void STApplyTable::unsetSelection() |
---|
88 | { |
---|
89 | table_ = originaltable_; |
---|
90 | attach(); |
---|
91 | sel_.reset(); |
---|
92 | } |
---|
93 | |
---|
94 | void STApplyTable::setbasedata(uInt irow, uInt scanno, uInt cycleno, |
---|
95 | uInt beamno, uInt ifno, uInt polno, |
---|
96 | Double time) |
---|
97 | { |
---|
98 | scanCol_.put(irow, scanno); |
---|
99 | cycleCol_.put(irow, cycleno); |
---|
100 | beamCol_.put(irow, beamno); |
---|
101 | ifCol_.put(irow, ifno); |
---|
102 | polCol_.put(irow, polno); |
---|
103 | timeCol_.put(irow, time); |
---|
104 | } |
---|
105 | |
---|
106 | } |
---|