source: trunk/src/STBaselineTable.cpp@ 2747

Last change on this file since 2747 was 2740, checked in by WataruKawasaki, 12 years ago

New Development: No

JIRA Issue: Yes CAS-4794

Ready for Test: No

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description:


File size: 4.3 KB
Line 
1//
2// C++ Implementation: STBaselineTable
3//
4// Description:
5//
6//
7// Author: Wataru Kawasaki <wataru.kawasaki@nao.ac.jp> (C) 2013
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 <casa/OS/Path.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 "STBaselineTable.h"
27
28
29using namespace casa;
30
31namespace asap {
32
33const String STBaselineTable::name_ = "APPLY_BASELINE";
34
35STBaselineTable::STBaselineTable(const Scantable& parent)
36 : STApplyTable(parent, name_)
37{
38 setup();
39}
40
41STBaselineTable::STBaselineTable(const String &name)
42 : STApplyTable(name)
43{
44 attachOptionalColumns();
45}
46
47STBaselineTable::~STBaselineTable()
48{
49}
50
51void STBaselineTable::setup()
52{
53 table_.addColumn(ScalarColumnDesc<uInt>("NCHAN"));
54 table_.addColumn(ScalarColumnDesc<uInt>("FUNC_TYPE"));
55 table_.addColumn(ArrayColumnDesc<uInt>("FUNC_PARAM"));
56 table_.addColumn(ArrayColumnDesc<Float>("FUNC_FPARAM"));
57 table_.addColumn(ScalarColumnDesc<uInt>("CLIP_ITERATION"));
58 table_.addColumn(ScalarColumnDesc<Float>("CLIP_THRESHOLD"));
59 table_.addColumn(ArrayColumnDesc<uInt>("MASKLIST"));
60 table_.addColumn(ArrayColumnDesc<Float>("RESULT"));
61 table_.addColumn(ScalarColumnDesc<Float>("RMS"));
62
63 table_.rwKeywordSet().define("ApplyType", "BASELINE");
64
65 attachOptionalColumns();
66}
67
68void STBaselineTable::attachOptionalColumns()
69{
70 nchanCol_.attach(table_, "NCHAN");
71 ftypeCol_.attach(table_, "FUNC_TYPE");
72 fparCol_.attach(table_, "FUNC_PARAM");
73 ffparCol_.attach(table_, "FUNC_FPARAM");
74 citerCol_.attach(table_, "CLIP_ITERATION");
75 cthresCol_.attach(table_, "CLIP_THRESHOLD");
76 maskCol_.attach(table_, "MASKLIST");
77 resCol_.attach(table_, "RESULT");
78 rmsCol_.attach(table_, "RMS");
79}
80
81void STBaselineTable::save(const std::string &filename)
82{
83 String inname(filename);
84 Path path(inname);
85 inname = path.expandedName();
86 table_.deepCopy(inname, Table::New);
87}
88
89void STBaselineTable::setdata(uInt irow, uInt scanno, uInt cycleno,
90 uInt beamno, uInt ifno, uInt polno,
91 uInt freqid, Double time,
92 uInt nchan,
93 STBaselineFunc::FuncName ftype,
94 Vector<uInt> fpar,
95 Vector<Float> ffpar,
96 uInt citer,
97 Float cthres,
98 Vector<uInt> mask,
99 Vector<Float> res,
100 Float rms)
101{
102 if (irow >= (uInt)nrow()) {
103 throw AipsError("row index out of range");
104 }
105
106 if (!sel_.empty()) {
107 os_.origin(LogOrigin("STBaselineTable","setdata",WHERE));
108 os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST;
109 }
110
111 setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time);
112 nchanCol_.put(irow, nchan);
113 ftypeCol_.put(irow, uInt(ftype));
114 fparCol_.put(irow, fpar);
115 ffparCol_.put(irow, ffpar);
116 citerCol_.put(irow, citer);
117 cthresCol_.put(irow, cthres);
118 maskCol_.put(irow, mask);
119 resCol_.put(irow, res);
120 rmsCol_.put(irow, rms);
121}
122
123void STBaselineTable::appenddata(uInt scanno, uInt cycleno,
124 uInt beamno, uInt ifno, uInt polno,
125 uInt freqid, Double time,
126 uInt nchan,
127 STBaselineFunc::FuncName ftype,
128 Vector<uInt> fpar,
129 Vector<Float> ffpar,
130 uInt citer,
131 Float cthres,
132 Vector<uInt> mask,
133 Vector<Float> res,
134 Float rms)
135{
136 uInt irow = nrow();
137 table_.addRow(1, True);
138 setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time,
139 nchan, ftype, fpar, ffpar, citer, cthres, mask, res, rms);
140}
141
142Vector<STBaselineFunc::FuncName> STBaselineTable::getFunctionAsString()
143{
144 Vector<uInt> rawBlfuncColumn = ftypeCol_.getColumn();
145 uInt n = rawBlfuncColumn.nelements();
146 Vector<STBaselineFunc::FuncName> blfuncColumn(n);
147 for (uInt i = 0; i < n; ++i) {
148 blfuncColumn[i] = STBaselineFunc::FuncName(rawBlfuncColumn(i));
149 }
150 return blfuncColumn;
151}
152
153uInt STBaselineTable::nchan(uInt ifno)
154{
155 STSelector org = sel_;
156 STSelector sel;
157 sel.setIFs(vector<int>(1,(int)ifno));
158 setSelection(sel);
159 uInt n = nchanCol_(0);
160 unsetSelection();
161 if (!org.empty())
162 setSelection(org);
163 return n;
164}
165}
Note: See TracBrowser for help on using the repository browser.